> For the complete documentation index, see [llms.txt](https://readme.directual.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://readme.directual.com/api-integrations/other-integrations/telegram.md).

# Telegram

## What is Telegram

[Telegram](https://telegram.org/) is a messenger that allows for the creation of advanced chatbots. Let's explore how you can create a Telegram bot using Directual.

## &#x20;Directual–Telegram basics

### Step 1. Create a bot

Open the messenger and go to the [BotFather](https://t.me/BotFather) and type `/newbot`

![Secret token is red. Here on the screenshot it is masked partially :)](/files/-MQfKxScX0tY2HQAQu-z)

The BotFather will give you an HPPT API **secret token** (the red one).

### Step 2. Connect your bot to the app

Go to Directual app, **Plugins** section → **Telegram** , insert the **secret token** you copied and click **Install**.

<figure><img src="/files/efDUH57a6NBZ8tppJcTh" alt=""><figcaption></figcaption></figure>

### Step 3. Find Telegram structures in Directual

Go to Database section, `Integrations/Telegram` folder (it appears automatically). Here you will find five data structures:

![](/files/-MQfP8SBK2E_ZXT8Ze4M)

* **Incoming Telegram messages** (system name `TMessageIn`). Stores all messages that users have sent to the bot.
* **Outcoming Telegram messages** (system name `TMessageOut`). Stores all messages that the bot have sent to users.
* **Users Telegram** (system name `TUser`). Stores Users who have sent messages to the bot.
* **Chats Telegram** (system name `TChat`). Stores Chat-objects. That is the object which is used by scenario Telegram step as a 'destination'.
* **Keyboards Telegram (Legacy)** (system name `TKeyboard`).

Also, a [webhook](/api-integrations/webhooks.md) for receiving Telegram messages has been added, and a new [System scenario](/scenarios/system-scenarios.md) `Parse incoming telegram messages` has appeared (do not edit them!).

### Step 4. Test the integration and investigate `TMessageIn` structure

Type something to the bot! Send a picture, a file, or location details. Then check the `TMessageIn` structure.

![Different messages are being sent to the bot](/files/-MQfShYO0FcjHKZYIgUv)

Let's have a look at new objects which appeared in `TMessageIn`!

![](/files/-MQfUPWN16IxlJJ_0b4t)

The clue field for text messages is `text` — it contains the message. Also there is information referring to images, files and locations.&#x20;

{% hint style="info" %}
Information about files and images are stored as `Telegram file IDs`, further in this manual we'll figure out how to download and process them.&#x20;
{% endhint %}

### Step 5. Creating a simple scenario

Create a new scenario, which triggers new objects in `TMessageIn` structure. (See [scenarios documentation](/scenarios/principles-of-scenarios.md)):

![](/files/-MQfXVDsKUkWHC3H2aUv)

Put the [Telegram step](/scenarios/editing-scenarios/integration-steps/telegram-step.md) in scenario and configure it as follows (don't forget to publish and run the scenario):

![](/files/-MQfYJ3is7HuQGMnvHmg)

The bot will behave as follows:

![](/files/-MQf_ZOszMDh6rEbP2tZ)

Check out some [useful techniques for building Telegram bots with Directual](/api-integrations/other-integrations/telegram/telegram-advanced-techniques.md)
