# Working in messengers

## Checking Instagram subscription

check\_insta\_subscription()

<details>

<summary>Description</summary>

<mark style="background-color:blue;">**To check subscription to an Instagram account**</mark>

**check\_insta\_subscription()**

Parameters: None

The function returns logical **True** if the user is subscribed to the account, **False** if not.

</details>

<details>

<summary>Examples</summary>

<figure><img src="/files/ezSJfGEaTSYSnP7IlYTM" alt="" width="375"><figcaption></figcaption></figure>

</details>

<details>

<summary>Code example for copying</summary>

`r=check_insta_subscription()`

</details>

## Working with WhatsApp&#x20;

check\_whatsapp() | get\_whatsapp\_bot\_id\_by\_phone()

<details>

<summary>Description</summary>

{% hint style="warning" %}
The functions work if a WhatsApp bot is connected to a project.
{% endhint %}

<mark style="background-color:blue;">**To check whether a phone number has WhatsApp**</mark>

**check\_whatsapp(phone\_number)**\
method to check whether WhatsApp is connected to the given phone number

Parameters:\
**phone\_number** - phone number in the format 79999999999 or 89999999999

The function returns logical **True** if the number is registered in WhatsApp, **False** if it is not.

<mark style="background-color:blue;">**To get WhatsApp bot\_id by phone number**</mark>

**get\_whatsapp\_bot\_id\_by\_phone(bot\_phone)**\
function to find WhatsApp bot\_id by phone number

</details>

<details>

<summary>Examples</summary>

Let’s check if WhatsApp is connected to a phone number:

<figure><img src="/files/hdYu4T925hXZEI2Gkra3" alt="" width="375"><figcaption><p>Example usage of the function check_whatsapp()</p></figcaption></figure>

</details>

<details>

<summary>Code example for copying</summary>

```
rs=check_whatsapp(79999999999)
```

</details>

## Removing last message

last\_message\_id() | remove\_last\_message()

<details>

<summary>Description</summary>

**last\_message\_id()**- to get the number of the last bot's message

{% hint style="info" %}
If both an image and text have been sent, the message numbers are separated by an underscore (\_)
{% endhint %}

{% hint style="warning" %}
To correctly get the number of the bot’s last message, the message should be saved in the client dialog history.

This means that in a funnel block, message history saving should be enabled if sent via the funnel, or when sending a broadcast, the option "save message to dialog history" needs to be turned on.
{% endhint %}

**remove\_last\_message()** – to delete the bot's last message

{% hint style="danger" %}
It work only in Telegram and Facebook.
{% endhint %}

If the **"Save to dialog history"** toggle is enabled, then for Telegram and FB you can delete the last message via a mailing from a block. Simply use the function **remove\_last\_message()** in the calculator. This function removes the last message sent by the bot, but only if that message is saved in the dialog history.

</details>

<details>

<summary>Example</summary>

Example:

1. Create a broadcast block:

<div data-with-frame="true"><figure><img src="/files/1hRM9weVfb6xMurqxWVJ" alt=""><figcaption></figcaption></figure></div>

{% hint style="success" %}
Customize the mailing settings as you like, then go to the **"Sending"** tab.
{% endhint %}

&#x20;2\. Activate the checkbox **"Save mailing in the client dialog history"** in the **"Sending"** tab:

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

Now, feel free to send the mailing.

If you want to delete the last message (for example, a message with an error), you can do so in a single block using the function **remove\_last\_message()**.

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

Next, send the mailing with the function to delete the last message.

{% hint style="warning" %}
IMPORTANT! The last message cannot be deleted after some time!
{% endhint %}

Пример с получением ID последнего сообщения.

<figure><img src="/files/bcaqbidhACRLtm36vHFB" alt="" width="375"><figcaption></figcaption></figure>

</details>

<details>

<summary>Code example for copying</summary>

```
soob = last_message_id()
status = remove_last_message()
```

</details>

## Pausing bot's operation

\| pause\_bot(minutes)

<details>

<summary>Description</summary>

pause\_bot(minutes) - pauses bot’s operation for the specified number of minutes.

minutes - required parameter representing the number of minutes. It can be passed as either an integer or a decimal number.

The function works like clicking the **"Pause"** button in a client dialogue, but lets you specify the duration to pause the bot. It returns **True** upon successful execution.

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

</details>

## Deleting planned messages

\| delete\_pended\_messages\_from\_list(message\_id\_list, with\_not\_delete)

<details>

<summary>Description</summary>

delete\_pended\_messages\_from\_list(message\_id\_list, with\_not\_delete)

The function helps delete specific messages from the scheduled ones.

<mark style="color:red;">!</mark> message\_id\_list - required parameter; a list of blocks whose messages need to be deleted from the scheduled ones.

with\_not\_delete - optional parameter; deletes messages marked as **"Do not delete."** Any value can be passed to this parameter.

The return value **"wrong message\_id\_list"** appears if message\_id\_list is not provided or is not an array.

How to pass parameters:

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

Where to get the required parameter:

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

</details>

## Checking the operator's status

\| check\_operator\_status(email, with\_pause)

<details>

<summary>Descriptiom</summary>

check\_operator\_status(email, with\_pause) - checks whether the operator is on shift. Returns **True** if the operator is on shift, and **False** if not.

<mark style="color:red;">**!**</mark> email - required parameter; an employee's email

with\_pause - optional parameter with values 1 or 0. If set to 1, the function returns a positive result when the operator’s status is either **"On shift"** or **"On break."** If set to 0, it returns a positive result only when the operator’s status is **"On shift."**&#x20;Default value: 1.

</details>


---

# 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/functions/calculator/messengers.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.
