# API Telegram functions

API functions significantly expand the capabilities of a bot in Telegram. By using API functions, you can work with attachments, groups, and chats in Telegram — for example, automating the blocking or unblocking of users, and much more!

{% hint style="info" %}
Source: [Telegram bot API](https://core.telegram.org/bots/api)
{% endhint %}

{% hint style="warning" %}
Important!&#x20;

To understand how to work with API functions, we strongly recommend reviewing the rules for specifying functions and parameters in the calculator.

<mark style="color:red;">**NOTATION:**</mark>

<mark style="color:red;">**!**</mark> — an exclamation mark indicates required parameters

**parameter=None** — this shows the default value for the specified parameter.

It's <mark style="color:red;">**incorrect**</mark> to simply copy the function text from the documentation, like this: tg\_send\_message(platform\_id, "Some text", client\_message\_id=61818138, reply\_markup=None, parse\_mode=None, disable\_web\_page\_preview=0, protect\_content=False)

The values after the equals signs represent default values for each parameter. Therefore, if you don’t need a particular parameter but do need one that follows it, you can’t just skip the unused one — instead, you must explicitly pass its default value.

Thus, the <mark style="color:green;">**correct**</mark> usage would be: tg\_send\_message(platform\_id, "Some text", 61818138, None, None, 0, True)
{% endhint %}

### Where can I get the <mark style="color:red;">platform\_id</mark> for sending notifications?

* You need to have a Telegram bot connected to your project.
* Send any message to this bot from the Telegram account where you want to receive notifications.
* In the list of project clients, select the client dialog you want to send requests to.
* Copy the ID value from the messenger field.

<div data-with-frame="true"><figure><img src="/files/IapsE9CRfKSncRtEDkCC" alt="" width="359"><figcaption></figcaption></figure></div>

<details>

<summary>Example of passing the <mark style="color:red;">platform_id</mark> parameter:</summary>

1. The platform\_id parameter can be passed without explicitly specifying numeric values.

<figure><img src="/files/XDqDZM23DXUxEdptzVWp" alt=""><figcaption><p>platform_id was provided without any value</p></figcaption></figure>

`react = tg_set_reaction(platform_id, 1556, '👌')`

Functions with this parameter will work even without explicitly specifying a platform\_id value.\
Important: In most functions, this parameter is required and must not be omitted. <br>

2\. If you need to use the function in a specific chat, channel, or group, you must provide the platform\_id as a numeric value.

<figure><img src="/files/ZqrHsL2rrVdXHS9SMk8l" alt="" width="563"><figcaption></figcaption></figure>

In the function **tg\_send\_message(!platform\_id, !text)** shown above, the platfor&#x6D;**\_id parameter** is passed using quotation marks enclosing a numeric value:

`tgmess = tg_send_message('1234566788', 'Hello!')`&#x20;

<figure><img src="/files/ou0lg78tXZNuXQfg6FIS" alt="" width="563"><figcaption></figcaption></figure>

</details>

### How to define buttons in the reply\_markup parameter

**Example of reply buttons:**

`opts = {"keyboard": [[{"text": "Left"}, {"text": "Right"}]]}`

**Example of inline buttons:**

opts = {"inline\_keyboard": \[\[{"text": "Package 1","callback\_data":1}, {"text": "Package 2","callback\_data":2}]]}

### How to use text formatting (Markdown) in the parse\_mode paramete&#x72;**?**&#x20;

The **parse\_mode** parameter formats the entire text or parts of it in *italic* or **bold**. It can have the values: html, markdown, or markdownV2.

1. <mark style="color:blue;">**If you choose html:**</mark>

&#x20;        for **bold text**, use  `"<b>caption</b>"`

&#x20;        for *italic text*, use `"<i>caption</i>"`

2. <mark style="color:blue;">**For Markdown:**</mark>

&#x20;        for **bold text**, use  `"*caption*"`

&#x20;        for *italic text*, use  `"_caption_"`

**Example of sending italic text:**\
`tg_send_message(47615196, "<i>italic</i>",None,None,"html")`

**Example of sending bold text:**\
`tg_send_message(platform_id, '*test*', None, None, 'markdown')`


---

# Agent Instructions: 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:

```
GET https://docs.mavibot.ai/chatbot/messengers/telegram/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
