via Make.com
Table of contents
Create a new Contact at Bitrix24 CRM when a new WhatsApp Message is received
| This flow creates a contact at Bitrix24 CRM when the new WhatsApp message is received and contact with such a number does not exist at Bitrix24. The flow is based on TimelinesAI Webhooks , Bitrix24 CRM integration with Make.com and Bitrix24 CRM Rest API.
Create a new scenario at Make.com
Add a Custom Webhook module . Further steps require data from a webhook to be present. Make sure you've run the Webhook module and have data in the payload
Add a new _Bitrix24 Search Contacts_ module: The purpose of this step is to check whether contact already exists at Bitrix24 CRM or not. The check is done using the Phone Number field. To add this module click the + icon next to the existing _Webhooks _module > search for and select _Bitrix24 _ > then select _Search Contacts_
Configure the new _Bitrix24 Search Contacts_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save: |
Filter: select _Phone_ ; operators: _equals_ . Click the next empty field. A new box will appear to the right with data available from the _Webhook_ module. Find _sender_ > _phone_ . You can either click the found value OR drag and drop it into the empty field:
Click OK
Right-click the newly created _Bitrix24 Search Contacts_ and select _Run this module only _ > enter any phone number > click OK. This searches your Bitrix24 CRM contacts by entered phone number and returns results on whether contact with such phone number exists or not. Further steps require output data from this to be present. Make sure you've run the _Bitrix24 Search Contacts_ and have data in the payload:
Add a new _Flow Control Router_ module: The purpose of this step is to divide the flow into 2 branches: 1- if the search module found the contact, 2-if the search module did not find the contact. To add the _Router_ module click the + icon next to the existing _Bitrix24 Search Contacts_ module > search for and select Flow Control > then select _Router_ . The result:
Add the first Filter: click the wrench icon between the _Router_ and the next empty module > then click Setup a filter
Name your filter Contact does not exist
Condition: click the field. A new box will appear to the right with data available from the _Bitrix24 Search Contacts_ module. Find _Total number of bundles_ >. You can either click the found value OR drag and drop it into the empty field
Numeric operators: select _less then_ and type 1 into the next field:
Add a new _Bitrix24 Create Contact_ module: The purpose of this step is to create a contact if it was not found by the Search module. To add this new module click the + icon next to the existing "Contact does not exist" filter > search for and select _Bitrix24 _ > then select _Create Contact_
Configure the new _Bitrix24 Create Contact_ module:
First name: can be mapped with _chat: full_name_ from a TimelinesAI webhook
Phone: can be mapped with the _message: sender: phone_ from a TimelinesAI webhook
Other fields: can be mapped, left empty, or have custom data per your needs
End result: TimelinesAI Webhook monitors incoming WhatsApp messages > searches Bitrix24 CRM for contact by phone number > if contact is not found > creates a new contact:
Synchronize new incoming WhatsApp messages into task comments at Bitrix24 CRM
| This flow creates a task at Bitrix24 CRM when the new WhatsApp message is received, links the task with the corresponding Bitrix24 CRM contact and adds new incoming WhatsApp messages as comments to the task .The flow is based on TimelinesAI Webhooks , Bitrix24 CRM integration with Make.com and Bitrix24 CRM Rest API.
Complete the steps from Create a new Contact at Bitrix24 CRM when new WhatsApp Message is received part of this article first. You should have the following modules in your scenario to proceed further:
Add a new _Make an API Call_ module: The purpose of this module is to create a task at Bitrix24 CRM and link the task to the Bitrix24 CRM contact that was created earlier in this flow. To add a new module: mouse hover the existing _Create a contact _module and click the _+_ to add a new module. Search for and select _Bitrix24 _ > then select _Make an API Call_
Configure the new _Make an API Call_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save
URL:
tasks.task.add
Method: POST
Headers: add a new header with key = _Content-Type_ and value= _application/json_
Body: add
{ "fields": { "TITLE": "TimelinesAI_WhatsApp_messages", "UF_CRM_TASK": ["C_YOUR_ID_HERE], "ADD_IN_REPORT": "N", "STATUS":"5", "RESPONSIBLE_ID": "1" }}
Note: parameter details of this request are available at https://training.bitrix24.com/rest_help/tasks/task/tasks/tasks_task_getFields.php
Save your changes. Right-click the newly created module and rename it to API call: create a task. Renaming modules properly is important to avoid any confusion down the road as you will be adding more _Make an API Call_ modules.
Right-click the module and click _Run this module only _ > enter the contact ID from your Bitrix24 CRM > click OK. To find the contact ID in Bitrix24 CRM, open the Contact List, select any contact (preferably a test contact), and look at the URL of the page you land on. For example, if the URL is https://XXXX.bitrix24.com/crm/contact/details/17/, the contact ID is 17. After running the module, check the contact's page in Bitrix24 CRM to confirm that the new task was created.
Add a new _Make an API Call_ module: The purpose of this step is to add received WhatsApp messages as comments to the Bitrix24CRM task you've created earlier in the flow. To add the module: mousehover the last _API call: create a task_ module and click the _+_ to add a new module. Search for and select _Bitrix24 _ > then select _Make an API Call_
Configure the new _Make an API Call_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save
URL:
task.commentitem.add
Method: POST
Headers: add a new header with key = _Content-Type_ and value= _application/json_
Body: add
[YOUR_TASKID_HERE, { "POST_MESSAGE": "YOUR_TIME_HERE message received: YOUR_MESSAGE_TEXT" }]
YOUR_TASKID_HERE must be replaced with the output data of your own _API call: create a task_.
YOUR_TIME_HERE and YOUR_MESSAGE_TEXT must be replaced with the output data of the original webhook module. You can include additional data into the POST_MESSAGE field from your Webhook if needed.
Save your changes. Right-click the newly created module and rename it to _API call: add WA message as a comment to the task_. Renaming modules properly is important to avoid any confusion down the road as you will be adding more _Make an API Call_ modules
Right-click the module and click _Run this module only _ > enter the random numbers into "Timestamp" field > enter the testing task ID from your Bitrix24 CRM > click OK. To find the task ID in Bitrix24 CRM, open any task ( preferably a testing one). You can find the task created at Bitrix24 CRM when you run earlier modules and use it for testing. Look at the URL of the page you land on. For example, if the URL is https://XXX.bitrix24.com/company/personal/user/1/tasks/task/view/35/XXXX , 35 will be the task ID. Enter the random text. In an production mode received WhatsApp message will become a text. After running the module, check the task's page in Bitrix24 CRM to confirm that the comment to the task was added:
Intermediate result : Webhook monitors incoming WhatsApp messages > searches Bitrix24 CRM for contact by phone number > if contact is not found > creates a new contact > creates a special task and links it to the contact > adds received WhatsApp messages as comments to the task .
So far we have worked in a branch where the contact did NOT exist at Bitrix24 CRM and we had to create them, then create a task and add WhatsApp messages as comments to that task. In this section we will work on a new branch of the flow where the contact already exists and we just need to add a task and comments.
Add a new filter. Click the wrench icon between the _Router_ and the next empty module > then click Setup a filter (https://storage.crisp.chat/users/helpdesk/website/94268256ba492800/screen-shot-2024-01-16-at-1754_o6wobi.png)
Name your filter _Contact exists_
Condition: click the field. A new box will appear to the right with data available from the _Bitrix24 Search Contacts_ module. Find _Total number of bundles_ >. You can either click the found value OR drag and drop it into the empty field
Numeric operators: select _greater then or equals_ and type 1 into the next field
Add a new _Make an API Call_ module: The purpose of this step is to find whether the existing contact has a task where WhatsApp messages are stored or not. To add a module click the + sign after the latest created filter > search for and select _Bitrix24 _ > then select _Make an API Call_
Configure the new _Make an API Call_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save
URL:
tasks.task.list.json?order[CREATED_DATE]=desc&filter[UF_CRM_TASK]=C_YOUR_CONTACT_ID_HERE&[TITLE]=TimelinesAI_WhatsApp_Messages
Method: GET
Headers: add a new header with key = _Content-Type_ and value= _application/json_
Body: empty
YOUR_CONTACT_ID_HERE must be replaced with the output data from your own _Search Contacts_ module.
Save your changes. Right-click the newly created module and rename it to _API call: search tasks_. Renaming modules properly is important to avoid any confusion down the road as you will be adding more _Make an API Call_ modules.
Right-click the module and click _Run this module only _ > enter the contact ID from your Bitrix24 CRM > click OK. To find the contact ID in Bitrix24 CRM, open the Contact List, select any contact (preferably a test contact), and look at the URL of the page you land on. For example, if the URL is https://XXXX.bitrix24.com/crm/contact/details/17/, the contact ID is 17.
Add a new _Flow Control Router_ module: The purpose of this step is to divide the flow into 2 more branches: 1- if the search tasks module found the task, 2-if the search module did not find the task. To add the _Router_ module click the + icon next to the existing _API call: search tasks_ module > search for and select Flow Control > then select _Router_ .
Add a Filter: click the wrench icon between the Router and the next empty module > then click Setup a filter ![]
Name your filter _If Task exists_
Condition: click the field. A new box will appear to the right with data available from the _API call: search tasks_ module. Find _Body > Total_ >. You can either click the found value OR drag and drop it into the empty field
Numeric operators: select _equals to_ and type 1 into the next field:
Add a new _Make an API Call_ module: The purpose of this step is to add received WhatsApp messages as comments to the found Bitrix24CRM task. To add this module click the + icon next to the existing "If Task exists" filter > search for and select _Bitrix24 _ > then select _Make an API Call_
Configure the new _Make an API Call_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save
URL:
task.commentitem.add
Method: POST
Headers: add a new header with key = _Content-Type_ and value= _application/json_
Body: add
[YOUR_TASKID_HERE, { "POST_MESSAGE": "YOUR_TIME_HERE message received: YOUR_MESSAGE_TEXT" }]
YOUR_TASKID_HERE must be replaced with the output data of your own _API call: search tasks _ module.
YOUR_TIME_HERE and YOUR_MESSAGE_TEXT must be replaced with the output data of the original webhook module. You can include additional data into the POST_MESSAGE field from your Webhook if needed.
Right-click the newly created module and rename it to "API call: add WA message as a comment to the task"
Save your changes and add a 2nd Filter:
Name your filter _If task does not exist_
Condition: click the field. A new box will appear to the right with data available from the _API call: search tasks_ module. Find _Body > Total_ >. You can either click the found value OR drag and drop it into the empty field
Numeric operators: select _less then_ and type 1 into the next field:
Add a new _Make an API Call_ module: The purpose of this module is to create a task at Bitrix24 CRM and link the task to the existing Bitrix24 CRM contact. To add this module click the + icon next to the existing "If Task does not exists" filter > search for and select _Bitrix24 _ > then select _Make an API Call_
Configure the new _Make an API Call_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save
URL:
tasks.task.add
Method: POST
Headers: add a new header with key = _Content-Type_ and value= _application/json_
Body: add
{ "fields": { "TITLE": "TimelinesAI_WhatsApp_messages", "UF_CRM_TASK": ["C_YOUR_ID_HERE], "ADD_IN_REPORT": "N", "STATUS":"5", "RESPONSIBLE_ID": "1" }}
Note: parameter details of this request are available at https://training.bitrix24.com/rest_help/tasks/task/tasks/tasks_task_getFields.php
Right-click the newly created module and rename it to "API call: create a task"
Right-click the module and click _Run this module only _ > enter the contact ID from your Bitrix24 CRM > click OK. To find the contact ID in Bitrix24 CRM, open the Contact List, select any contact (preferably a test contact), and look at the URL of the page you land on. For example, if the URL is https://XXXX.bitrix24.com/crm/contact/details/17/, the contact ID is 17. After running the module, check the contact's page in Bitrix24 CRM to confirm that the new task was created.
Add a new _Make an API Call_ module: The purpose of this step is to add received WhatsApp messages as comments to the Bitrix24CRM task you've created earlier. To add this module click the + icon next to the existing _API call: create a task_ module > search for and select _Bitrix24 _ > then select _Make an API Call_
Configure the new _Make an API Call_ module:
Connection: Click the _Add _button and enter your Bitrix24 URL > click Save
URL:
task.commentitem.add
Method: POST
Headers: add a new header with key = _Content-Type_ and value= _application/json_
Body: add
[YOUR_TASKID_HERE, { "POST_MESSAGE": "YOUR_TIME_HERE message received: YOUR_MESSAGE_TEXT" }]
YOUR_TASKID_HERE must be replaced with the output data of your own _API call: create a task _module_.
YOUR_TIME_HERE and YOUR_MESSAGE_TEXT must be replaced with the output data of the original TimelinesAI webhook module. You can include additional data into the POST_MESSAGE field from your TimelinesAI Webhook if needed.
End result: TimelinesAI Webhook monitors incoming WhatsApp messages > searches Bitrix24 CRM for contact by phone number > if contact is not found > creates a new contact > creates a special task and links it to the contact > adds received WhatsApp messages as comments to the task . If the contact was found > searches whether a special task where WhatsApp messages are stored exists> if it exists adds new incoming message a comment to this task. If the task does not exist > first created a task> then adds messages as comments to that task