The chatId variable is a general way to get ChatApp client data. Some messengers don't have phone numbers (TelegramBot, ViberBot, Instagram, Facebook*, VK, Avito). Then you can start a dialogue via Bitrix24 webhook by getting the ChatId of the ChatApp client.
The chatId variable (Chat ID) is assigned to all clients in ChatApp with whom a chat has already been opened:
While there was no dialogue with the client, the variable cannot be used.
How to get the chatId of a client via Bitrix24
1. Enter the section "CRM" and click on "Automation rules".
2. In the Automation rules and triggers section choose "Create" new robot.
3. Select “Other” and find the ChatApp robot "Get chatId from the Messenger field".
Add this robot.
4. Complete the fields and set up the robot:
- Condition - select the type of condition to trigger.
- Field “Messenger” - specify the messenger from the deal or lead card.
- ChatApp Line Id - ID of the line where the robot will be active. You can leave this field empty if there is only one line.
- Channel - on which the robot will work.
- Run as - The employee on whose behalf the robot was started joins the chat, the person in charge does not change.
3. After the robot starts, you will receive ID from ChatApp clients.
4. The ChatId obtained through the robot can be used in the following robots or Bot Builder.