Overview
Webhooks faciliate real-time event-driven communication with your system, enabling you to receive HTTP POST requests from CometChat that carry details about different events. Utilizing webhooks is beneficial for creating customized services, such as SMS or email notifications, etc.
Webhook endpoint requirements
- Your webhook endpoint must be accessible over
HTTPS. This is essential to ensure the security and integrity of data transmission. - This URL should be publicly accessible from the internet.
- Ensure that your endpoint supports the
HTTP POSTmethod. Event payloads will be delivered viaHTTP POSTrequests inJSONformat. - Configure your endpoint to respond immediately to the CometChat server with a
200 OKresponse.
Security
It is recommended to set up a Basic Authentication that is usually used for server-to-server calls. This requires you to configure a username and password. Whenever your webhook URL is triggered, the HTTP Header will contain:
Authorization: Basic <Base64-encoded-credentials>
Webhook triggers
Triggers for Messages
| Event | Description |
|---|---|
| before_message | The endpoint will be triggered when a message is in-flight. |
| after_message | The endpoint will be triggered after a message is sent. |
| message_delivery_receipt | The endpoint will be triggered when a message is marked delivered. |
| message_read_receipt | The endpoint will be triggered when a message is marked read. |
Triggers for User-related events
| Event | Description |
|---|---|
| user_connection_status_change | The endpoint will be triggered when a users logs in or logs out of CometChat. |