# Блок "Входящий Webhook"

Блок "Входящий Webhook" создан для приема http-запросов со сторонних ресурсов и их обработки с помощью языка JavaScript.

<figure><img src="/files/3MrJGBKQZdOPEo5mQOM5" alt=""><figcaption></figcaption></figure>

### Объект request

Запрос от вашего сервера записывается в JavaScript объект `request`.<br>

```
var headers = request.headers; // Объект заголовков
var query = request.query; // Объект переменных строки запроса
var rawBody = request.body; // Сырое тело запроса
var data = request.data; // Объект всех переменных запроса, включая строку запроса, форму, тело и т.д.
```

### Примеры кода <a href="#primery-koda" id="primery-koda"></a>

{% hint style="info" %}
Прежде чем писать код обработки запроса, вам нужно установить текущий контакт, иначе связь "Продолжить" не отработает.
{% endhint %}

```
// Получить внутренний ID контакта платформы из строки запроса:
var contactId = request.query.contact_id;

// Установить контакт по его id
var success = setContactById(contactId);
// Контакт установлен?
if (success) {
  // todo
}
```

**Все функции установки контакта:**

{% content-ref url="/pages/NHRixNhX1zdJix5Q2JUI" %}
[setContactById()](/onebot-help/bloki-konstruktora/integracii/setcontactbyid.md)
{% endcontent-ref %}

{% content-ref url="/pages/RB8kCESr2ke43kZMWGml" %}
[setContactByTelegramId()](/onebot-help/bloki-konstruktora/integracii/setcontactbytelegramid.md)
{% endcontent-ref %}

{% content-ref url="/pages/aTsSN0eIjqtgCQru3ZjA" %}
[setContactByViberId()](/onebot-help/bloki-konstruktora/integracii/setcontactbyviberid.md)
{% endcontent-ref %}

{% content-ref url="/pages/Gxyxyk7jc1u1BVrNDWgI" %}
[setContactByVkId()](/onebot-help/bloki-konstruktora/integracii/setcontactbyvkid.md)
{% endcontent-ref %}

{% content-ref url="/pages/Gx6BKOtKIlnLsl7m2OQ9" %}
[setContactByWhatsAppPhone()](/onebot-help/bloki-konstruktora/integracii/setcontactbywhatsappphone.md)
{% endcontent-ref %}


---

# 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://help.onebot.tech/onebot-help/bloki-konstruktora/integracii/blok-vkhodyashii-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.
