# Telegram

{% hint style="info" %}
Requires a Telegram account.
{% endhint %}

Publishing an AI agent to Telegram allows your audience to interact with the agent—and [subsequently with live agents](https://documentation.proto.cx/docs/modules/ai-agents/workflows-and-actions/human-handoff)—in a Telegram thread.

In the agent's **Publish** tab, [create a Telegram channel](https://documentation.proto.cx/docs/modules/ai-agents/publishing/..#add-a-channel) or select an existing one from the table to open its settings.

***

## Basic Settings

In the **Basics** accordion, the following options are available:

* **Name** — the internal name of the channel, used to distinguish from any other Telegram channels the agent is published to.
* **Default chat language** — the language used by the AI agent at the start of a new chat. Available languages are set in the agent's [General](https://documentation.proto.cx/docs/modules/manage-ai-agents#general) settings.
* **Icon** — the channel's avatar seen by live agents in the [Inbox](https://documentation.proto.cx/docs/modules/inbox) dashboard.

Press **Save** to confirm edits.

***

## Connecting to Telegram

#### Configuration

* **Authentication token** - required to authorize the Telegram channel

### Telegram Create a New Bot

1. Login to your Telegram account and start chatting with [**BotFather**](https://t.me/botfather). BotFather is the one bot to rule them all on Telegram. It will help you create new bots and change settings for existing ones.

<figure><img src="https://849782063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXEtIIGTPyKf3CFAsNTzZ%2Fuploads%2FMWSrcaXDo1lfPjK7CUGe%2Fimage.png?alt=media&#x26;token=8dc80cc4-cc78-47e6-a32a-a1831c7ef0a1" alt=""><figcaption></figcaption></figure>

2. Use the **`/newbot`** command to create a new bot. The BotFather will ask you for a **name** and **username**, then generate an **authentication token** for your new bot.

* The **name** of your bot that will be shown to your customer/end user.
* The **Username** is a short name, to be used in mentions and t.me links. Usernames are **5-32 characters** long and are **case insensitive**, but may only include **Latin characters, numbers, and underscores**. Your bot's username **must end in 'bot'**, e.g. 'tetris\_bot' or 'TetrisBot'.
* The **token** is a string  is required to authorize the bot and send requests to the Telegram Bot API.

<figure><img src="https://849782063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXEtIIGTPyKf3CFAsNTzZ%2Fuploads%2F5G4lPExg1oDZqTn3RBf9%2Fimage.png?alt=media&#x26;token=af1d9ecd-f166-45df-af54-8eec2d63d4be" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %} <mark style="color:red;">**Important**</mark>

Keep your token secure and store it safely, it can be used by anyone to control your bot.
{% endhint %}

{% hint style="info" %}
If your existing token is compromised or you lost it for some reason, use the **`/token`** command to generate a new one.
{% endhint %}

3. Copy and paste the **token** to your Telegram channel **Authentication token** on Proto's platform.
4. Click on the **Verify** button. If verification successful, a `t.me/<bot_username>` link will be generated and you can share this link to your customer.
5. Click on the **Save** button to save the Authentication token.

<div align="left" data-full-width="true" data-with-frame="true"><figure><img src="https://849782063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXEtIIGTPyKf3CFAsNTzZ%2Fuploads%2FWS0mdIQuE5bmqpKCSfGS%2Fimage.png?alt=media&#x26;token=8a3a6e01-03ee-474d-9f28-86fdf866b20a" alt=""><figcaption></figcaption></figure></div>

6. Use **`/setjoingroups`** command to disable the bot to be added into group chats. Select the bot you created and type "**Disable**"
7. After disable the join group setting of your bot on Telegram, you enabled the Telegram channel and click **SAVE**.

{% hint style="warning" %} <mark style="color:orange;">**Reminder**</mark>

You will not be able to enable your Telegram channel on Proto's platform if you didn't **DISABLED** the **Allow Group** setting .
{% endhint %}

<div align="left" data-with-frame="true"><figure><img src="https://849782063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXEtIIGTPyKf3CFAsNTzZ%2Fuploads%2FLAvDSQ8tK1HPT00igsJ9%2Fimage.png?alt=media&#x26;token=af3a392b-880e-432b-a0c3-051cfdbd7f68" alt=""><figcaption></figcaption></figure></div>

You can use **`/mybots`** command to return a list of your bots on your Telegram account to edit their settings. Please refer to the [documentation on Telegram](https://core.telegram.org/bots#botfather-commands) to learn more about the commands you can use.

In the **Configuration** accordion, a **token** is required from Telegram.

To get this, use Telegram's BotFather chatbot to create a bot and gets its token:

1. Login to your Telegram account and start chatting with [BotFather](https://t.me/botfather), used to create new bots and change settings for existing ones.
2. Insert the **`/newbot`** command to create a new bot.
3. BotFather will ask for you to insert a:
   * **Name** — the bot's name shown to people who chat with it.
   * **Username** — the bot's short name, used in mentions and 't.me' links. It must be 5-32 characters long and is case sensitive, and only include letters, numbers, and underscores. The username must also end in "bot", e.g. "help\_bot" or "HelpBot".
4. BotFather will then generate the bot's **token**, which allows anyone to control the bot. If it's lost or compromised, use the **`/token`** command to generate a new one.
5. Insert the **`/setjoingroups`** command to disable the bot from being added to group chats, required for integration with Proto. Select the bot and type "**Disable**"
6. In Proto, paste the **token** into the Telegram configuration's **Authentication token** field.
7. Press **Verify**. If successful, a `t.me/<bot_username>` link will be generated and you can share this link with your audience.
8. Press **Save** to confirm edits.

See [Telegram documentation](https://core.telegram.org/bots#botfather-commands) for a full list of BotFather commands and options.

***

## Using Telegram

Follow the link generated in step 7 above to open a thread with the bot (your AI agent) in Telegram.
