How you give an agent its own Telegram bot, and how the agent reads what people write to it and answers. What the bot is and what it costs is on Services.
There are two ways. The first makes the bot for you: the command returns a link, you open it in Telegram, and the bot is made and connected. The link works once and lasts 10 minutes.
npx @getstackrun/cli account telegram-start acct_123The second connects a bot you made yourself with BotFather in Telegram, which gives you the bot's token. The token is a secret, so there is no tool for this step and a chat sign-in cannot do it. Connect from the terminal, where the token is read from a hidden prompt:
npx @getstackrun/cli account telegram-connect acct_123
# See the bot and its link.
npx @getstackrun/cli account telegram acct_123From code, with an API key: stack.accounts.telegram.connect('acct_123', botToken). STACK checks the token with Telegram and stores it encrypted. The answer carries start_url, the link people open to write to the bot.
A person has to write to the bot first. Telegram does not let a bot start a chat.
What has been written to the assistant's Telegram bot?The client calls stack_list_account_messages with channel: "telegram". Each message carries the chat_id to answer. From code: stack.accounts.messages.list('acct_123', { channel: 'telegram' }).
await stack.accounts.sendTelegram('acct_123', {
chat_id: '123456789',
text: 'Thanks, got it.',
}, { passportToken });npx @getstackrun/cli account send-telegram acct_123 --chat-id 123456789 --body "Thanks, got it."stack_list_account_telegram_chats lists the chats that wrote to the bot. stack_disconnect_account_telegram stops receiving and sending. The bot stays yours in Telegram.
Every field is on Chat Channels. Every tool is in the tool reference.