Summary
Webhooks in Wati's Chatbot Builder allow you to send and receive real-time data between your chatbot and external applications using GET or POST API requests. This feature enables dynamic chatbot interactions, such as fetching user details, verifying data, or integrating with third-party services. Note: The Webhook feature is available only in the Pro & Business plans. If you're on the Standard plan, you can create and save chatbots with webhooks, but you will need to upgrade to use them in Keyword Action or Default Action workflows.
Instructions
Advanced Chatbot Builder is available in the Pro & Business Plan only.
How to Use Webhooks in Chatbot Builder
1. Adding a Webhook to Your Chatbot
Open the Wati Chatbot Builder.
Drag and drop the Webhook icon into the chatbot workflow.
Connect it to a relevant chatbot step.
2. Configuring the Webhook Node
URL & Method
Choose a request method:
GET
orPOST
.Enter the URL endpoint of the external API.
Make the URL dynamic by inserting variables using the Variables button. Example:
https://webhook-wa-testing.clare.ai/123456789?name=##{{name}}
Customize Headers
Headers provide additional request details, such as content type or authorization.
Headers are optional and turned off by default.
Headers follow a key-value format. Example:
Key =
Content-Type
Value =
application/json
Customize the Body
The request body contains data sent to the external API.
The body is optional and turned off by default.
It must always be in JSON format.
Set Your Test Variables
Define test variables manually to simulate API responses during setup.
3. Testing the Webhook Request
Click Test the Request to verify if the API call works correctly.
4. Saving API Responses as Variables
You can store responses from the API into variables or custom attributes.
If the API returns a JSON response with key-value pairs, you can extract and store specific values. Example: Storing
"result": "success"
from an API response:
json { "result": "success"}
Storing Values Inside an Object
Use the format:
objectKey.keyName
.Example: To store
QuoteId
from the response below, useResult.QuoteId
.
json { "Result": { "QuoteId": "xxxxx", "QuoteNumber": "xxxxxx", "PolicyNumber": null }, "MessageValidation": null, "QuoteReferrals": null}
Storing Values Inside an Array of Objects
Use the format:
$.[0].objectKey.keyName[0].value
.Example: To store
current_status
, use$.[0].tracking_data.shipment_track[0].current_status
.
json [ { "tracking_data": { "track_status": 1, "shipment_track": [ { "id": 1278937320, "current_status": "Delivered" } ] } }]
5. Using Response Routing
Response routing allows you to split chatbot actions based on response status codes.
You can define different chatbot flows depending on the API response.
By integrating Webhooks, you can enhance chatbot functionality with external data, automate workflows, and improve user interactions dynamically.
Frequently Asked Questions (FAQs)
General Questions
1. What is a webhook in Wati's Chatbot Builder?
→ A webhook is a mechanism that allows your chatbot to send and receive real-time data from external applications using GET or POST API requests. This enables dynamic interactions, such as fetching user details, verifying data, or integrating with third-party services.
2. Who can use webhooks in the Chatbot Builder?
→ The webhook feature is available only in the Pro & Business plans. If you are on the Standard plan, you can create and save chatbots with webhooks but will need to upgrade before using them in Keyword Action or Default Action workflows.
Setup and Configuration
3. How do I add a webhook to my chatbot?
→ To add a webhook:
Open the Wati Chatbot Builder.
Drag and drop the Webhook icon into the chatbot workflow.
Connect it to a relevant chatbot step.
4. What are the request methods available in webhooks?
→ You can choose between:
GET: Retrieves data from an external source.
POST: Sends data to an external API.
5. Can I customize the webhook request URL?
→ Yes. You can insert variables into the URL using the Variables button to make the request dynamic. Example:https://webhook-wa-testing.clare.ai/123456789?name=##{{name}}
Customizing Webhooks
6. How do I add headers to my webhook request?
Headers are optional and are turned off by default.
They are set in key-value pairs. Example:
Key:
Content-Type
Value:
application/json
7. How do I customize the body of a webhook request?
The body is optional and is off by default.
It must always be in JSON format.
8. What are test variables, and why should I use them?
→ Test variables allow you to manually define values to simulate an API response during setup. This helps ensure that your webhook is configured correctly before deployment.
Handling API Responses
9. How can I save API responses as variables?
If an API response is in JSON format with key-value pairs, you can store the values by referencing the keys. Example: To store
"result": "success"
, use:
json { "result": "success"}
Advanced Features
10. What is response routing?
→ Response routing allows you to split chatbot actions based on response status codes. You can define different chatbot flows depending on the API response.
11. Can I trigger different chatbot flows based on API responses?
→ Yes. By setting up response routing, you can create multiple chatbot flows that activate based on the API's status code or specific response values.