Telegram

Base URL: https://chatsa.co/api/v1

A partner account can connect Telegram three ways, so every message reaches you as a signed webhook and you reply from your own product:

  • The company's own bot, made inside Telegram (recommended). Your customer taps Start and Create the bot in Telegram; ChatSa gets the bot's token from Telegram itself. Nobody copies a token.
  • The company's own bot, by its token. Your customer makes a bot in Telegram's @BotFather and pastes its token into your product; you send it to ChatSa. Their customers write to the bot.
  • The person's own Telegram account. With a Telegram Business account (part of Telegram Premium), the owner adds ChatSa's bot to their account, and messages their customers send them reach you.

These conversations are team only: ChatSa's AI never answers them. They work exactly like Messenger and Instagram, with channel: "telegram".

Availability. GET /partner/capabilities says telegram (own bots), telegram_managed (bots made inside Telegram) and telegram_business (Telegram Business accounts). Show each option only when it is on.

This uses the partner API: authenticate with the account's key (Authorization: Bearer <account key>). Paths are under https://chatsa.co/api/v1/.

Make the bot inside Telegram#

POST /api/v1/partner/telegram/managed-links
Authorization: Bearer <account key>

{ "name": "Acme Roofing" }
{
  "data": {
    "id": "3f1c2a8e-5b7d-4c1e-9a2f-6d8e0b4c7a91",
    "status": "waiting",
    "url": "https://t.me/ChatSaConnectBot?start=mb_Q2x8…",
    "bot_username": "ChatSaConnectBot",
    "expires_at": "2026-12-04T10:15:00Z",
    "owner": null,
    "bot": null,
    "account": null,
    "error": null
  }
}

Open the url for your customer (it works once, for 15 minutes). In Telegram they press Start, tap Create the bot, check the name and username Telegram suggests, and confirm. If they made a bot this way before and it is no longer connected, ChatSa's bot also offers it under the button, so they can connect it again instead. name is suggested as the bot's name (the account's name if you leave it out).

Read the setup every few seconds while they are in Telegram:

GET /api/v1/partner/telegram/managed-links/{id}
statusMeaning
waitingThe link hasn't been opened yet
startedThey pressed Start (owner says who); the bot isn't made yet
bot_readyThe bot is made (bot): show it and offer Connect
connectingConnect is running
connectedDone: account is the connected bot
expired, canceled, failedThe end: start a new setup

When your customer presses Connect:

POST /api/v1/partner/telegram/managed-links/{id}/complete
Authorization: Bearer <account key>
Idempotency-Key: <any key for this setup>

200 with status: "connected" and account (as in the list below). Calling it again answers the same. DELETE /api/v1/partner/telegram/managed-links/{id} cancels a setup that hasn't connected.

StatuscodeWhen
404not_foundNo such setup for this account
409not_readyNo bot made yet
409connect_in_progressAnother Connect is running; try again in a minute
409owner_changed, bot_unavailable, bot_in_useThis setup failed: start a new one
410expiredThe setup expired or was canceled
502telegram_unavailableTelegram couldn't be reached; Connect again
503not_configuredMaking bots inside Telegram is off on this ChatSa

No answer ever carries the bot's token, and only the person who pressed Start can make the bot for this setup.

Connect a bot by its token#

Ask your customer to open @BotFather in Telegram, send /newbot, pick a name and a username, and copy the token it gives them. Then:

POST /api/v1/partner/telegram/bots
Authorization: Bearer <account key>

{ "token": "7012345678:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw0" }
{
  "data": {
    "channel": "telegram",
    "account_id": "bot-7012345678",
    "kind": "bot",
    "name": "Acme Roofing",
    "username": "acme_roofing_bot",
    "page_id": null,
    "status": "connected",
    "connected_at": "2026-12-02T10:00:00Z"
  }
}

201 for a new bot, 200 when the same bot is connected again (its token is refreshed). ChatSa sets the bot's webhook, and a bot has only one: another tool that used the same bot stops receiving its messages. Treat the token as a password: send it once, don't keep it.

StatuscodeWhen
400invalid_tokenNot a BotFather token, Telegram refused it, or it isn't a bot's
409bot_in_useThe bot is already connected elsewhere in ChatSa
409connect_in_progressAnother request is connecting this bot; try again in a minute
502telegram_unavailableTelegram couldn't be reached; try again
503not_configuredTelegram is off on this ChatSa

Connect a Telegram Business account#

POST /api/v1/partner/telegram/business-links
Authorization: Bearer <account key>
{
  "data": {
    "url": "https://t.me/ChatSaBizBot?start=link_Vx3…",
    "bot_username": "ChatSaBizBot",
    "expires_at": "2026-12-02T10:15:00Z"
  }
}

Show the link (it lasts 15 minutes and works once). The person opens it in Telegram and presses Start, then goes to Settings → Telegram Business → Chatbots, adds the bot and lets it reply. Their account then appears in the list below with kind: "business" and account_id: "bc-…"; check the list every few seconds while your window is open.

The account's Telegram bots and accounts#

They are listed with the Pages and Instagram accounts, in GET /api/v1/partner/social/accounts, and stopped with DELETE /api/v1/partner/social/accounts/telegram/{account_id} (a bot's webhook is removed; for a Business account, also tell the person to remove the bot in Telegram). status: "reconnect": the bot's token was revoked (connect it again with a new token), or the Business account's replies were turned off.

Messages#

The same social.message.received and social.message.sent webhooks, with channel: "telegram":

  • account.id is bot-… or bc-…; from.id is the person's Telegram user id, from.name their name and from.username their Telegram username (or null).
  • type: text, image, video, audio, file or postback. Files come as 24-hour links, up to 20 MB.
  • A bot has no reply window: reply_window_until is null, and you can reply any time to someone who wrote to the bot. A bot can't start a conversation with someone who never wrote to it. A Business account has Telegram's 24 hours.
  • social.message.sent with source: "app" is what the owner of a Business account typed in their own Telegram.

Send a message#

POST /api/v1/social/messages with "channel": "telegram", the account_id, the person's id in to, and text (up to 4,096 characters, sent as plain text) or one attachment by public https link (image, video, audio or file; photos up to 5 MB, videos and audio up to 20 MB). A file (PDF, Word, Excel, PowerPoint or text, up to 50 MB) is uploaded by ChatSa, named by the optional attachment.filename. With an attachment, text is its caption (up to 1,024 characters). Refusals as for Messenger: recipient_unavailable when the person never started the bot or blocked it, window_closed (Business accounts only), reconnect_required.

Read a thread and delete a person's data#

GET /api/v1/social/threads/telegram/{to}?account_id=bot-7012345678. For a deletion request, send { "social": [{ "channel": "telegram", "id": "<Telegram user id>" }] }.