Heypi connects to Telegram using long polling — no public URL or webhook registration required. The adapter callsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/hunvreus/heypi/llms.txt
Use this file to discover all available pages before exploring further.
getUpdates in a continuous loop, processes each update, and automatically backs off if Telegram returns errors. This approach works out of the box for both local development and production deployments without any infrastructure changes.
Create a Bot
Open BotFather
In Telegram, start a conversation with @BotFather.
Create a new bot
Send the
/newbot command. BotFather will ask for a display name and then a username ending in bot.Discover Chat IDs
Telegram bots cannot enumerate chats — the bot must observe an inbound message first. Thetelegram observe command temporarily takes over long polling for your token and prints IDs as messages arrive.
/start to the bot in a DM, or post a message in the target group or channel. The CLI prints a ready-to-paste snippet:
allow.chats (for groups and channels) or in scheduled job targets. For DM-only bots, leave allow.chats empty and restrict by user ID with allow.users instead.
Configure the Adapter
Config Reference
Theallow object controls which chats and users can trigger the bot. The trigger and threadTrigger options are top-level adapter config, not nested under allow:
| Option | Nested under | Type | Description |
|---|---|---|---|
allow.chats | allow | string[] | Group or channel chat IDs (not applied to DMs) |
allow.users | allow | string[] | User IDs allowed to interact with the bot |
allow.dms | allow | boolean | Whether to accept direct messages |
trigger | top-level | "mention" | "message" | "mention" requires @botusername; "message" responds to all messages |
threadTrigger | top-level | "mention" | "message" | false | Override trigger for forum topic replies |
allow config only filters updates after Telegram delivers them.
Groups Setup
Add the bot to the group
Use the group settings to add the bot as a member, or share the bot link with a group admin.
Observe the group chat ID
Run
heypi telegram observe and post a message in the group. The CLI will print the group’s chat ID (a large negative number, e.g. -1001234567890).Handle privacy mode
By default, Telegram bots in groups only receive messages that are commands (
/command) or direct mentions. If you need the bot to see all messages, either:- Set
trigger: "mention"and always mention the bot. - Disable privacy mode in BotFather with
/setprivacy → Disable— then the bot receives every group message.
Forum topics (supergroups with topics enabled) use
message_thread_id to identify the topic. Heypi maps each topic as a separate conversation thread. Use threadTrigger: "message" to respond to any message within a topic without requiring a mention.Full Example
The following is the completeexamples/telegram-workout entry point — a personal fitness coach bot with long polling, streaming, and a daily check-in heartbeat job:
CLI Commands
heypi telegram check
Validates
TELEGRAM_BOT_TOKEN and prints the bot’s identity (username, ID).heypi telegram observe
Polls for inbound messages and prints chat and user IDs as they arrive. Send
/start or post in a group to capture IDs.Common Failures
Unauthorized
Unauthorized
No updates during observe
No updates during observe
One of the following:
- The bot has a webhook registered somewhere else. Run
telegram observe— it deletes the webhook automatically — but if another live service immediately re-registers it, stop that service first. - The message was sent before
observestarted polling. Send a new message after the CLI is running. - Group privacy mode blocked the message. Disable privacy mode in BotFather (
/setprivacy → Disable) or send a direct command/mention.
Conflict: another bot instance is polling
Conflict: another bot instance is polling
Only one process can long-poll a bot token at a time. Stop any other running instances (including
telegram observe) before starting your agent.Bot not responding in groups
Bot not responding in groups
Confirm
allow.chats includes the group’s chat ID (a large negative number). If trigger is "mention", the message must include @yourbotusername. If privacy mode is on, the bot only receives commands and mentions.