Telegram
Telegram is the simplest channel to configure — bot creation takes under five minutes with no external approval required. This guide covers creating a bot with @BotFather, connecting it to Snippbot, and registering the webhook.
Prerequisites
Section titled “Prerequisites”- A Telegram account (mobile or desktop)
- A running Snippbot instance reachable from the internet on port 18790 (or via ngrok)
- HTTPS on your webhook URL (required by Telegram in production)
Setup Steps
Section titled “Setup Steps”-
Open @BotFather in Telegram
Start a conversation with @BotFather. This is Telegram’s official bot management account.
-
Create a new bot
Send the command:
/newbotBotFather asks you two questions:
- Name: A display name for your bot (e.g. “My Snippbot”)
- Username: A unique handle ending in
bot(e.g.mysnippbot→@mysnippbot)
-
Copy the bot token
After creating the bot, BotFather replies with a message containing your bot token. It looks like:
1234567890:AAFhash_randomcharactershereCopy this token. Treat it like a password — anyone with this token can control your bot.
-
Configure Snippbot with the bot token
In the Snippbot UI, navigate to Settings > Channels > Telegram and enter:
Field Value Bot Token The token from BotFather Webhook Secret Optional random string for request verification (recommended) Click Save.
Alternatively, add it to
~/.snippbot/config.toml:~/.snippbot/config.toml [channels.telegram]bot_token = "1234567890:AAFhash_randomcharactershere"webhook_secret = "my-random-secret-string" -
Start the channel adapter
Start the channel adapter snippbot channel startWhen the adapter starts, Snippbot automatically calls the Telegram Bot API to register the webhook URL:
POST https://api.telegram.org/bot{token}/setWebhookBody: { "url": "https://your-server.com:18790/webhook/telegram" }The webhook URL is derived from the
public_urlsetting in your Snippbot config (see Configuration Reference). -
Verify the webhook is registered
Check webhook status curl "https://api.telegram.org/bot{YOUR_BOT_TOKEN}/getWebhookInfo"A successful response looks like:
{"ok": true,"result": {"url": "https://your-server.com:18790/webhook/telegram","has_custom_certificate": false,"pending_update_count": 0,"last_error_date": null,"last_error_message": null,"max_connections": 40}} -
Test the bot
Open Telegram and search for your bot by its username (e.g.
@mysnippbot). Send it a message. The bot should reply within a few seconds.
Webhook URL Pattern
Section titled “Webhook URL Pattern”Snippbot registers the webhook at this path on the channel adapter:
https://{your-public-host}:18790/webhook/telegramThe {your-public-host} is determined by the public_url config setting:
[channels]public_url = "https://snippbot.yourserver.com"If public_url is not set, Snippbot will prompt you to provide it when you start the adapter.
Configuration Reference
Section titled “Configuration Reference”| Option | Type | Required | Description |
|---|---|---|---|
bot_token | string | Yes | Bot token from @BotFather |
webhook_secret | string | No | Random secret added to webhook URL for verification. Snippbot validates this on every incoming request |
default_agent_id | string | No | Agent to use when no binding matches the incoming chat ID |
parse_mode | string | No | How to format bot replies: Markdown, MarkdownV2, or HTML (default: MarkdownV2) |
Channel Bindings
Section titled “Channel Bindings”By default, all messages to your Telegram bot are routed to the default agent. To route messages from specific Telegram chats or users to different agents:
Bind a Telegram chat to an agent
Section titled “Bind a Telegram chat to an agent”- Open Settings → Channels → Bindings in the Snippbot UI
- Click New Binding
- Select Telegram as the platform
- Enter the Telegram chat ID as the context ID
- Select which agent handles messages from that chat
- Click Save
The context_id is the Telegram chat ID. To find a chat ID, forward a message from that chat to @userinfobot, which returns the ID.
All binding management is done through the Snippbot UI under Settings → Channels → Bindings.
Troubleshooting
Section titled “Troubleshooting”Webhook registration fails at startup
Section titled “Webhook registration fails at startup”The most common cause is that your server is not reachable from the internet, or is using HTTP instead of HTTPS.
- Telegram requires HTTPS for all webhook URLs
- For local development, use ngrok:
ngrok http 18790— the HTTPS URL provided by ngrok works with Telegram - Set
public_urlto the ngrok HTTPS URL before starting the adapter
The bot does not respond
Section titled “The bot does not respond”- Check the adapter is running:
snippbot channel startshould show no errors - Check the webhook is registered: run the
getWebhookInfocommand above and look for errors inlast_error_message - Look at adapter logs for any routing errors
”Unauthorized” error from Telegram API
Section titled “”Unauthorized” error from Telegram API”Your bot token is incorrect or has been revoked. Generate a new token with BotFather:
/mybots → select your bot → API Token → Revoke current tokenThen update the token in Snippbot settings.
Messages are delivered but formatting looks wrong
Section titled “Messages are delivered but formatting looks wrong”Snippbot uses MarkdownV2 by default. If you see raw asterisks or underscores in replies, switch to HTML mode in the config:
[channels.telegram]parse_mode = "HTML"