Skip to main content

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

  1. Your webhook endpoint must be accessible over HTTPS. This is essential to ensure the security and integrity of data transmission.
  2. This URL should be publicly accessible from the internet.
  3. Ensure that your endpoint supports the HTTP POST method. Event payloads will be delivered via HTTP POST requests in JSON format.
  4. Configure your endpoint to respond immediately to the CometChat server with a 200 OK response.

Security

  1. 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>
  2. 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 an HTTP GET request to this URL will result in a 401 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, including appId and apiKey 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

EventDescription
message_sentThe hook triggers after the message is sent.
message_editedThe hook triggers after the message is edited.
message_deletedThe hook triggers after the message is deleted.
message_delivery_receiptThe hook triggers when the client chat application confirms with Cometchat servers that a message was delivered.
message_read_receiptThe hook triggers when the client chat application confirms with Cometchat servers that a message was read.
message_reaction_addedThe hook triggers after a user reacts to a message.
message_reaction_removedThe hook triggers after a user un-reacts to a message.
user_mentionedThe hook triggers after a user is mentioned in the message.
EventDescription
user_blockedThe hook triggers when a user blocks another user.
user_unblockedThe hook triggers when a user unblocks another user.
user_connection_status_changedThe hook triggers after a user connects/disconnects from the websocket server.

Triggers for Group events

EventDescription
group_member_bannedThe hook triggers after members are banned from a group.
group_member_unbannedThe hook triggers after members are unbanned from a group.
group_member_scope_changedThe hook triggers if the scope of a member changes in a group.
group_createdThe hook triggers after the group is created.
group_updatedThe hook triggers after the group is updated.
group_deletedThe hook triggers after the group is deleted.
group_member_joinedThe hook triggers after a user joins a group.
group_member_leftThe hook triggers after a user leaves the group.
group_member_addedThe hook triggers after members are added to a group.
group_member_kickedThe hook triggers after members are kicked from a group.
group_owner_transferredThe hook triggers if the owner of the group is changed.

Triggers for Call & Meeting

EventDescription
call_initiatedThe hook triggers when the call is initiated.
call_startedThe hook triggers when the call is started.
call_participant_joinedThe hook triggers when a participant joins the call.
call_participant_leftThe hook triggers when a participant leaves the call.
call_endedThe hook triggers when the call is ended.
meeting_startedThe hook triggers when a meeting is started.
recording_generatedThe hook triggers when the recording is generated.
meeting_participant_joinedThe hook triggers when a participant joins the meeting.
meeting_participant_leftThe hook triggers when a participant leaves the meeting.
meeting_endedThe hook triggers when the meeting is ended.