API Chat Channel
When this partner addon is enabled, the client’s workspace will be able to set webhook for api chat channel.
Please reach out to UChat support for this channel.
 Instructions
Initial setup
Enable partner addon, Api Chat
set api chat webhook for workspace through partner api, the webhook url need to be verified
bot_url from the set api chat webhook response, will be used to send messages from bot user
check example payload for different type of messageswhen bot reply or agent reply, the message payload will be sent to provided api chat webhook url with signature in the header
 Partner Api to get/set/remove webhook
You need to use your partner api key for authentication
- Get webhook
GET {{baseUrl}}/api/partner/workspace/{{workspace_id}}/apichat-webhook
Request body: (empty)
Sample response,
{
"status": "ok",
"data": {
"webhook_url": "https://your-webhook-url/",
"webhook_verification_key": "VERIFICATION_TOKEN",
"webhook_status": "verified",
"bot_url": "https://bot.dfktv2.com/api/apichat/{{unique_code_to_bot}}"
}
}
Â
- Set webhook
Request body:
Note: three parameters will be sent to your webhook url via POST
hub_mode
: the value will be “subscribe
"
hub_verify_token
: the value will be the same value from your request body “webhook_verification_key“, as the sample above, the value will be VERIFICATION_TOKEN
hub_challenge
: the value will be random string, e.g. 205c40409f9bcdeb9e00614b442c5fdd
Â
You need to verify the verification key and return the text response output with the content from parameter hub_challenge
as body, e.g. 205c40409f9bcdeb9e00614b442c5fdd
Â
Â
Sample response, (success)
Â
Â
- Remove webhook
Request body: (empty)
Sample response,
Â
Â
Â
 Workspace Api to send messages
You need to use your flow api key for authentication, requires manage flow permission
- Send Text Message
Request body:
Â
- Send Button Payload
Request body:
Â
- Send Image
Request body:
Â
- Send Audio
Request body:
Â
Â
- Send Video
Request body:
Â
Â
- Send File
Request body:
Â
Â
Â
 Webhook payload
When the bot or agent send a message, your webhook url l receive the message payload. For each request, you can check the following headers.
Sample php code to verify the payload signature
Â
- Receive Text Message
Â
- Receive Button Template
Â
- Receive Generic Template (Card/Carousel)
Â
- Receive Image Message
Â
- Receive Audio Message
Â
- Receive Video Message
Â
- Receive File Message
Â