How to create flows for your campaigns with Webhooks step by step
In this article, we will explain step by step how to create flows for your campaigns with Webhooks in Atom.
Flow Assembly with Webhooks
First, we will access our Flowbuilder section in Campaigns. For this, you will go to the left side menu > Campaigns > Flows > Create Flow.
Then we will selectCreate Flow from Scratch. We select the number from which our campaign will be sent and there we enter Flowbuilder where we will begin to diagram our campaign with Webhooks. Our trigger in this case will beWebhook.
For the Webhook configuration, remember that you must have the URL and the fields corresponding to the POST request and, if additional information fields are required, the default required field will always be the "phone" field.
If you want to add additional information fields, you can do so by clicking on the “+” icon and there you can add it directly as shown below, and then add it to the POST method request that we visualize above. Keep in mind that, if you have not created it previously, you must do so as explained in thefollowing article.
Suppose that later we will send a template with specific information. To be able to send any campaign, it is necessary that you have previously created a template. For this, you must first connect the template component to the Webhook component, as we show you below:
If you need to create a template, you can create it in our Configurations > Messaging > Templates section, or you can also take advantage of theCreate Templatesfunctionality within Flowbuilder as we indicate in this other article.
After choosing a template, you can continue adding the components that you consider to complete the flow. For more information about the components of a flow you can seethis article.
Once the workflow is complete, copy the input parameters of the Webhook. You can do it in two different ways:
Before publishing the workflow, double-click on the Webhook component and then on "Show POST request" in the right panel. In the detail of the POST request you will find between {} symbols the parameters (keep in mind that you must replace the values "Data to send" with the one that corresponds".
Example:
Another option you have to copy the input parameters once the flow has been published and is in the 'Active' state, are the following: Select the flow with webhook on the 'Webhooks' screen within the Campaigns module and execute the action 'View flow':
Select the flow with webhook on the 'Webhooks' screen within the Campaigns module and execute the action 'View flow':
In the workflow viewer, click on the 'Copy information fields' button that is inside the webhook component:
In the workflow viewer, click on the 'Copy information fields' button that is inside the webhook component:
Example:
{
"phone": "",
"company_name": "",
"fecha_cita": "",
"monto": "",
"name": ""
}
After finalizing the creation of the workflow with webhook, save it and publish it so that you can use it.
The webhook component has two buttons to speed up its subsequent operation:
Button 1 allows you to copy the URL of the webhook, while button 2 can be used to copy the information fields in JSON format.
Keep in mind the following information about the parameters of an ATOM webhook.
Every ATOM webhook has, by default, as a mandatory input parameter the phone number (phone) of the destination of the flow messages.
You must enter the phone number (“phone“) by prefixing the “+“ sign and the area code of your country, without using hyphens or spaces.
However, if templates with their own custom fields are inserted in the flow, all of them will become mandatory input parameters of the webhook.
On the other hand, Atom allows including other parameters in the webhook through custom fields, as shown below:
To view the required fields of a webhook:
Go to the flow editor in the Campaigns module.
Click on the Webhook component.
On the right side of the screen, a panel will be displayed where you can view the required fields.
Test your flow
Once you have a flow with a created and published webhook, you can simulate and evaluate its execution. For this, the API testing tool called Postman will be used.
Below you will see the step by step to simulate a flow with webhooks in Postman:
Go to the Campaigns module.
Click on the webhooks submodule.
3. Go to the flow with the webhook you want to test and click the URL icon to copy it and use it in Postman.
4. Next, complete the following parameters in Postman:
Headers
Content-Type: application/json
Authorization: Bearer xxxxx, where xxxxx is the API token that must be obtained in the My Company → Security configuration submodule
💡Important: when using a webhook, authentication through the API token is mandatory. On the other hand, keep in mind that if you already have one generated and decide to generate a new one, you have to replace the new one in all those Atom webhooks and APIs that you have in use.
Body
Format: raw
Write the parameters in JSON format, eg:
{
"phone": "5795755112756",
"client_name": "Martin Lopez"
}
All parameters must be inserted in string format, that is, between double quotes (“”).
When using ATOM webhooks you may encounter the following codes
| Scenario |
Scenario
| Response code |
Response code
| Response body |
Response body
| Successful delivery |
Successful delivery
| 200 - Ok |
200 - Ok
| {"message":"Webhook executed successfully"} |
{"message":"Webhook executed successfully"}
| Non-existent token |
Non-existent token
| 401 - Unauthorized |
401 - Unauthorized
| No authorization token found. |
No authorization token found.
| Incorrect token |
Incorrect token
| 404 - Not Found |
404 - Not Found
| Cannot find a company with uuidToken = xxxxxxx |
Cannot find a company with uuidToken = xxxxxxx
| Required parameter |
Required parameter
| 500 - Internal Server Error |
500 - Internal Server Error
| {"message": "The parameter xxxx is required","hasErrors": true} |
{
"message": "The parameter xxxx is required",
"hasErrors": true
}
| Try to simulate an active flow |
Try to simulate an active flow
| 500 - Internal Server Error |
500 - Internal Server Error
| {"message":"The contact is simulating a flow.","hasErrors":true} |
{
"message":"The contact is simulating a flow.",
"hasErrors":true
}
Define the triggers of your CRM or ERP that will execute the flow with the created webhook. It is important that you configure both the URL and the parameters of the ATOM webhook in them.
Once you have evaluated and approved the interaction between your CRM or ERP and the ATOM webhook, make your flow productive.
Using the http component to return the data of a flow
Alternatively, you have the possibility of returning the data used in a flow through the POST method of HTTP request.
For this, the “HTTP Request” component will be used in the design of the workflow. Next, we will see its configuration:
In the ATOM workflow editor, insert the “HTTP Request” component.
As method you must choose: “POST”.
Insert the URL to which the data of the custom fields used in the flow will be sent.
Activate the field to insert the fields in the Request Body, by sliding the Body button.
5. The information fields must be inserted in JSON format. Keep in mind that both the field identifier and its value (the information field) must be in double quotes (“).
To choose the information field that captures the data, press the / (slash) key which will display a list with all the information fields available to insert.
6. Proceed to simulate the execution of the flow to evaluate the sending of the data.
Below, we present an example of a simulation of a flow that contains an “HTTP Request” component:
We generate a flow with an HTTP request with the following parameters:
The “name” field is an input parameter of the flow while the “identification” field captures the client's response in WhatsApp
We start the simulation of the flow through the POSTMAN tool:
The client receives and answers the following on WhatsApp:
We can see how the client's last response is stored in the “Identification” field:
Later, we can choose different logics, analysis of intentions with artificial intelligence to then define what you want the bot to execute.
For example, we can send a message where, for example, if the client answers that they want to schedule an appointment in this case, derive it to the attention of a group of advisors, or otherwise we will tag it to know that they are not interested in this campaign at the moment.
IMPORTANT:
If you use Webhooks to send notifications through flows, keep in mind that, if there is an active conversation being attended by an advisor, the component will previously verify this condition and suspend its execution so as not to interfere with the personalized attention that is being provided.
RELATED ARTICLES:
How to create a campaign