Webhooks
With webhooks turned on in your Sendbird application, your server will receive HTTP POST
requests from Sendbird server in the form of the response containing information on all events that occur within the application.
The webhooks can be useful when you build your own custom notification service, such as a SMS notification or an email system for your offline users.
Configuration
You can configure a webhook endpoint URL and other settings on the Settings > Desk > Webhooks on the Sendbird Dashboard.
Webhook endpoint requirements
HTTP POST
requests with JSON
payloads are sent to your webhook endpoint upon specific events in your Sendbird application.
- The endpoint must support
HTTP/1.1
andkeep-alive
. - The endpoint needs to respond to
POST
requests. - The endpoint needs to parse
JSON
payloads.
By default, Sendbird server sends an HTTP POST
request and waits for a response from your webhook endpoint for 1 second. The server sends the same POST
request up to three times until it receives a response. To avoid too many requests, you should implement the endpoint to respond immediately to the server with a 200 OK
response.
Note: When you need a process or function which handles webhook payloads, it should be implemented to be executed asynchronously from that of which responds to the server. If they are executed synchronously, it can cause the endpoint to stop working properly when many events happen on your application.
Headers
HTTP POST
requests from Sendbird server will include the following headers.
x-hub-signature
Used as a request header to ensure that the source of the request comes from Sendbird server and the request is not altered by external influences. Based on both the POST
request body and your API token, the value of the x-hub-signature
starting with sha1=
is generated by SHA-1
encryption on the Sendbird server side. To verify the request on your server side, create a comparison value exactly the same way as Sendbird server does, and then check if the result is equal to the value of the x-hub-signature
.
Data structure
All webhook events depend on the following data structure.
List of properties
Property name | Type | Description |
---|---|---|
id | int | The unique ID of the webhook. |
project | nested object | An object that contains information of the project. |
project.id | int | The unique ID of the project which consists of integers. |
project.pid | string | The unique ID of the project which consists of random characters. |
eventType | string | The type of the event. |
data | nested object | An object that contains information about the webhook. |
dataType | string | The type of the data. Valid values are TICKET or AGENT_CONNECTION_LOG. |
createdAt | string | The date and time when the webhook was created, in ISO 8601 format. |
createdBy | String | The subject who created the webhook. Valid values are limited to the following: |
Webhook events
Ticket events
Event | Triggered when |
---|---|
A ticket is created. | |
The status of a ticket is updated. | |
A ticket is closed. | |
The information of a ticket is updated. This webhook is sent only when the customer satisfaction rating of the ticket is updated. | |
An agent sends a confirmation request message to a customer for ticket closing. | |
A customer agrees to close a ticket. | |
A customer declines to close a ticket. | |
A ticket is transferred. |
Agent's connection log events
Event | Triggered when |
---|---|
A connection log is created due to a change of the connection status of an agent. |
TICKET.CREATED
The following shows a webhook payload of a TICKET.CREATED
event.
TICKET.STATUS.UPDATED
The following shows a webhook payload of a TICKET.STATUS.UPDATED
event.
TICKET.CLOSED
The following shows a webhook payload of a TICKET.CLOSED
event.
TICKET.UPDATED
The following shows a webhook payload of a TICKET.UPDATED
event. This event is sent only when the customer satisfaction rating of the ticket is updated.
TICKET.MESSAGE.CLOSE_CONFIRMATION
The following shows a webhook payload of a TICKET.MESSAGE.CLOSE_CONFIRMATION
event.
TICKET.MESSAGE.CLOSE_CONFIRMATION.CONFIRMED
The following shows a webhook payload of a TICKET.MESSAGE.CLOSE_CONFIRMATION.CONFIRMED
event.
TICKET.MESSAGE.CLOSE_CONFIRMATION.DECLINED
The following shows a webhook payload of a TICKET.MESSAGE.CLOSE_CONFIRMATION.DECLINED
event.
TRANSFER.CREATED
The following shows a webhook payload of a TRANSFER.CREATED
event.
AGENT_CONNECTION_LOG.CREATED
The following shows a webhook payload of a AGENT_CONNECTION_LOG.CREATED
event.