Skip to main content

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.

  1. Receive the response from a contact in a variable.

image

  1. Call Webhook in a node.
    1. Choose to Call a webhook in the dropdown in node action.
    2. Choose POST in response type.
    3. Enter the URL where you want a Webhook connection.
    4. Click on the Post Body tab.
    5. Enter the variables which you want to pass through the webhook.
{
"contact": "@contact",
"results": "@results",
"Emp_name": "Mohit"
"Emp_age": "@results.age.input"
}

image

image

  1. Click OK to save the changes

Use webhook response in the flows.

  1. Let's say you make a webhook call (by using the above steps) and you want to use the response variable in the flow.

image

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

image

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.