# Telegram

Integrating BotDistrikt's chatbot with the Telegram messaging channel offers numerous benefits for startups and enterprises seeking to expand their reach and provide efficient customer support and engagement. Here are some of the key benefits:

1. **700 Million Monthly Active User Base**: Telegram boasts a sizable and diverse user base, making it an attractive platform for businesses to connect with a wide audience.&#x20;
2. **Automated Customer Support**: Chatbots on Telegram can efficiently handle routine customer support inquiries, such as frequently asked questions, order status checks, and basic troubleshooting. This automation frees up human agents to focus on more complex issues.
3. **Efficiency and Scalability**: Chatbots are capable of handling a large volume of conversations simultaneously. As user demand grows, chatbots can efficiently scale to accommodate increased interaction, reducing the need for additional support staff.
4. **Rich Media Sharing**: Telegram supports various media types, including images, videos, files, and links. Chatbots can leverage these capabilities to share multimedia content, product images, instructions, and more with users.
5. **Secure and Encrypted**: Telegram is known for its security features, including end-to-end encryption for messages.&#x20;
6. **Feedback and Surveys**: Gather user feedback and conduct surveys on Telegram, helping businesses collect valuable insights and improve their products or services based on user responses.
7. **Promotional Campaigns**: Run promotional campaigns, send updates, and offer discounts or special offers to users, fostering customer loyalty and engagement.
8. **Integration with External Systems**: Integrate with other business systems and databases, enabling them to access and provide real-time information, such as inventory levels, order statuses, and more.

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FBrJy1uBbsXHX7AUhYelR%2FUntitled%20design.gif?alt=media&#x26;token=00969eba-4b45-43b4-b70c-f9a367fffe60" alt="" width="240"><figcaption><p>Telegram Bot Integration</p></figcaption></figure>

## Prerequisites

In order to integrate Telegram with your Bot, you will need the following:

