Skip to Content
Setup

Telegram

SwB talks to Telegram through a bot that you make in BotFather. SwB asks Telegram for new messages, so your SwB server can stay on a private address.

Before you start

Use a Telegram account. To connect a group, use an account that can add members. Sign in to SwB as the owner.

Copy the setup prompt

Read the setup guide at https://swb.one/docs/setup/telegram.

Help me connect Telegram to SwB. SwB carries messages between my agents and channels.

If the SwB tools are missing, ask me to add SwB as a custom MCP server. Follow https://swb.one/docs/connect to add the client.

For Claude, give me the path `Customize > Connectors > Add > Custom > Web`. For ChatGPT, ask me to open `https://chatgpt.com/plugins`. Give me the path `+ > Add custom MCP server`. For Grok, give me the path `grok.com > Connectors > New Connector > Custom`. For other apps, ask me to open the MCP server settings. Wait for me to confirm.

Use a SwB client with owner access.

Call `connect(what="telegram")`. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step.

Ask me to open https://t.me/BotFather and send `/newbot`. Ask me to choose the bot's name and username. BotFather replies with the token. Ask me to enter it only through the claim link from `connect`. Then ask me to start a chat with the bot and send one message.

For a group, ask me to open `setup.add_to_group_url` from `telegram_status`. Ask me to select the group. Ask me to send `/swb@<bot username>` there. To let the bot read all group messages, ask me to send `/setprivacy` to BotFather. Ask me to choose the bot and select **Disable**. Ask me to remove the bot from the group. Ask me to add it again.

Use `telegram_status` to get the chat IDs from `setup.seen_chats` and my user ID from the direct message. Add a space under `blocks.telegram.spaces` in `config/switchboard.yaml`. Put the chat IDs in `chats` and my user ID in `owner_ids`. Grant the test agent access in `blocks.telegram.agents`. If the file needs a manual edit, give me the YAML. Restart SwB after an edit.

Call `connect(what="telegram")` again to check the connection. When it reports `connected`, ask me to choose a test chat. Call `telegram_post` with the space label, chat ID and test text. Show me the result.

Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.

If you keep your own memory, set up memory sync as described at https://swb.one/docs/memory.

Paste the prompt into your SwB owner client.

Set up the Telegram bot

Open BotFather

Open https://t.me/BotFather in Telegram. Tap Start if this is your first chat with BotFather.

Create the bot

Send /newbot. Reply with a display name.

Choose the username

Reply with a username that ends in bot. BotFather replies with the token.

Save the token

Open the SwB claim link from your agent. Paste the token into the field.

Start a private chat

Tap Start in the private chat with your bot. Send one message so SwB can find your user ID.

Add the bot to a group

Open the group link from your agent. Select the group.

Send the setup command

Send /swb@<bot username> in the group. SwB then knows the group ID.

Read all group messages

For groups where the bot needs every message, send /setprivacy to BotFather. Choose your bot. Select Disable.

Add the bot again

Remove the bot from each group. Add the bot to the group again.

What the agent does

The agent calls connect(what="telegram"). If needed, it enables the telegram block. When the block is enabled, connect or telegram_provision returns a claim link for the bot token.

After you save the token, the agent calls telegram_status. It checks the bot and privacy mode. The group invite is in setup.add_to_group_url. Recent chat IDs are in setup.seen_chats.

The agent configures a space under blocks.telegram.spaces in config/switchboard.yaml. A space points a set of chats to a SwB project. Set the group IDs in chats. Set your user ID in owner_ids. Restart SwB after editing the file.

Credentials

TokenWhere Telegram shows itFormatWhere it goes
Bot tokenReply from BotFather after /newbot, or after /tokenDigits, a colon, then letters and digitsSwB claim link

Check the connection

Ask the agent to call connect again. It reports connected when the setup is complete.

Use the Telegram account listed in owner_ids. Send /swb <target> hello to the bot in a private chat. Replace <target> with a target name from targets. Check for a reply.

Fix problems

If the bot reads only commands in a group, turn off privacy mode in BotFather. Then remove the bot and add it again.

A webhook is a web address where Telegram sends messages. Ask the bot owner to remove any old webhook with Telegram’s deleteWebhook method.

On this page