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 POST
method. Event payloads will be delivered viaHTTP POST
requests inJSON
format. - Configure your endpoint to respond immediately to the CometChat server with a
200 OK
response.
Security
-
Authentication
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>
-
Token Based Media Access
For token-based media access, the URL for a media file follows this format:
https://files-%<REGION>%.cometchat.io/<APP_ID>/media/name.png
. Directly making anHTTP GET
request to this URL will result in a401 Unauthorized
response. When using our webhooks, you will receive this URL. To obtain a pre-signed URL, make a GET request to the same URL, includingappId
andapiKey
in the request headers.Sample request:
curl --location 'https://files-<REGION>.cometchat.io/<APP_ID>/media/audio3.mp3?redirect=0' \
--header 'appId: <APP_ID>' \
--header 'apiKey: <API_KEY>'Sample response:
{
"data": {
"url": "https://files-<REGION>.cometchat.io/<APP_ID>/media/audio3.mp3?fat=<FILE_ACCESS_TOKEN>"
}
}The
data.url
will redirect to a pre-signed URL. The pre-signed URL will be accessible for 5 min.
Webhook triggers
Triggers for Messages
Event | Description |
---|---|
message_sent | The hook triggers after the message is sent. |
message_edited | The hook triggers after the message is edited. |
message_deleted | The hook triggers after the message is deleted. |
message_delivery_receipt | The hook triggers when the client chat application confirms with Cometchat servers that a message was delivered. |
message_read_receipt | The hook triggers when the client chat application confirms with Cometchat servers that a message was read. |
message_reaction_added | The hook triggers after a user reacts to a message. |
message_reaction_removed | The hook triggers after a user un-reacts to a message. |
user_mentioned | The hook triggers after a user is mentioned in the message. |
Triggers for User-related events
Event | Description |
---|---|
user_blocked | The hook triggers when a user blocks another user. |
user_unblocked | The hook triggers when a user unblocks another user. |
user_connection_status_changed | The hook triggers after a user connects/disconnects from the websocket server. |
Triggers for Group events
Event | Description |
---|---|
group_member_banned | The hook triggers after members are banned from a group. |
group_member_unbanned | The hook triggers after members are unbanned from a group. |
group_member_scope_changed | The hook triggers if the scope of a member changes in a group. |
group_created | The hook triggers after the group is created. |
group_updated | The hook triggers after the group is updated. |
group_deleted | The hook triggers after the group is deleted. |
group_member_joined | The hook triggers after a user joins a group. |
group_member_left | The hook triggers after a user leaves the group. |
group_member_added | The hook triggers after members are added to a group. |
group_member_kicked | The hook triggers after members are kicked from a group. |
group_owner_transferred | The hook triggers if the owner of the group is changed. |
Triggers for Call & Meeting
Event | Description |
---|---|
call_initiated | The hook triggers when the call is initiated. |
call_started | The hook triggers when the call is started. |
call_participant_joined | The hook triggers when a participant joins the call. |
call_participant_left | The hook triggers when a participant leaves the call. |
call_ended | The hook triggers when the call is ended. |
meeting_started | The hook triggers when a meeting is started. |
recording_generated | The hook triggers when the recording is generated. |
meeting_participant_joined | The hook triggers when a participant joins the meeting. |
meeting_participant_left | The hook triggers when a participant leaves the meeting. |
meeting_ended | The hook triggers when the meeting is ended. |