本文へスキップ
セットアップ

Telegram

このページは、エージェントが英語版から翻訳し、確認しました。Zhehan が読めるのは英語と中国語です。校正へのご協力をお待ちしています。 校正に協力する 翻訳の問題を報告する

SwB は、BotFather で作成したボットを通じて Telegram とやり取りします。SwB が新しいメッセージを Telegram に問い合わせるので、SwB サーバーは非公開のアドレスでも使えます。

始める前に

Telegram のアカウントを使ってください。グループを接続するときは、メンバーを追加できるアカウントを使ってください。オーナーとして SwB にサインインしてください。

セットアップ用プロンプトをコピーする

Claude で開くChatGPT で開く
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.

このプロンプトを、SwB のオーナー用クライアントに貼り付けてください。

Telegram のボットを設定する

BotFather を開く

Telegram で https://t.me/BotFather を開いてください。BotFather と初めてチャットする場合は、Start をタップしてください。

ボットを作成する

/newbot を送ってください。表示名を返信してください。

ユーザー名を選ぶ

bot で終わるユーザー名を返信してください。BotFather がトークンを返信します。

トークンを保存する

エージェントから届いた SwB の受け取りリンクを開いてください。欄にトークンを貼り付けてください。

個人チャットを始める

ボットとの個人チャットで Start をタップしてください。SwB がユーザー ID を確認できるように、メッセージを 1 つ送ってください。

ボットをグループに追加する

エージェントから届いたグループ用のリンクを開いてください。グループを選んでください。

セットアップ用のコマンドを送る

グループで /swb@<bot username> を送ってください。これで、SwB がグループの ID を把握します。

グループのすべてのメッセージを読む

ボットにすべてのメッセージを読ませたいグループがある場合は、BotFather に /setprivacy を送ってください。作成したボットを選んでください。Disable を選択してください。

ボットをもう一度追加する

各グループからボットを削除してください。そのグループに、もう一度ボットを追加してください。

エージェントの動作

エージェントは connect(what="telegram") を呼び出します。必要に応じて telegram ブロックを有効にします。ブロックが有効になると、connect か telegram_provision がボットトークン用の受け取りリンクを返します。

トークンを保存すると、エージェントは telegram_status を呼び出します。ボットとプライバシーモードを確認します。グループへの招待は setup.add_to_group_url にあります。最近のチャット ID は setup.seen_chats にあります。

エージェントは、config/switchboard.yaml の blocks.telegram.spaces でスペースを設定します。スペースは、チャットのまとまりを SwB のプロジェクトに結び付けます。グループの ID を chats に設定してください。自分のユーザー ID を owner_ids に設定してください。ファイルを編集したら、SwB を再起動してください。

認証情報

トークンTelegram で表示される場所形式入力する場所
ボットトークン/newbot か /token のあとの BotFather からの返信数字、コロン記号、英数字の順に並んだ文字列SwB の受け取りリンク

接続を確認する

もう一度 connect を呼び出すよう、エージェントに頼んでください。セットアップが完了すると、connected と報告します。

owner_ids にある Telegram アカウントを使ってください。個人チャットで、ボットに /swb <target> hello を送ってください。<target> を、targets にある送信先の名前に置き換えてください。返信が届くことを確認してください。

問題を解決する

グループでボットがコマンドだけを読む場合は、BotFather でプライバシーモードをオフにしてください。そのあと、ボットを削除して、もう一度追加してください。

Webhook とは、Telegram がメッセージを送る Web アドレスです。古い Webhook が残っている場合は、Telegram の deleteWebhook メソッドで削除するよう、ボットのオーナーに頼んでください。

このページの内容