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