Skip to main content

Telegram

Telegram is the simplest provider to set up. SimplePost posts through a bot token and a target chat ID. There is no OAuth flow.

Content support

CapabilitySupport
TextUp to 4096 characters for plain messages, 1024 characters for media captions.
FormattingHTML, Markdown, or MarkdownV2 parse mode.
MediaImages and videos.
Media limitOne media file per message.
Empty postsAllowed when media is present.
ThreadsPass replyTo (a Telegram message ID as string) to make the post a reply.

Set up credentials

1. Create a bot

  1. Open Telegram and start a chat with BotFather.
  2. Send /newbot.
  3. Follow the prompts.
  4. Copy the bot token.

2. Get the chat ID

For a public channel or group, you can often use the handle:

@your_channel

For private chats or groups:

  1. Add the bot to the chat.
  2. Send a message in the chat.
  3. Call getUpdates with the bot token:
curl "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates"
  1. Find chat.id in the response.

Environment variables

TELEGRAM_BOT_TOKEN=

The chat ID is not read from any env var. Pass it through options.telegram.chatId on every SDK call, or store it on the local CLI account / accounts.json entry as platformAccountId.

SDK options

await post({
content: { text: "Hello <b>Telegram</b>" },
platforms: ["telegram"],
options: {
telegram: {
chatId: "@mychannel",
parseMode: "HTML",
},
},
});

parseMode can be HTML, Markdown, or MarkdownV2. Note that Telegram requires aggressive escaping in MarkdownV2 (every _*[]()~\>#+-=|{}.!must be escaped); pickHTML` if you do not need that level of control.

Reply to an existing message:

await post({
content: { text: "Replying" },
platforms: ["telegram"],
options: {
telegram: { chatId: "@mychannel", replyTo: "12345" },
},
});

REST server account

Add this entry under accounts in the self-hosted REST server's accounts.json:

{
"id": "telegram-news",
"platform": "telegram",
"platformAccountId": "@your_channel",
"credentials": { "botToken": "123456:ABC..." },
"options": { "parseMode": "HTML" }
}