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

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

EventDescription
before_messageThe endpoint will be triggered when a message is in-flight.
after_messageThe endpoint will be triggered after a message is sent.
message_delivery_receiptThe endpoint will be triggered when a message is marked delivered.
message_read_receiptThe endpoint will be triggered when a message is marked read.
EventDescription
user_connection_status_changeThe endpoint will be triggered when a users logs in or logs out of CometChat.