How to use Webhooks in Glific
For a detailed setup process, you can go to the below article https://glific.github.io/slate/#webhooks
You can check the recipe link below for code examples to use webhook. https://github.com/glific/recipes
Some Glific steps with screenshots for your reference.
- Receive the response from a contact in a variable.
- Call Webhook in a node.
- Choose to
Call a webhook
in the dropdown in node action. - Choose
POST
in response type. - Enter the
URL
where you want a Webhook connection. - Click on the
Post Body
tab. - Enter the variables which you want to pass through the webhook.
- Choose to
{
"contact": "@contact",
"results": "@results",
"Emp_name": "Mohit"
"Emp_age": "@results.age.input"
}
- Click
OK
to save the changes
Use webhook response in the flows.
- Let's say you make a webhook call (by using the above steps) and you want to use the response variable in the flow.
For example, if you send a response like a below object
{
"success_message" : "You are onboarded.",
"status_code": 200
}
Please note that your webhook should always return a JSON object (not an array).
Then you can use that response as @results.mywebhook.success_message Or if you want to use any other variable then it will be @results.mywebhook.*YOUR_RESPONSE_OBJECT_KEY
Here my webhook is a custom name you defined on your webhook node and success_message is the key of the response object you send back in a webhook call.