* [A Telegram Bot](https://telegram.org/blog/bot-revolution)

When a user sends a message to your Telegram bot, your BotDistrikt bot will reply to them.

### Create a Telegram Bot

First, you have to chat with the [BotFather](https://web.telegram.org/#/im?p=@BotFather) in Telegram. Search for "BotFather" and click on **Start**

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FpvwUN7j53LXQS3CEQC8P%2F1%20-%20telegram.png?alt=media&#x26;token=313bd357-1e56-4f12-8b57-f5575ef039c5" alt="" width="188"><figcaption><p>Click on Start with BotFather</p></figcaption></figure>

Select **/newbot** to start creating your bot.&#x20;

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FdLWHKK08m1d1UvjNEr1l%2F2%20-%20telegram.png?alt=media&#x26;token=a3e33d93-4e1a-41f4-a6e6-33aacfc6fedb" alt="" width="188"><figcaption><p>BotFather Process</p></figcaption></figure>

Next, choose a display name and username for your bot. You may edit the display name later on but the username is fixed.&#x20;

{% hint style="info" %}
The username is fixed and cannot be changed. Please choose a username carefully.&#x20;
{% endhint %}

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FASox7N2r6s50XmmsFzh4%2F3%20-%20telegram.png?alt=media&#x26;token=86abff54-7322-42d8-bd35-87735d7e26ce" alt="" width="188"><figcaption><p>Gain Token Access</p></figcaption></figure>

The BotFather will then issue an **Authorization Token**, also called *API Token*, or just *Token*. This token is like a password you will use to integrate your BotDistrikt bot. Keep it safe.

### Customise Bot Profile

To customize your Telegram bot's profile, you will need to chat with the BotFather again.

Type or select /mybots.

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2Fyu7tr4wkEggUaUPVDMrd%2F1%20-%20telegram%20edit.png?alt=media&#x26;token=561b1a10-1a0f-4312-936c-425a9ba420bb" alt="" width="188"><figcaption><p>Choose your Bot from mybots</p></figcaption></figure>

Next, you will be shown a list of your bots. Select the bot that you want to edit.

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FhzcOnWYsYSSjU2nHb6Sn%2F2%20-%20telegram%20edit.webp?alt=media&#x26;token=06548f26-9f23-4069-8a73-218e8de20f81" alt="" width="375"><figcaption><p>Edit your Bot</p></figcaption></figure>

Select your bot and a menu of what you can do to the bot will appear.

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FPSDMn2T5b8U8b8dfj1WF%2F3%20-%20telegram%20edit.webp?alt=media&#x26;token=babd486f-589a-4ba4-95ca-eb9ecc8d3e28" alt="" width="375"><figcaption><p>Edit Bot</p></figcaption></figure>

Select **Edit Bot**

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FMFD3vW6ibhVRkePWxb62%2F4%20-%20telegram%20edit.webp?alt=media&#x26;token=791d3f8c-afc1-4007-8f42-a4110542a9a9" alt="" width="375"><figcaption><p>Bot Menu</p></figcaption></figure>

Here is the list of fields you can edit for your Telegram bot:

| Field               | Where a Telegram User sees it                                    |
| ------------------- | ---------------------------------------------------------------- |
| Name                | <p>On the main Telegram inbox page,</p><p>In the chat thread</p> |
| Botpic              | <p>On the main Telegram inbox page,</p><p>In the chat thread</p> |
| Description         | When a user clicks on your bot for the first time                |
| Description Picture | When a user clicks on your bot for the first time                |
| About               | When the user clicks on "More Info" in the chat thread           |
| Commands            | In the **Menu** of your bot, or when a user types "**/"**        |

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FyJNElcgecJb701ErWQ6N%2Fspaces_-LirAdLo22OkAW9w3tvY_uploads_Ac5u1ApDs2JRnbpdsbf9_5%20-%20telegram%20edit.webp?alt=media&#x26;token=dd8f4cd8-5360-4689-b72f-b1d200019a7d" alt="" width="188"><figcaption><p>Bot Profile: Name, Description, and Botpic</p></figcaption></figure>

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FYGRIA79Lo93xJEGXP2QQ%2F6%20-%20telegram%20edit.png?alt=media&#x26;token=5d5e428b-4918-46c9-968a-1187e85b25df" alt="" width="188"><figcaption><p>Bot Profile: About</p></figcaption></figure>

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2F0Tqt3slxMDiKstKp1D4w%2FUntitled%20design.gif?alt=media&#x26;token=fd72f098-1fa7-4a85-a8c4-35ae697f59c3" alt="" width="240"><figcaption><p>Bot Profile: Commands</p></figcaption></figure>

## **Setup**

From your bot account, go to **Integrations**

Select **Telegram**

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2Flc81Y6aTMfbSi4dFk5R4%2F0%20-telegram.png?alt=media&#x26;token=10296d14-c9ed-4d94-87f6-31c9ddea13ea" alt=""><figcaption><p>Select Telegram Channel</p></figcaption></figure>

* Paste your bot's **Authorization Token** from the BotFather
* Click on **Link to Telegram**

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FdbofBDYsloHBILtfD2Hy%2F4%20-%20telegram.png?alt=media&#x26;token=a7a25a36-c2b7-456b-a557-c4d647f90a96" alt=""><figcaption><p>Enter Authorization Token</p></figcaption></figure>

You will receive a notification from BotDistrikt stating that a new group of Rules called **TELEGRAM** will be added to your bo&#x74;**.** Click **OK**

And you are done! Your bot is now live as your Telegram Bot

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FNzWczcppnaFgdoeXTILV%2Ftelegram.png?alt=media&#x26;token=a9981427-992b-4d0c-8671-01b22118130b" alt=""><figcaption><p>Your Bot is Ready</p></figcaption></figure>

## Trigger Story Upon Chat Session Expiry

To send a story on a user chat session expiry, activate the toggle for **Send a story when the chat session expires**.

Upon activating the toggle, select a Session Expiration Story from the dropdown menu. Once selected, click **Save**.

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FZt3CYR1FADE6KUfTPJsI%2FScreenshot%202024-07-04%20at%202.47.12%E2%80%AFPM.png?alt=media&#x26;token=120868d3-1b60-4e84-a12d-4236ec8b724d" alt=""><figcaption><p>Session Expiration Story Selection</p></figcaption></figure>

On session expiry, the selected story will be sent to the user. You can use this feature to collect user feedback, increase user engagement, and more!

<figure><img src="https://2535542804-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LirAdLo22OkAW9w3tvY%2Fuploads%2FEB3c92UOb2bEez4gVVxn%2FScreenshot_20240704-211837.webp?alt=media&#x26;token=d0e65fca-1ff5-40bc-a9b0-113452cd6e71" alt="" width="248"><figcaption><p>Story Sent on Session Expiry</p></figcaption></figure>
