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:
Ā
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.
Ā
Ā
Ā
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.
Ā
Ā
Ā
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:
Ā