Skip to Content
Blocks

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: claude

Send 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

KeyUse
blocks.telegramSettings for the Telegram bot and its spaces
blocks.telegram.useLoads the telegram block
blocks.telegram.enabledSet true to load the block or false to turn it off
blocks.telegram.token_envName of the environment variable for the bot token
blocks.telegram.dm_spaceSpace whose routing and owner settings apply to private chats. The default is the first configured space
blocks.telegram.dm_modeMode for private messages from other people. Use watch to collect a digest or off to skip them
blocks.telegram.ack_reactionEmoji to mark receipt of a message addressed to the bot. Set null to turn off this reaction
blocks.telegram.persona_prefixSet true to put the name used by the agent on the first line in bold
blocks.telegram.refresh_minutesMinutes between updates to the target list. The default is 30
blocks.telegram.target_aliasesMaps extra target names to existing targets
blocks.telegram.agentsSpaces 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

KeyUse
blocks.telegram.spacesMaps names used in SwB to settings for sets of Telegram groups
blocks.telegram.spaces.*.chatsGroup chat IDs in this space. Use negative integers. Put each group in one space
blocks.telegram.spaces.*.owner_idsTelegram user IDs treated as owners
blocks.telegram.spaces.*.knownMaps known Telegram user IDs to display names
blocks.telegram.spaces.*.default_targetTarget for a new message addressed to SwB with the target name omitted
blocks.telegram.spaces.*.projectDefault SwB project for this space
blocks.telegram.spaces.*.channel_projectsSets the SwB project by group chat ID
blocks.telegram.spaces.*.modeMode for the space. A group mode can override it
blocks.telegram.spaces.*.channelsSets a mode or more detailed settings by group chat ID
blocks.telegram.spaces.*.channels.*.modeMode for one group
blocks.telegram.spaces.*.channels.*.projectSwB project for one group. It takes priority over the project for the space
blocks.telegram.spaces.*.listenOlder setting for group chat IDs that use assist mode
blocks.telegram.spaces.*.bot_posts_per_hourMaximum bot posts per conversation thread in one hour. The default is 20

On this page