# Webhook (Automation)

Description

The Webhook component facilitates real-time data transmission between applications whenever a specific event occurs. In our algorithm, the webhook acts as an input, enabling our system to receive and process data instantly upon the triggering event.

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FtHK5lSFt9HMzoyud3pce%2Fimage.png?alt=media&#x26;token=691be40a-e292-4db0-ab30-75c9b6f12dd3" alt=""><figcaption></figcaption></figure>

## Component settings&#x20;

| Parameter Name                               | Description                                                                                                                                                          |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Webhook endpoint (Test URL / Production URL) | <p>You can copy the webhook endpoint<br><br>- Test URL: Use for the flow with status "Draft."<br><br>- Production URL: Use for the flow with status "Published."</p> |
| API Key                                      | <p>You can choose API Key from the list of API Keys in your Workspace<br><br>Default value: <em>API Key created by Diaflow</em></p>                                  |
| Body                                         | You can add a key and specify whether it is required or optional.                                                                                                    |

## Use case

Here's a use case for the Webhook component: it is used to analyze a PDF document by asking, "*How to scale the B2B engine?*"

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FROKhiQvYzyjJgQ2pjlC0%2Fimage.png?alt=media&#x26;token=4b459537-495b-4295-aaff-d8187fca1082" alt=""><figcaption></figcaption></figure>

## How to Set up a Node Trigger Webhook

### **Step 1: Set Up the Node Trigger Webhook**

Setting up the node trigger webhook.\
In the **"Config"** tab, select **Type = "Webhook"**

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FdudwwnvYputuTXun5hZM%2Fimage.png?alt=media&#x26;token=1e12643b-106b-45a5-b0fb-f799bbccdf4e" alt=""><figcaption></figcaption></figure>

### **Step 2: Choose API Key**

Choose API Key from your API Keys List.

Make sure that your API Key is included in the header when calling the webhook. This security

measure helps protect your data and environment.&#x20;

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FBpzhecpJkNqidStrBJVQ%2Fimage.png?alt=media&#x26;token=499a17b8-c893-44c8-ae2a-8ad5ebdc7b6d" alt=""><figcaption></figcaption></figure>

### **Step 3: Configure the Body Fields**

Enter the values in the **Body** section. These are the data fields the system will receive from the Webhook. You can mark them as **"Optional"** or **"Required"**.

**Note:** If the system receives a Webhook request that does not contain the required fields, an error will be returned.

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2F3MoObYv9B75fRMhmuQTo%2Fimage.png?alt=media&#x26;token=ea58afbc-fb7a-44b2-b416-446cf9ed3a04" alt=""><figcaption></figcaption></figure>

### **Step 4: Preview the Webhook**

You can test the Webhook using one of the following methods:

**Recommendation**: Use **Postman** to preview the Webhook.

<https://www.postman.com/>

**Steps to Test with Postman**

* Copy the Webhook URL on Diaflow

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FLsEs0OMbu3YHU9U5UdMg%2Fimage.png?alt=media&#x26;token=74579997-8f2a-41b2-a1c4-ea25c524f42c" alt=""><figcaption></figcaption></figure>

* Open **Postman**.
* Use the **"POST"** method.
* Paste the Webhook URL.
* Go to the **"Body"** tab:
  * Select **"Raw"** format.
  * Enter the data fields (e.g., Name, Age, Gender).

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FNDDx9kRll4gljQ05Fn1L%2Fimage.png?alt=media&#x26;token=ebeb4038-bc69-416a-93ed-f0656fac8628" alt=""><figcaption></figcaption></figure>

* Click **"Send"**.
* If the response contains `"success": true`, the connection is successful. You can now use this Webhook configuration to transmit data.

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FJbXttJclm0FU7sW0UItE%2Fimage.png?alt=media&#x26;token=023083f4-c08c-4483-a6c3-59f07e26bcbf" alt=""><figcaption></figcaption></figure>
