The module allows you to call API methods for integration with third systems. To run the script, we need call_node
method.
Call format:
POST <https://engine>.{{project slug}}.kwizbot.io/kw/api/call_node/
or
Where:
Calls the execution of the script from the entry point (see Components for details) specified in the call for the user with the specified chat_id of the specified channel.
This screenshot shows the entry point with the alias crm_entry_point
JSON request format (JSON body):
{
"chat_id":"398866372",
"channel":"telegram",
"bot_id":1,
"connector_alias":"crm_entry_point",
"data":{
"phone":"380961234567",
"name":"Sergey"
}
}
Where:
connector_alias
this is a unique alias for the entry pointchat_id
this is a unique identifier of the chat within the channel that was saved when the user subscribes to notifications User subscription to bot notificationsbot_id
this is the bot id in Kwizbot. By default, 1, if you have 2 or more bots deployed, you can see which id of the bot in Settings - List of botsdata
you can pass any parameters that the script can then process as ordinary variables, for example, output using {{variable name}}
Response format:
{
"status": "error" или "success"
"message": "сообщение с ответом",
"data": {...данные ответа...}
}
Curl-request example:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{{engine-url}}/kw/api/call_node/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"chat_id":"999999999",
"channel":"telegram",
"bot_id":1,
"connector_alias":"node_alias",
"data":{
"phone":"380111111111",
"name":"Randomname"
},
"callback_url": "[<https://callback-getter.site>](<https://callback-getter.site/>)"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>