Telegram
Connect the agent to Telegram through a bot registered with @BotFather.
Telegram
The Telegram integration lets the agent talk to users directly in Telegram, through a bot registered with @BotFather.
Reach it through the Settings icon → Integrations tab → the Telegram card.
Turning the integration on
Turn on the toggle in the Telegram card. The configuration fields appear once it is on.
How it works
- The user sends a message to the bot in Telegram.
- Telegram forwards the update to Roberty's webhook.
- Roberty validates the
X-Telegram-Bot-Api-Secret-Tokenheader (where one is configured). - The agent runs and the answer goes out through
sendMessage.
The webhook's endpoint:
https://agent-backend.roberty.app/integrations/telegram/<AGENT_ID>
Use Copy ID at the top of the Integrations tab to get the AGENT_ID.
The configuration fields
| Field | Required | What it is |
|---|---|---|
| Bot Token | Yes | The token @BotFather gives you when the bot is created |
| Secret Token | No | A security string — it must match the secret_token parameter of the setWebhook call |
| Allowed Chat IDs | No | Chat IDs separated by commas (123456789,-100987654321). With this filled in, the bot only answers in those chats |
Creating the bot in Telegram
1. Create the bot
- In Telegram, open the chat with @BotFather.
- Send
/newbotand follow the instructions to name it. - BotFather gives you the Bot Token at the end.
2. Register the webhook
Use the setWebhook API to register Roberty's endpoint:
curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" \
-H "Content-Type: application/json" \
-d '{
"url": "https://agent-backend.roberty.app/integrations/telegram/<AGENT_ID>",
"secret_token": "YOUR_OPTIONAL_SECRET",
"allowed_updates": ["message", "edited_message"]
}'
secret_tokenis optional but strongly recommended in production.- To remove the webhook:
POST /bot<TOKEN>/deleteWebhook.
3. Configure the agent in Roberty
Fill in Bot Token and, optionally, Secret Token and Allowed Chat IDs.
4. (Optional) Restrict who can talk to it
Use Allowed Chat IDs to restrict the bot to particular conversations.
To find a chat.id:
- Send
/startto your bot. - Call
https://api.telegram.org/bot<BOT_TOKEN>/getUpdates. message.chat.idis in the JSON that comes back.
Chats that are not allowed get a silent 200, with no answer.
Security validation
With a Secret Token configured on the agent, Telegram sends the X-Telegram-Bot-Api-Secret-Token: <value> header. Requests without it, or with a different value, get a 401.
With Secret Token blank, that validation is off.
The update types it handles
| Update | What happens |
|---|---|
message | Runs the agent with message.text. |
edited_message | Treated as a new message (the updated text). |
Other types (button callbacks, commands, photos and so on) are ignored in the current version.