# Telegram step

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MTCfu1LmTo8KSd2wj5b%2F-MTCgLcqvdhMLyUQVyOJ%2Ftelegram_v2.png?alt=media\&token=2ce9cf00-cc88-442d-8d6c-2fd14a099bdf)

Telegram step works as an interface to [Telegram API](https://core.telegram.org/bots/api). There are following options to work with Telegram step:

* **Professional mode**. Choose any Telegram method you like and compose the request in JSON-format;
* **Send text message**. Easier way to deal with `sendMessage` method. Typing a text message + choosing advanced options

## Professional mode (HTTP-requests)

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MTCfu1LmTo8KSd2wj5b%2F-MTChi0gTJbr5UR33Ayq%2Fpro-mode.png?alt=media\&token=e14ee5d3-378e-4c0b-98ee-4bbeb93041b7)

There are following fields:

* **Chat IDs**. That is ID (or an array of IDs, comma separated) of objects from `Integrations/Telegram/TChat` data structure (see [Telegram data structures](https://readme.directual.com/api-integrations/other-integrations/telegram#step-3-find-telegram-structures-in-directual)).
* **Method type**. POST/GET.
* **Method name**. One of the [Telegram official API-methods](https://core.telegram.org/bots/api).
* **Request body**. According Telegram documentation, but exclude parameter `chat_id` — it will be added automatically, based on **Chat IDs** field. The input control will check consistency of JSON syntax. You are welcome to use [Template system](https://readme.directual.com/template-system/basics-of-template-system) here, adding fields of the current object, global constants or local variables.
* **Save response to...** Choose where to save API response (if necessary).
* **Escaping characters with \\**. If the option ON, Directual will escape [characters from the list](#please-note) with `\`. But be careful. That could conflict with Markdown (inline links mostly). Turn the option OFF  if you want to manage that matter by yourself.&#x20;

{% hint style="warning" %}
Automatic character escaping usually brakes markdown links. Turn it off, if you want to add links, but mirror characters from the list manually.
{% endhint %}

{% hint style="info" %}
You can start editing your http-request from another mode, and then switch to Professional.
{% endhint %}

## **Send text message**

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MTCfu1LmTo8KSd2wj5b%2F-MTCmulYF7_6sgcsiNaN%2Ftext-mode.png?alt=media\&token=1867a675-a558-40f2-a1d8-18bd49efaccc)

There are following fields:

* **Message** (with Markdown formatting by default).
* **Use reply keyboard.**
  * List of buttons below, each one has options to request contact or request location.
* **Remove keyboard** (doesn't match with the previous option). Removes all reply keyboards.
* **Disable notification**.
* **Disable link preview**.
* **Escape characters with \\**. Works in the same way as in Professional mode.

## Text message Markdown formatting

Telegram Bot API supports basic formatting for messages. You can use **bold**, *italic*, underlined and ~~strikethrough~~ text, as well as inline links and pre-formatted code in your bots' messages. Telegram clients will render them accordingly.

In Telegram v.2 step Markdown v2 is turned on by default. Use the following syntax in your message:

````
*bold \*text*
_italic \*text_
__underline__
~strikethrough~
*bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold*
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
`inline fixed-width code`
```
pre-formatted fixed-width code block
```
```python
pre-formatted fixed-width code block written in the Python programming language
```
````

#### Please note:

* Any character with code between 1 and 126 inclusively can be escaped anywhere with a preceding '\\' character, in which case it is treated as an ordinary character and not a part of the markup.
* Inside `pre` and `code` entities, all '\`' and '\\' characters must be escaped with a preceding '\\' character.
* Inside `(...)` part of inline link definition, all ')' and '\\' must be escaped with a preceding '\\' character.
* In all other places characters '\_', '\*', '\[', ']', '(', ')', '\~', '\`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!' must be escaped with the preceding character '\\'.
* In case of ambiguity between `italic` and `underline` entities `__` is always treated from left to right as beginning or end of `underline` entity, so instead of `___italic underline___` use `___italic underline_\r__`, where `\r` is a character with code 13, which will be ignored.
