> For the complete documentation index, see [llms.txt](https://aibotkit.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aibotkit.gitbook.io/documentation/channels-and-integrations/telegram.md).

# Telegram

Run your chatbot inside Telegram. Customers message your bot, the AI replies using your knowledge base, and conversations show up in your dashboard for review or human takeover.

## What you need

* A Telegram **bot token** from [@BotFather](https://t.me/BotFather)
* A paid plan (Basic, Essential, or Business)

## Get a bot token in 60 seconds

1. Open Telegram and start a chat with **@BotFather**.
2. Send `/newbot` and follow the prompts to choose a display name and a username (must end in `bot`, e.g., `acme_support_bot`).
3. BotFather returns a bot token that looks like `123456789:AAH...`. **Copy it.**

## Connect to AI Bot Kit

1. Open your chatbot → **INTEGRATIONS** → **Telegram**.
2. Paste the bot token and click **Connect**.
3. AI Bot Kit automatically registers a webhook at `/api/telegram/callback/<token>` so Telegram knows where to deliver messages.
4. Send a test message to your bot in Telegram. The reply should arrive within a few seconds.

When connected, you'll see:

* **Feature bullets:**
  * **Token encrypted at rest** -- Your token is never exposed in plain text
  * **Instant setup** -- Your bot goes live immediately
  * **950M+ Telegram users** -- Reach customers on one of the world's largest messaging platforms

The token is hashed and encrypted before being stored — it's never shown back to you in plain text.

## What happens behind the scenes

* **Inbound:** Telegram POSTs to `/api/telegram/callback/<token>`. The token in the URL identifies the chatbot. The endpoint returns 200 immediately and processes the message asynchronously.
* **Session ID format:** `tg_<chat_id>` — one continuous thread per Telegram chat.
* **Outbound:** Replies are sent via Telegram's Bot API, including basic Markdown formatting where supported.

## Sharing your bot

Tell customers to message your bot directly via `https://t.me/<your_bot_username>`. You can embed this link on your website, email signature, or business card.

## Tips

* **Test in private first.** Use Telegram's "Test Bot" feature in BotFather settings to validate before publishing.
* **Disconnect cleanly.** Removing the integration also unregisters the webhook from Telegram.
* **One bot per chatbot.** If you connect the same token to a second chatbot, AI Bot Kit detects the conflict and asks you to confirm a transfer.

## Limits

* Counts toward your **Monthly AI Messages** quota.
* No per-channel rate limit on top of Telegram's own (currently 30 messages/sec to different users).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://aibotkit.gitbook.io/documentation/channels-and-integrations/telegram.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
