SMS Notifications integration is possible using Twilio as a provider or a custom provider. With Custom SMS provider, you can integrate using SMS providers other than Twilio.
A user’s timezone is required to allow them to set a schedule for receiving notifications. In case the timezone is not registered, the default timezone for
For US region: EST
For EU region: GMT
For IN region: Asia/Kolkata
The timezone can be registered for a user from the SDK using the updateTimezone() method of CometChatNotifications class.
This functionality is available in the following SDK versions:
Custom provider allows you to make use of providers apart from Twilio for triggering SMS notifications. This is implemented using webhook URL which gets all the required details that can be used to trigger SMS notifications.
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 via HTTP POST requests in JSON format.
Configure your endpoint to respond immediately to the CometChat server with a 200 OK response. The response should be sent within 2 seconds of receiving the request.
For security, it is recommended to set up 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:
Enabling the “Trigger only if phone number is stored with CometChat” setting requires users’ phone numbers to be stored with CometChat using the Update Contact details API. When enabled, the webhook is triggered only for those users. If this setting is disabled, the webhook triggers regardless of whether users’ phone numbers are stored with CometChat.
The Custom provider is triggered once for an event in one-on-one conversation. In case of notifying users in a group, the custom provider is triggered once for each user present in that group.
Copy
Ask AI
{ "trigger": "sms-notification-payload-generated", "data": { "to": { "uid": "cometchat-uid-1", "phno": "+919299334134", // Optional "name": "Andrew Joseph" }, "messages": [ { "sender": { "uid": "cometchat-uid-4", "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", "name": "Susan Marie" }, "message": "Are we meeting on this weekend?" }, { "sender": { "uid": "cometchat-uid-4", "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", "name": "Susan Marie" }, "message": "📷 Has shared an image" } ], "senderDetails": { "uid": "cometchat-uid-4", "name": "Susan Marie", "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp" }, "smsContent": "You've received new messages from Susan Marie! Read them at https://your-website.com/chat." }, "appId": "app123", "region": "us/eu/in", "webhook": "custom"}