Read Telegram chats the bot can see and send confirmed messages through the Bot API using telegramBotToken.
- Other
- telegram
- bot
- messaging
- bot-token
- chat
- License
- MIT
- Published
- August 22, 2026
- Pinned commit
6ef34f3- Rating
- No ratings yet
- Forks
- 0
- Stars
- 0
- Adaptation effort
- —
README
@kody/telegram
Official Telegram paper-plane mark from telegram.org/img/t_logo.svg.
Intent
Provide reusable, account-agnostic Telegram Bot API helpers so Kody can read updates and chats a bot can see, and send explicitly confirmed messages, using a saved telegramBotToken — never Telegram Login Widget OAuth.
Auth: bot token, not OAuth, not an API key
This package calls https://api.telegram.org/bot<token>/METHOD. That token is created by @BotFather. It is not an OAuth access token and not a user account password.
Do not connect https://kody.codes/connect/oauth?provider=telegram for this package. That URL is Telegram Login Widget identity (openid / profile on oauth.telegram.org) and cannot send or read Bot API messages.
Telegram Bot API has no OAuth scopes. What the bot can do is:
- chat membership (private chats require the user to send
/start) - admin rights in groups and channels
- BotFather privacy mode (
/setprivacy) for reading non-command group messages
If Telegram returns 401/403, the error names the missing access and the next setup step.
Required setup
- Open Telegram and message @BotFather.
- Send
/newbot(or/tokenfor an existing bot) and copy the token. Never paste the token into chat. - Save it in Kody and approve host
api.telegram.org:
- Send
/startto the bot in a private chat. Add the bot to groups you want it in. For channels, add it as an administrator. - To read all group messages (not just commands and replies), either:
- @BotFather →
/setprivacy→ Disable, or - make the bot a group administrator.
- @BotFather →
- Run the smoke test below.
Required host: api.telegram.org.
Additional bots
Default secret name is telegramBotToken. Pass secretName: "telegramBotToken-<slug>" (lowercase letters and digits) for another bot, and save that secret with the same host:
Smoke test
./smoke-test is safe before anyone saves a token: it returns
{ ok: true, live: false } and the setup URL. After telegramBotToken and
host approval, invoke the package (not a static import) so the secret
placeholder resolves and getMe runs:
import { packages } from 'kody:runtime'
export default async function main() {
return await packages.invoke({
kodyId: 'telegram',
exportName: './smoke-test',
})
}A live result is getMe with isBot: true. It does not send messages.
dryRun
Mutations never call Telegram when dryRun: true. Live sends require confirm: true after the user explicitly approves the chat and text.
import sendMessage from 'kody:@kody/telegram/send-message'
export default async function main() {
return sendMessage({
chatId: 123456789,
text: 'Hello from Kody',
dryRun: true,
})
}Exports
kody:@kody/telegram— package overview and safety metadatakody:@kody/telegram/guide— BotFather steps and the prefilled secret URLkody:@kody/telegram/smoke-test—getMeidentity checkkody:@kody/telegram/get-me— authenticated bot profilekody:@kody/telegram/get-updates— poll delivered updates (not arbitrary history)kody:@kody/telegram/get-chat— one chat the bot can seekody:@kody/telegram/get-webhook-info— whether a webhook is blockinggetUpdateskody:@kody/telegram/send-message— preview or send; sending requiresconfirm: truekody:@kody/telegram/request— any Bot API method; mutating calls needdryRun/confirm
Bots cannot fetch arbitrary chat history. They only see messages Telegram delivers through getUpdates or a webhook. If getUpdates returns 409, a webhook is set: read get-webhook-info, then request({ method: 'deleteWebhook', dryRun: true }).
Errors
| Telegram response | What to do |
|---|---|
| 404 Not Found | telegramBotToken is missing or empty. Save it at the secret URL above and approve api.telegram.org. |
| 401 Unauthorized | Save/replace telegramBotToken at the secret URL above and approve api.telegram.org. |
| 403 kicked / not a member | Add the bot to that chat (admin for channels). |
| 403 not enough rights | Grant the named chat permission. There are no OAuth scopes to reconnect. |
| 400 chat not found | User must /start the bot, or add it to the group/channel. |
| 409 Conflict | Webhook is set or another poller is running — see get-webhook-info. |
Report this listing
Log in to report this listing.