Inbound Webhook

 

Webhooks are a powerful feature in UChat that allows you to integrate your own platform with UChat's chat automation. This is useful if you have your own live chat platform and want to leverage UChat's automation features without directing users to the UChat interface.

 

Who should use Webhooks?

 

Webhooks are designed for developers who have their own platform and some experience working with APIs.

 

How to set up Webhooks in UChat

 

Here's a step-by-step guide on how to set up webhooks in UChat:

 

  1. Set up your Webhook URL:

 

  • Go to Integrations and then Webhooks.

  • You can optionally set up your own headers for additional security.

  • Provide a Webhook URL where you want to receive the data.

 

 

 

  1. Enable Webhooks in your Channel Settings:

 

  • Go to the channel settings for the chat you want to integrate with your platform (e.g., WhatsApp, SMS).

  • Under Live Chat Settings, select Webhook.

 

 

 

  1. Use the Pause the Bot Action:

 

  • In your UChat flow, include the Pause the Bot action where you want the conversation to switch to your platform.

  • When a user interacts after this point, the message will be sent to your Webhook URL.

 

Sample Payload

 

The data UChat sends to your Webhook URL is a JSON payload that includes various details about the message and conversation. Here's a breakdown of the sample payload in the image:

  • meta

 

  • user_ns: This is a unique identifier for the user.

  • agent_id: This is the ID of the agent currently assigned to the conversation (0 indicates no assigned agent).

  • flow_ns: This is a unique identifier for the chat flow.

  • team_id: This is the ID of the team the chat belongs to.

 

 

  • message

 

  • _id: This is a unique identifier for the message.

  • mid: This is a unique identifier for the message within the channel.

  • type: This indicates the type of message (e.g., "in" for incoming message).

  • msg_type: This specifies the message content type (e.g., "text").

  • sender_id: This is the ID of the message sender.

  • agent_id: This is the ID of the agent who received the message (0 indicates no assigned agent).

  • assigned_agent_id: This is the ID of the agent assigned to the conversation after the message was received.

  • payload

    • text: This contains the text content of the message.

  • content: This also contains the text content of the message.

  • username: This is the username of the message sender.

  • date: This shows the date the message was sent.

  • timestamp: This is the timestamp of the message in milliseconds.

  • ts: This is another timestamp representation of the message.

  • is_delivered: This indicates whether the message was delivered (1 means delivered).

  • seen: This field is empty in the sample payload but can indicate if the message was seen.

 

 

Using the UChat API

 

Once you capture the user message in your platform, you can use the UChat API to send a response back to the user within the chat conversation. The UChat API uses the user_ns and flow_ns from the payload to identify the conversation and send the message.

 

Additional Considerations

 

  • Webhooks are a powerful tool but require development expertise.

  • UChat supports various message types, and the payload will reflect the content type (text, image, etc.).

  • Leverage the UChat API to communicate back and forth between your platform and UChat users.

 

By following these steps and understanding the payload data, you can successfully set up webhooks to integrate your own platform with UChat's automation features.

 

Video Tutorial here:

 

https://www.youtube.com/watch?v=0qjHaUoniPo