Documentation Index
Fetch the complete documentation index at: https://mintlify.com/stephengpope/thepopebot/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Pope Bot framework provides two Telegram endpoints:- POST /api/telegram/register - Register your bot’s webhook URL
- POST /api/telegram/webhook - Receive incoming messages from Telegram
Register Webhook
Endpoint
Authentication
Requiresx-api-key header. See Authentication.
Request Body
Your Telegram bot token from @BotFather
Public HTTPS URL where Telegram will send updates (must be
/api/telegram/webhook)Example Request
Response
Success (200)
Error Responses
Missing Parameters (400)
Registration Failed (500)
Webhook Handler
Endpoint
Authentication
Public endpoint - Telegram authenticates usingTELEGRAM_WEBHOOK_SECRET environment variable.
This endpoint does not require
x-api-key header. Telegram verifies requests using the webhook secret.How It Works
- Telegram sends message to
/api/telegram/webhook - Server validates webhook secret
- Message normalized via
getTelegramAdapter().receive(request) - Processes message asynchronously through AI layer
- Returns
{"ok": true}immediately (non-blocking) - AI generates response and sends via Telegram API
Message Processing
- Acknowledge receipt to Telegram
- Start “typing” indicator
- Call
chat(threadId, text, attachments, metadata) - Stream response back to user via Telegram
- Stop typing indicator
Environment Variables
Default bot token (can be overridden by
/telegram/register)Secret token for webhook authentication
Setup Example
1. Create Bot with BotFather
- Message @BotFather on Telegram
- Send
/newbotand follow prompts - Save your bot token (looks like
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)
2. Set Environment Variables
3. Register Webhook
4. Test Your Bot
Send a message to your bot on Telegram. It should respond using your configured LLM.Channel Adapter
The Telegram integration uses a channel adapter pattern (lib/channels/telegram.js) to normalize messages into a common format:
lib/ai/) to handle messages from any channel (Telegram, web chat, etc.) uniformly.