Telegram Integration
Support customers via Telegram bots
Create a Telegram bot to handle support requests. Customers message your bot, and Keva creates tickets and responds directly in the chat.
Prerequisites
- A Telegram account
- A bot created via BotFather
Setup
1. Create a Telegram Bot
- Open Telegram and message @BotFather
- Send
/newbotand follow the prompts - Note your Bot Token (format:
123456789:ABCdefGHI...)
2. Connect to Keva
Go to Settings > Integrations > Telegram and enter:
- Bot Token: From BotFather
- Webhook Secret: A random string you choose
3. Set Up Webhook
curl -X POST "https://api.telegram.org/bot<TOKEN>/setWebhook" \
-H "Content-Type: application/json" \
-d '{
"url": "https://app.keva.support/api/webhooks/telegram?bot_id=<CONNECTOR_ID>",
"secret_token": "<YOUR_SECRET>"
}'4. Subscribe to Chats
Go to Settings > Channels, click Add Telegram Bot, and configure:
- Private chats: Use
*as channel ID for all private messages - Group chats: Use the specific group chat ID
Configuration Options
Create Ticket On
| Setting | Behavior |
|---|---|
| New thread | New messages in private chats; non-replies in groups |
| Any message | Every message creates or updates a ticket |
| Mention | Only when bot is @mentioned (best for groups) |
Routing
- Workspace: Route to a specific workspace
- Default Priority: Set initial priority
- Auto-assign: Assign to AI or specific agent
Chat Types
| Type | Description |
|---|---|
private | 1-on-1 with bot (primary support channel) |
group | Group chat with bot |
supergroup | Large group with admin features |
How It Works
- Customer messages your bot
- Telegram sends update to webhook
- Secret token header validated
- Keva creates ticket from message
- AI processes and drafts response
- Reply sent via Telegram Bot API
- Customer sees response in same chat
Conversation Threading
Conversations threaded by Telegram chat ID:
- Private chats: One thread per user
- Groups: One thread per group
- Closed tickets: New messages create new tickets
Customer Identification
Telegram provides:
- User ID: Unique numeric ID
- Username: @username (if set)
- First/Last Name: Display name
Email generated as {user_id}@telegram.keva.local.
Getting Group Chat ID
- Add bot to the group
- Send a message in the group
- Check webhook payload for
chat.id
Or use: curl "https://api.telegram.org/bot<TOKEN>/getUpdates"
Group IDs are negative (e.g., -1001234567890).
Troubleshooting
Webhook not receiving: Verify with getWebhookInfo, check HTTPS URL, confirm bot_id parameter.
Secret token failing: Check header X-Telegram-Bot-Api-Secret-Token, re-register webhook if needed.
Bot not responding: Test with getMe API, verify subscription active, check ticket created.
Group messages ignored: Verify group chat ID, check "Create Ticket On" setting, ensure bot has read permission.
Security
- Secret token header validation
- Timing-safe token comparison
- Bot tokens encrypted at rest
- Bot messages automatically filtered
- All updates logged in audit trail