Telegram¶
Connect your agents to Telegram using the Bot API.
Setup¶
1. Create a bot¶
- Open Telegram and message @BotFather
- Send
/newbotand follow the prompts - Copy the token:
1234567890:AAH...
2. Configure Soulacy¶
channels:
telegram:
enabled: true
token: "1234567890:AAH..."
agent_id: assistant
allowed_user_ids: [] # optional allowlist of Telegram user IDs
Telegram currently uses long polling by default, so it works on a laptop or private server without a public HTTPS URL.
3. Allow specific Telegram users¶
Set allowed_user_ids to restrict who can talk to the bot:
channels:
telegram:
enabled: true
token: "..."
agent_id: assistant
allowed_user_ids: [123456789, 987654321]
Multiple Telegram bots¶
Use bots: when you want one Telegram bot per agent:
channels:
telegram:
enabled: true
bots:
- token: "BOT_TOKEN_1"
agent_id: assistant
allowed_user_ids: [123456789]
- token: "BOT_TOKEN_2"
agent_id: financial-agent
allowed_user_ids: [123456789]
This registers two adapter IDs:
| Adapter ID | Agent |
|---|---|
telegram |
assistant |
telegram-financial-agent |
financial-agent |
You can configure this from the GUI: Channels → Telegram → Edit → Bot mappings.
Default Outbound vs Interactive Bots¶
Telegram can be used in two ways:
| Mode | Use it for | Configure |
|---|---|---|
| Default outbound sender | Cron reports, one-off channel.send, non-interactive delivery |
Top-level token, default_output_to, and usually outbound_only: true |
| Interactive agent bot | A Telegram bot that receives messages and invokes one agent | A bot mapping with agent_id, token, and allowlists |
If the channel card says OUTBOUND-ONLY, that is expected for the default
sender. It means the bot can send reports, but it will not poll inbound Telegram
messages. Add a bot mapping when you want a user to chat with an agent.
For interactive bot mappings, restart the gateway after saving, then send
/start to that exact bot. If the bot is used in a group, set
ignore_groups: false, add an allowlist if needed, and mention the bot or use
the configured trigger phrase.
Send Scheduled Output To Telegram¶
For cron agents that only need to post results, configure Telegram as
outbound_only. In this mode Soulacy registers the bot for sends, but does not
poll Telegram for inbound messages and does not expose the agent to Telegram
users.
Then point the cron agent's schedule.output at that adapter and set to to
the Telegram chat, user, group, or channel id:
id: daily-brief
name: Daily Brief
trigger: cron
schedule:
cron: "0 7 * * *"
output:
channel: telegram
to: "123456789"
bot_name: "Daily Brief Bot"
template: "{reply}"
For a Telegram channel, add the bot as an administrator and use the channel id
or public handle, for example @your_channel_name, as schedule.output.to.
Troubleshooting Telegram Delivery¶
Open Channels -> Telegram and read Delivery checks:
Default outbound bot token is missingmeans the top-level scheduled-output sender has no token saved.Adapter is not registeredusually means settings were saved but the gateway has not been restarted yet.Adapter is not connectedmeans the token, network, or Telegram Bot API connection failed.No default output destination is configuredis fine for agents that setschedule.output.to, but cron agents without their own destination need a channel-leveldefault_output_to.- A dedicated bot mapping must either select an
agent_idfor interactive use or be markedoutbound_onlyfor send-only use. chat not foundusually meansdefault_output_to/schedule.output.tois wrong, the bot is not in the target chat/channel, or a private chat has not sent/startto that bot yet.- If a mapped bot is listed as connected but never receives prompts, confirm the
agent has
trigger: channeland includes the mapping adapter ID ortelegramin itschannels:list.
You can also call GET /api/v1/doctor; its channels section returns the
same diagnostics for automated production checks.
Features¶
| Feature | Support |
|---|---|
| Text messages | ✅ |
| Photos / images | ✅ (passed to vision-capable agents) |
| Documents | ✅ (text extracted and passed as context) |
| Voice messages | 🔜 Planned |
| Inline keyboards | ✅ (agent can emit buttons) |
| Groups & channels | ✅ (mention the bot to trigger) |
| Commands | ✅ |
Example: minimal Telegram bot¶
server:
api_key: "sy_..."
llm:
default_provider: openai
providers:
openai:
api_key: "sk-..."
storage:
type: sqlite
path: ./soulacy.db
channels:
telegram:
enabled: true
token: "1234567890:AAH..."
agent_id: assistant
agent_dirs:
- ./agents
id: assistant
name: Assistant
trigger: channel
llm:
provider: openai
model: gpt-4o-mini
system_prompt: You are a helpful assistant on Telegram.
channels:
- telegram
Start with soulacy serve --config config.yaml and message your bot on Telegram.