# Webhook from Telegram

{% hint style="success" %}
**What is a webhook?**&#x20;

This is a notification about an event that has occurred. This notification contains the values of the changed variables.
{% endhint %}

## How to get webhook?

To get a complete webhook from Telegram, it is enough to assign <mark style="color:red;">**any value to the**</mark>**&#x20;save\_webhook** <mark style="color:red;">**variable:**</mark>

Example `save_webhook = 'text value'`

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

Example: numeric variable value

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

The save\_webhook variable can be either a project constant or a variable in the calculator (examples above):

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

In this case, the client's response to the bot message, which contains such a variable, will be recorded in the Telegram variable **tg\_request,** which you can find in the client's card among the transaction variables.

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

The client responded to the bot's message from the block in which the save\_webhook variable is assigned.

tg\_request and save\_webhook in client variable

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

## How to get a media link using a variable?

You can use the `tg_request` function to obtain a direct download link for a video, image, or animation sent by a user.

**Implementation steps:**

1. **Set up the webhook variable:**\
   First, assign any value to a variable named `save_webhook`. You can define this as a **project constant** or a **variable within a Calculator block**.
2. **Create the Trigger block:**\
   Next, create a **Trigger block**. This block will listen for incoming media and use the `tg_request` function with your `save_webhook` variable to capture the file link.

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

* Next, create a block to output the result.

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

Follow these steps to get a direct link to a file from your bot:

1. **Go to your connected Telegram bot** and start a chat.
2. **Type your designated keyword** to activate the file request function.
3. **Send the file** (image, video, etc.) for which you want to receive the downloadable link.

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

Pay attention in the last file\_id in the received Telegram response:

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

Do not forget that the received link is valid only within the bot framework to which you sent the file.


---

# 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/webhook.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.
