-
Notifications
You must be signed in to change notification settings - Fork 10
docs: enhance webhook documentation with response structure details a… #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5ebb4ec
da9ccf4
83f83a5
248806b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
|
|
||
| <h3> | ||
| <table> | ||
| <tr> | ||
| <td><b>3 minutes read</b></td> | ||
| <td style={{ paddingLeft: '40px' }}><b>Level: Advanced </b></td> | ||
| <td style={{ paddingLeft: '40px' }}><b>Last Updated: March 2026</b></td> | ||
| <td style={{ paddingLeft: '40px' }}><b>Last Updated: June 2026</b></td> | ||
| </tr> | ||
| </table> | ||
| </h3> | ||
|
|
||
| **Webhook calls are used to communicate with third-party applications within flows. They allow NGOs to receive and handle incoming messages, delivery receipts and other events from WhatsApp in a seamless and automated manner.** | ||
|
|
||
| ___ | ||
| --- | ||
|
|
||
| ## Using Webhooks in Glific | ||
|
|
||
| Please have a look at the steps to call Webhooks in Glific. | ||
|
|
@@ -21,11 +21,11 @@ Please have a look at the steps to call Webhooks in Glific. | |
|  | ||
|
|
||
| 2. Call Webhook in a node. | ||
| 1. Choose to `Call a webhook` in the dropdown in node action. | ||
| 1. Choose `POST` in response type. | ||
| 1. Enter the `URL` where you want a Webhook connection. | ||
| 1. Click on the `Post Body` tab. | ||
| 1. Enter the variables which you want to pass through the webhook. | ||
| 1. Choose to `Call a webhook` in the dropdown in node action. | ||
| 1. Choose `POST` in response type. | ||
| 1. Enter the `URL` where you want a Webhook connection. | ||
| 1. Click on the `Post Body` tab. | ||
| 1. Enter the variables which you want to pass through the webhook. | ||
|
Comment on lines
+24
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use precise terminology for the HTTP method dropdown. Line 25 says "Choose
🤖 Prompt for AI Agents |
||
|
|
||
| ``` | ||
| { | ||
|
|
@@ -38,22 +38,18 @@ Please have a look at the steps to call Webhooks in Glific. | |
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
|  | ||
|
|
||
| 3. 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. | ||
| 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. | ||
|
Comment on lines
47
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Fix awkward heading and repetitive phrasing.
🧰 Tools🪛 LanguageTool[style] ~49-~49: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing. (REP_WANT_TO_VB) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
|  | ||
|
|
||
|
|
||
|
|
||
| For example, if you send a response like a below object | ||
|
|
||
| ``` | ||
|
|
@@ -63,17 +59,71 @@ For example, if you send a response like a below object | |
| } | ||
| ``` | ||
|
|
||
| > Please note that your webhook should always return a JSON object (not an array). | ||
| > Your webhook should return JSON. A JSON object is the simplest to work with, but arrays are also supported — see [How the response should be structured](#how-the-response-should-be-structured) below. | ||
|
|
||
| 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** | ||
| 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** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value Escape or rephrase the wildcard placeholder. The
or escape the asterisks: 🤖 Prompt for AI Agents |
||
|
|
||
|  | ||
|
|
||
| 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. | ||
|
|
||
| ## How the response should be structured | ||
|
|
||
| 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. | ||
| When your external API replies to a webhook call, Glific reads the **JSON body** of the response and saves it under your webhook's result name. A few rules decide what you can read back: | ||
|
|
||
| - **Return JSON.** Glific only parses JSON response bodies. If the body is not valid JSON, nothing is saved to the result and the call is logged as an error. | ||
| - **A JSON object is the cleanest choice.** Every key in the object becomes a value you can read with **@results.YOUR_WEBHOOK_NAME.KEY**. | ||
| - **Arrays are supported too.** If your API returns a JSON array, Glific turns it into numbered keys starting at `0` — the first item is `0`, the second is `1`, and so on. You then read an item by its number. | ||
| - **Nesting is limited to 5 parts in a path.** Glific keeps the full shape of your JSON — objects inside objects, arrays inside objects — but it can only read a path that is up to **five dot-separated parts** long. Counting `@results` and your webhook name, that leaves room to go **3 levels deep inside your response** (for example `@results.mywebhook.user.address.city`). Anything deeper is not read, so keep the values you need within that depth. | ||
|
|
||
|
Comment on lines
+70
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win Clarify what "nothing is saved" means for flow authors. Line 80 states that invalid JSON means "nothing is saved to the result and the call is logged as an error." Consider clarifying whether the flow can still continue (with an empty result) or if the webhook node itself errors and stops flow execution. This distinction matters for authors designing error-handling paths. 🤖 Prompt for AI Agents |
||
| ## Accessing nested values | ||
|
|
||
| You reach a value by writing its path after the webhook name, separating each level with a dot: | ||
|
|
||
| **@results.YOUR_WEBHOOK_NAME.LEVEL1.LEVEL2...** | ||
|
|
||
| Say your webhook is named **mywebhook** and your API returns this: | ||
|
|
||
| ```json | ||
| { | ||
| "status": "success", | ||
| "user": { | ||
| "name": "Anita", | ||
| "address": { | ||
| "city": "Mumbai", | ||
| "pincode": "400001" | ||
| } | ||
| }, | ||
| "courses": [ | ||
| { "title": "Maths", "score": 88 }, | ||
| { "title": "Science", "score": 92 } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| Here is how to read each value: | ||
|
|
||
| | You want | Use this | | ||
| | ----------------------------------------- | -------------------------------------- | | ||
| | The status | `@results.mywebhook.status` | | ||
| | The user's name | `@results.mywebhook.user.name` | | ||
| | The user's city (object inside an object) | `@results.mywebhook.user.address.city` | | ||
| | The first course title (array → item `0`) | `@results.mywebhook.courses.0.title` | | ||
| | The second course's score | `@results.mywebhook.courses.1.score` | | ||
|
|
||
| A few things to keep in mind: | ||
|
|
||
| - **A path can be at most 5 parts long.** `@results.mywebhook.user.address.city` is the deepest you can read (that is 3 levels into your response). A value buried deeper — `@results.mywebhook.a.b.c.d` — will not be read. If your data is deeper than that, flatten it in your API before returning it. | ||
| - **Array items are numbered from `0`.** The first item is always `0`, not `1`. | ||
| - **Match the keys exactly**, including upper- and lower-case. `@results.mywebhook.User.name` will not find `user`. | ||
| - **Check a value exists before you use it.** If a key is missing from the response, its path returns nothing. Use a **Wait for result** or a split node to branch on whether the value came back. | ||
|
|
||
|
Comment on lines
+117
to
+120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify exact node type names in Glific documentation or codebase
rg -n "Wait for result" docs/
rg -n "split node" docs/
rg -n "Split by" docs/ --type mdRepository: glific/docs Length of output: 9250 Update the specific node name for handling missing values. While "Wait for result" is the correct node name, "split node" is too generic and does not match the Glific UI. The precise node for branching based on workflow results is Split by a result in the flow. Replace "split node" with "Split by a result in the flow" in the guidance:
🤖 Prompt for AI Agents |
||
| :::note | ||
| Want to confirm the exact shape your API returned? Open **Webhook Logs** (below) and view the **Response JSON** for that call. Copy the key names straight from there to build your paths. | ||
| ::: | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| --- | ||
|
|
||
| ___ | ||
| ## Checking Webhook Logs | ||
|
|
||
| Once the webhook setup is complete. You can test it by executing the flow in Glific. There may a case, the webhook is not set up correctly and there are some errors in Webhook calls. | ||
|
|
@@ -84,17 +134,16 @@ Glific has **Webhook Logs** from where you can check the status of a Webhook cal | |
|
|
||
| <img width="221" alt="Screenshot 2024-03-06 at 3 13 42 PM" src="https://github.com/glific/docs/assets/141305477/179b8f35-1f72-499b-8271-9488d0eedbac" /> | ||
|
|
||
|
|
||
| 1. Webhook logs page will show the results of your webhook calls with the below details | ||
| 1. `Time` - Time of the webhook call. | ||
| 1. `URL` - The URL which is used in webhook call. | ||
| 1. `Status` - Success / Error | ||
| 1. `Status Code`- Status code returned from the webhook call. | ||
| 1. `Error` - Error is an error returned. NULL in the case of success | ||
| 1. `Method` - GET / POST | ||
| 1. `Request Header` - Request header of the webhook call | ||
| 1. `Request JSON` - JSON of the webhook call | ||
| 1. `Response JSON` - JSON response received from the webhook call. | ||
| 1. `Time` - Time of the webhook call. | ||
| 1. `URL` - The URL which is used in webhook call. | ||
| 1. `Status` - Success / Error | ||
| 1. `Status Code`- Status code returned from the webhook call. | ||
| 1. `Error` - Error is an error returned. NULL in the case of success | ||
| 1. `Method` - GET / POST | ||
| 1. `Request Header` - Request header of the webhook call | ||
| 1. `Request JSON` - JSON of the webhook call | ||
| 1. `Response JSON` - JSON response received from the webhook call. | ||
|
Comment on lines
137
to
+146
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value Fix formatting and awkward phrasing in the log fields list.
🤖 Prompt for AI Agents |
||
|
|
||
| <img width="1451" alt="Screenshot 2024-03-06 at 3 12 51 PM" src="https://github.com/glific/docs/assets/141305477/d7f9dffe-2294-42e3-9b93-8bc3bfa38c38" /> | ||
|
|
||
|
|
@@ -105,7 +154,8 @@ Glific has **Webhook Logs** from where you can check the status of a Webhook cal | |
| 1. `View` will open up the response received in a pop-up window. You can check or copy the text to know more details of the response. | ||
|
|
||
|  | ||
| ___ | ||
|
|
||
| --- | ||
|
|
||
| ## Reference Article | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Clarify the webhook description.
The current description conflates Glific's role as a WhatsApp Business API client (receiving incoming messages and delivery receipts) with the flow action "Call a webhook," which makes outbound HTTP requests from a flow to external APIs. This could confuse readers about what the webhook flow action actually does.
Consider rephrasing to focus on outbound calls to external APIs, e.g.:
🤖 Prompt for AI Agents