# Inbound Webhooks

Source: https://help.channelautomation.com/flow-builder/inbound-webhooks

- [1 Create Inbound Webhook](#create-inbound-webhook)
    - [1.1 Webhook Address](#webhook-address)
    - [1.2 Example of Received JSON](#example-of-received-json)
    - [1.3 Values to Identify a User](#values-to-identify-a-user)
        - [1.3.1 Process for User Identification](#process-for-user-identification)
    - [1.4 Mapping Area](#mapping-area)
- [2 Webhook Logs](#webhook-logs)
- [3 Demo: Booking Confirmation](#demo-booking-confirmation)
 

---

Inbound webhook is a powerful tool to receive data from anywhere to the chatbot through a POST request.

With inbound webhooks, your bot can even start a conversation with a bot user who never talked to it before.

For example, when a client fills in their contact information on your website, you send the data to an inbound webhook of a chatbot, say an SMS bot. The SMS bot can then send a confirmation message to the client's phone number.

If that webhook is built in a Voice bot, the bot can even call the client right away!

Limitation - Each bot has up to 5 inbound webhooks, the rate limits is 500 request per 24 hours.

## Create Inbound Webhook

It's available in almost all channels, in your flow builder, go **Tools** - **Inbound Webhooks**:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/3f50fbe3-9d90-4061-8a4a-9833ea2867f7_1677779801.png)

Click on **New Inbound Webhook**, give a name and click **Save**:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/553c9a20-fcf6-4b84-b204-c009a8d8951c_1677779839.png)

You will see the editing interface like this:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/f5af50bc-b5e2-4b1a-b428-b98fde03884b_1677779875.png)

### Webhook Address

This area shows you where to send the data and the method, which is POST. Each inbound webhook has a unique URL in the whole Channel Automation system.

### Example of Received JSON

This area shows an example JSON for reference. It describes the structure of the data in the JSON we received later. We need it to find the values for both \*\*user identification \*\* and **data to save**.

There are 2 ways to get an example JSON:

1. manually type/paste it here
2. listen to a real-time data from a live test
 

### Values to Identify a User

Whenever the webhook receives data, it first checks the paths you specify here to see whether it can find an existing user in the chatbot.

If the user is not in the system, the chatbot will create a new profile. That's how the chatbot initiates a conversation without talking to the user before.

However, some channels don't allow the chatbot to start the conversation first due to privacy and spam issues.

For example, your SMS bot can send messages as long as you have the recipient's phone number, while your Facebook Messenger chatbot cannot send messages to a Facebook user who never talked to your bot before.

#### Process for User Identification

This is the process of how the system identifies a user:

1. check `user_ns`
    
    
    - if there is a valid `user_ns`, user found.
    - if not, next step
2. check `phone` / `email`
    
    
    - if we can find a user by the `phone` or `email`, user found.
    - if not, next step
3. verify `phone`
    
    
    - no user matched in the system, is the `phone` a valid number?
    - if yes, user profile created.
    - if not, webhook won't be processed
 

### Mapping Area

The mapping list shows which value should be stored in which custom field. When you get a sample JSON in the above area, click on **Preview Payload** to get a mapping tool.

## Webhook Logs

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inked3f45347a-0dcb-4707-9a04-b15db5f0d48c_1677779989.jpg)

Every single request is saved in **Logs**. Click on a record to see the received JSON data.

## Demo: Booking Confirmation

A perfect tool to test your inbound webhook is already built-in everywhere! Simple get a chatbot (whatever channel), test it in an **Action Step**.

Open another Channel Automation webpage side by side, keep the inbound webhook editing on Page 1 and select an external request on Page 2:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inkedcdfcf8f9-a6bb-426f-8e93-fd81a823806f_1677780032.jpg)

Follow steps 1 to 8 in the following screenshot:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inked73701b1b-e144-4ba2-8302-bed709c3a8ff_1677780078.jpg)

Provide the data that need to be sent to the chatbot and click **Test**, you must get a "webhook inactive" error since we haven't activated it yet. It's fine, click on **Done** on Page 1, and you will see the data saved:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inked28cfbfe4-d4fb-4385-8474-1fa3d6c37d51_1677780120.jpg)

Scroll down a bit, follow steps 1, 2, 3 to tell the system, where is the `phone` and `email` values in the JSON:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/f67d8ae6-cfc2-4ba7-8794-e5c28b7b0d49_1677780159.png)

Finally, map the rest data to the chatbot:

![](blob:https://uchat-com-au.atlassian.net/edb9b1e5-cd96-4550-a4aa-96ea7a1480cf#media-blob-url=true&id=c6f7f3ff-cf1b-4183-9fab-88c2b2e78a0d&collection=contentId-670138434&contextId=670138434&mimeType=image%2Fpng&name=image-20220706-031058.png&size=48060&height=486&width=1085&alt=)

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/edb9b1e5-cd96-4550-a4aa-96ea7a1480cf_1677780181.png)

**Save** your inbound webhook editing:

![](blob:https://uchat-com-au.atlassian.net/b4020f5d-3380-484d-a522-35b5fb64920b#media-blob-url=true&id=def6e3e2-7eae-4602-969b-756f277623de&collection=contentId-670138434&contextId=670138434&mimeType=image%2Fpng&name=image-20220706-031114.png&size=80115&height=679&width=1333&alt=)

 

 

 

 

 

 

 

 

 

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inkedb4020f5d-3380-484d-a522-35b5fb64920b_1677780239.jpg)

Enter the subflow, let's send a message to the bot user:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/6a5ede6c-e69d-4907-93f4-46329eaa8b49_1677780268.png)

**Publish** the flow and let's do a live test in the external request again:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inked2bad2038-b9b6-4485-95a9-35c94541d56d_1677780316.jpg)

We can see that this time it run without error because we activated the webhook and used a real phone number. Go to **Logs** and we can see a new user profile is created successfully.

On the user side:

![](https://cdn.eniston.com/bases/b65dacaf-ae39-4733-871d-f10cfe13378f/attachments/inkedda4bf046-7543-4651-be9b-23d60ae6e100_1677780388.jpg)

![](blob:https://uchat-com-au.atlassian.net/6a5ede6c-e69d-4907-93f4-46329eaa8b49#media-blob-url=true&id=04f37eb0-45fb-458e-83ee-17a83532519b&collection=contentId-670138434&contextId=670138434&mimeType=image%2Fpng&name=image-20220706-031152.png&size=105193&height=919&width=1333&alt=)
