Skip to main content
Trinity
Guides/Telegram Integration

Telegram Integration

Connect agents to Telegram bots. Supports direct messages, group chats, @mentions, and reply threading.

Concepts

1:1 Mapping — Each agent has its own dedicated Telegram bot. Bots cannot be shared across agents.
Webhook — Trinity receives Telegram updates via a webhook URL. Requires public_chat_url to be configured in Settings.
Trigger Mode — In groups, controls whether the bot responds to all messages or only @mentions and direct replies.
Privacy Mode — A Telegram-level setting that determines which messages the bot receives in groups. Must be disabled for "all messages" mode to work.

Bot Setup (BotFather)

Before connecting to Trinity, create and configure your bot via @BotFather on Telegram.

Step 1: Create the Bot

1

Open Telegram and message @BotFather

2

Send /newbot

3

Enter a display name (e.g., "My Agent Bot")

4

Enter a username ending in bot (e.g., my_agent_bot)

5

Copy the bot token (format: 123456789:ABC-DEF...)

Step 2: Configure Privacy Mode (Required for Groups)

By default, Telegram bots have Privacy Mode enabled. This means in groups, the bot only receives @mentions, replies to its own messages, and bot commands.

To enable "all messages" mode in groups, you must disable Privacy Mode:

1

Message @BotFather

2

Send /setprivacy

3

Select your bot from the list

4

Choose Disable

Critical: If the bot is already in a group, you must remove and re-add the bot for the change to take effect.

Connect Bot to Agent

1

Open the agent detail page

2

Select the Sharing tab

3

In the Telegram section, paste your bot token

4

Click Connect Bot

5

Trinity validates the token and registers the webhook

After connecting, the bot link (t.me/YourBot) appears in the UI. Users can start chatting immediately via direct messages.

Voice Messages

Voice notes sent to the bot are automatically transcribed with Google Gemini 2.0 Flash and delivered to the agent as text prefixed with the 🎤 emoji. Transcription is transparent — users just send voice notes normally.

ConstraintLimit
Duration5 minutes
File size10 MB
Config requiredGEMINI_API_KEY set on the backend

If transcription fails or GEMINI_API_KEY is not configured, the agent receives a placeholder such as [Voice message received — transcription failed] so the conversation still progresses.

Bot Commands

Users in Telegram can use these commands:

CommandAction
/startWelcome message
/helpShows capabilities
/resetClears conversation history
/login <email>Verify email for access-controlled agents
/logoutClear verified email
/whoamiShow current verified email

Group Chat Configuration

When a bot joins a Telegram group, Trinity automatically creates a group config.

Trigger Modes

ModeBot Responds ToPrivacy Mode
Mention only (default)@mentions and replies to botEither
All messagesEvery message in the groupMust be Disabled

If "all messages" mode doesn't work: Verify Privacy Mode is disabled in BotFather, then remove and re-add the bot to the group.

Group Authentication

By default, anyone in a group can chat with the bot. To require at least one verified member before the bot responds, go to Agent Detail → Sharing tab → Channel Access Policy and set Group auth mode to "Any verified member". Once any group member completes /login, the group is unlocked for everyone.

Welcome Messages

Enable welcome messages to greet users who join the group. Toggle Welcome message on, enter the welcome text (up to 4096 characters), and use {name} to include the user's first name. The bot needs admin rights in the group.

API

EndpointMethodDescription
/api/agents/{name}/telegramGETBot binding status
/api/agents/{name}/telegramPUTConfigure bot token
/api/agents/{name}/telegramDELETERemove bot binding
/api/agents/{name}/telegram/testPOSTVerify bot or send test message
/api/agents/{name}/telegram/groupsGETList group configs
/api/agents/{name}/telegram/groups/{id}PUTUpdate trigger mode / welcome
/api/agents/{name}/telegram/groups/{id}DELETEDeactivate group config

Troubleshooting

Bot not responding in groups

1Check Privacy Mode: Message @BotFather, send /setprivacy, verify it shows "Disabled"
2Re-add the bot: Remove the bot from the group, then add it again
3Check trigger mode: In Trinity, verify the group is set to the expected trigger mode
4Check agent status: Ensure the agent container is running

"Connected (no webhook)" warning

Configure public_chat_urlin Settings with your Trinity instance's publicly accessible URL. The webhook registers automatically.

Messages delayed or not arriving

Check backend logs for webhook errors, verify your public_chat_url is accessible from the internet, and look for 429 (rate limit) errors.

Limitations

One bot per agent — Each agent can only have one Telegram bot. Each bot can only be bound to one agent.
Privacy mode is manual — Disabling Privacy Mode must be done through BotFather; it cannot be automated via the Bot API.
Group re-add required — After changing Privacy Mode, the bot must be removed and re-added to existing groups.
Welcome messages require admin — The bot needs admin rights in the group to see member join events.
20MB file limit — Media files larger than 20MB cannot be processed.
Voice transcription limits — Voice notes over 5 minutes or 10MB are rejected; transcription requires GEMINI_API_KEY on the backend.
No edited message handling — Edited messages are not re-processed.