Messages

Messaging is one of the core features of CometChat. We've thoughtfully created APIs to help you send and retrieve message history.

  1. Users can send messages to a user or group.
  2. No limit to the number of unread messages per user.
  3. No limit to the number of unread messages per group.
  4. Soft deleted messages will be available in the database but permanently deleted messages will not be available.

📘

Properties and constraints:

  1. The maximum File size that can be uploaded per message is 100MB.
  2. For a group with more than 300 members, the conversations and unread message counts are not updated.
  3. Delivery and read receipts will be sent for a group of up to 300 online users.
  4. Data is an arbitrary JSON structure. It accepts utf8mb4. It can have any user defined properties. but the below properties have meaning for CometChat: text, attachments, custome_data, metadata
    Note: The attachment size is separate. Here, the attachment is only the attachment properties (such as URL, size, etc.). The size must not exceed 10KB for the data object.
  5. A message can have up to 25 tags with 100 characters per tag. The tags can be in any language. The character set must be UTF8mb4.

The following table lists the properties that the Message API supports.

ParametersTypeDescription
appIdStringUnique identifier for the app
apiKeyStringAuthentication key for the app
regionStringGeographic region for the app
baseUrlStringBase URL for API requests

Interactive Messages:

Element List:

The following mentioned elements will come inside formFields key mentioned above:

1. LabelElement

{
    "elementType": "label",
    "elementId": "",
    "text": "Something to show" 
}
JSON PropertyTypeDescription
textStringRequired, text to be displayed in the label element

2. TextInputElement

{
    "elementType": "textInput",
    "elementId": "",
    "optional": false,
    "label": "name",
    "maxLines": 5, 
    "placeholder": {
        "text": "Enter digits"
    }
}
JSON PropertyTypeDescriptionDefault Value
optionalbooleanOptional, will be validated when doing the submission based on thistrue

3. ButtonElement

{
    "elementType": "button",
    "elementId": "",
    "buttonText": "Press it", 
		"disableAfterInteracted": true
    "action": {
			"url" : ""
			"method": ""  
			"payload": payload; 
			"headers":"headers";
			"dataKey":"";  
      "type": "apiAction",
      "url": "https//abc.com", 
      "payload": "", 
      "headers": ""
    }
}

a. apiAction

{
    "method": "",
    "payload": {},
    "headers": {},
    "dataKey": "",
    "actionType": "apiAction",
    "url": "https//abc.com"
}

b. urlNavigation(both fields are mandatory)

{
    "url": "<VALID URL>",
    "actionType": "urlNavigation"
}
JSON PropertyTypeDescriptionDefault Value
urlStringRequired,
actionTypeStringrequiredurlNavigation

c. DeepLinking(both fields are mandatory)

{
    "url": "<VALID URL>",
    "actionType": "deepLinkAction"
}
JSON PropertyTypeDescriptionDefault Value
urlStringRequired,
actionTypeStringrequireddeepLinkAction

d. CustomAction (only actionType is mandatory):

{
    "actionType": "customAction"
}

4. CheckboxElement

{
    "elementType": "checkbox",
    "elementId": "",
    "optional": false,
    "label": "Select multiple",
    "defaultValue": [
        "",
        ""
    ],
    "options": [
        {
            "value": "option1",
            "label": "This is option 1"
        },
        {
            "value": "option1",
            "label": "This is option 1"
        }
    ]
}
JSON PropertyTypeDescriptionDefault Value
optionalbooleanoptional,true
labelStringrequired
defaultValueArray of stringoptional

5. DropdownElement/SpinnerElement(Android)

{
    "elementType": "dropdown",
    "elementId": "",
    "optional": true,
    "label": "Select multiple",
    "defaultValue": "option1", 
    "options": [
        {
            "value": "option1", 
            "label": "This is option 1" 
        },
        {
            "value": "option1", 
            "label": "This is option 1" 
        }
    ]
}

6. RadioButtonElement

{
    "elementType": "radio", 
    "elementId": "",
    "optional": false,
    "label": "Select multiple",
    "defaultValue": "option1",
    "options": [
        {
            "value": "option1",
            "label": "This is option 1"
        },
        {
            "value": "option2",
            "label": "This is option 1"
        }
    ]
}

7. SingleSelectElement

{
    "elementType": "singleSelect",
    "elementId": "",
    "optional": false,
    "label": "Select multiple", 
    "defaultValue": "option1",
    "options": [
        {
            "value": "option1", 
            "label": "This is option 1"
        },
        {
            "value": "option2", 
            "label": "This is option 1"
        }
    ]
}

8. DateTimeElement

{
    "elementType": "dateTime",
    "elementId": "element1",
    "optional": false,
    "label": "Contact Number",
    "defaultValue": false,
    "dateTimeFormat": "Y-m-d H:i:ss",
    "mode": "date",
    "timezoneCode": "Asia/Kolkata",
    "from": "2024-06-23",
    "to": "2024-06-24"
}