Telegram
SwB asks Telegram for new messages. Your SwB server can use a private address.
Make the bot
In @BotFather, send /newbot. Ask an agent to connect Telegram. The agent calls telegram_provision and gives you a claim link. Open the link and paste the bot token.
Add the bot to a group
Add the bot to the group. Send /swb@<bot username> in the group. telegram_status then shows the group's chat id in setup.seen_chats. Put that id in the space's chats.
Start a private chat with the bot. Send it a message. Find your private chat ID in setup.seen_chats. Use that ID in owner_ids.
blocks:
telegram:
use: telegram
agents: {claude: [home]}
spaces:
home:
chats: [-100111222]
owner_ids: [222222]
default_target: claudeSend from Telegram
Send a private message to the bot, mention the bot, or use /swb <target> <message>. To continue a conversation, reply to the bot's answer. With persona_prefix enabled, agent replies can show the agent's name in bold.
To let the bot read every group message, turn privacy mode off with /setprivacy in @BotFather. Then remove the bot from the group and add it again.
Block settings
Open Telegram in Settings to change the bot name and picture. Telegram uses this identity in every chat.
| Key | Use |
|---|---|
blocks.telegram | Settings for the Telegram bot and its spaces |
blocks.telegram.use | Loads the telegram block |
blocks.telegram.enabled | Set true to load the block or false to turn it off |
blocks.telegram.token_env | Name of the environment variable for the bot token |
blocks.telegram.dm_space | Space whose routing and owner settings apply to private chats. The default is the first configured space |
blocks.telegram.dm_mode | Mode for private messages from other people. Use watch to collect a digest or off to skip them |
blocks.telegram.ack_reaction | Emoji to mark receipt of a message addressed to the bot. Set null to turn off this reaction |
blocks.telegram.persona_prefix | Set true to put the name used by the agent on the first line in bold |
blocks.telegram.refresh_minutes | Minutes between updates to the target list. The default is 30 |
blocks.telegram.target_aliases | Maps extra target names to existing targets |
blocks.telegram.agents | Spaces where each agent can post and receive events. Use * for all spaces |
Use channel modes to wake an agent through a project route.
Spaces and groups
| Key | Use |
|---|---|
blocks.telegram.spaces | Maps names used in SwB to settings for sets of Telegram groups |
blocks.telegram.spaces.*.chats | Group chat IDs in this space. Use negative integers. Put each group in one space |
blocks.telegram.spaces.*.owner_ids | Telegram user IDs treated as owners |
blocks.telegram.spaces.*.known | Maps known Telegram user IDs to display names |
blocks.telegram.spaces.*.default_target | Target for a new message addressed to SwB with the target name omitted |
blocks.telegram.spaces.*.project | Default SwB project for this space |
blocks.telegram.spaces.*.channel_projects | Sets the SwB project by group chat ID |
blocks.telegram.spaces.*.mode | Mode for the space. A group mode can override it |
blocks.telegram.spaces.*.channels | Sets a mode or more detailed settings by group chat ID |
blocks.telegram.spaces.*.channels.*.mode | Mode for one group |
blocks.telegram.spaces.*.channels.*.project | SwB project for one group. It takes priority over the project for the space |
blocks.telegram.spaces.*.listen | Older setting for group chat IDs that use assist mode |
blocks.telegram.spaces.*.bot_posts_per_hour | Maximum bot posts per conversation thread in one hour. The default is 20 |