# setContactByVkId()

Функция **setContactByVkId()** устанавливает текущий контакт для которого выполняется JavaScript-код.&#x20;

{% hint style="warning" %}
Эта функция предназначена для блока "**Входящий Webhook**" и будет работать только в нем.

Контакт должен существовать в боте на платформе.
{% endhint %}

### Синтаксис

```javascript
setContactByVkId(id)
```

* `id` - (число) id пользователя ВКонтакте.&#x20;

### Возвращаемые значения

* Логический

### Пример

В этом примере устанавливается контакт с id пользователя ВКонтакте "123".

```javascript
var success = setContactByVkId(123);
if (success) {
    // Контакт успешно установлен
}
```

{% hint style="warning" %}
В одном скрипте такую функцию можно вызвать только 1 раз.
{% endhint %}


---

# 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.watbot.ru/js-api/funkcii/setcontactbyvkid.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.
