Skip to main content
POST
/
bots
/
{uid}
/
messages
curl --request POST \
  --url https://{appid}.api-{region}.cometchat.io/v3/bots/{uid}/messages \
  --header 'Content-Type: application/json' \
  --header 'apikey: <api-key>' \
  --data '
{
  "receiverType": "user",
  "data": {
    "interactionGoal": {
      "type": "allOf",
      "elementIds": [
        "element8"
      ]
    },
    "allowSenderInteraction": true,
    "interactiveData": {
      "title": "Form Title",
      "formFields": [
        {
          "elementType": "textInput",
          "elementId": "element1",
          "defaultValue": "vivek",
          "label": "Name",
          "optional": false,
          "maxLines": 1,
          "placeholder": {
            "text": "write your name here"
          }
        },
        {
          "elementType": "textInput",
          "elementId": "element2",
          "label": "Last Name",
          "optional": false,
          "maxLines": 1
        },
        {
          "elementType": "textInput",
          "elementId": "element3",
          "label": "Address",
          "optional": false,
          "maxLines": 5
        },
        {
          "elementType": "dropdown",
          "elementId": "element4",
          "label": "Country",
          "optional": false,
          "defaultValue": "option1",
          "options": [
            {
              "value": "option1",
              "label": "INDIA"
            },
            {
              "value": "option2",
              "label": "AUSTRALIA"
            }
          ]
        },
        {
          "elementType": "checkbox",
          "elementId": "element5",
          "optional": true,
          "label": "Services",
          "options": [
            {
              "value": "option1",
              "label": "Garbage"
            },
            {
              "value": "option2",
              "label": "Electricity Bill"
            },
            {
              "value": "option3",
              "label": "Lift"
            }
          ],
          "defaultValue": [
            "option1",
            "option2"
          ]
        },
        {
          "elementType": "singleSelect",
          "elementId": "element6",
          "optional": false,
          "label": "Wing",
          "defaultValue": "option1",
          "options": [
            {
              "value": "option1",
              "label": "A Wing"
            },
            {
              "value": "option2",
              "label": "B Wing"
            }
          ]
        },
        {
          "elementType": "button",
          "elementId": "element9",
          "buttonText": "About us",
          "disableAfterInteracted": true,
          "action": {
            "actionType": "urlNavigation",
            "url": "https://www.cometchat.com"
          }
        }
      ],
      "submitElement": {
        "elementType": "button",
        "elementId": "element8",
        "buttonText": "Submit",
        "disableAfterInteracted": true,
        "action": {
          "actionType": "apiAction",
          "url": "https://10893f2ae68f59.api-us.cometchat-staging.com/v3.0/messages",
          "method": "POST",
          "payload": {
            "category": "message",
            "type": "text",
            "data": {
              "text": "Thanks For filling the Form!"
            },
            "receiver": "superhero2",
            "receiverType": "user"
          },
          "headers": {
            "appId": "10893f2ae68f59",
            "Content-Type": "application/json",
            "apiKey": "5797f2d3d103d7d78f085eb46bfd14d5c45ddfdf",
            "onBehalfOf": "superhero1"
          },
          "dataKey": "CometChatData"
        }
      }
    }
  },
  "category": "interactive",
  "type": "form",
  "receiver": "superhero1",
  "tags": [
    "tag1"
  ]
}
'
{
  "data": {
    "id": "1",
    "conversationId": "superhero3_user_superhero5",
    "sender": "superhero3",
    "receiverType": "user",
    "receiver": "superhero5",
    "category": "message",
    "type": "text",
    "data": {
      "text": "test     hello",
      "metadata": {
        "key1": "val1"
      },
      "entities": {
        "sender": {
          "entity": {
            "uid": "superhero3",
            "name": "Spiderman",
            "avatar": "https://data-us.cometchat.io/assets/images/avatars/spiderman.png",
            "status": "offline",
            "role": "default",
            "createdAt": 1638361550
          },
          "entityType": "user"
        },
        "receiver": {
          "entity": {
            "uid": "superhero5",
            "name": "Cyclops",
            "avatar": "https://data-us.cometchat.io/assets/images/avatars/cyclops.png",
            "status": "offline",
            "role": "default",
            "createdAt": 1638361550,
            "conversationId": "superhero3_user_superhero5"
          },
          "entityType": "user"
        }
      }
    },
    "sentAt": 1638423490,
    "updatedAt": 1638423490
  }
}

Authorizations

apikey
string
header
required

API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).

Path Parameters

uid
string
required

An UID of the Bot.

Body

application/json
receiver
string

The receiver of the message.

muid
string

The muid will be a unique Identifier of the message.

receiverType
enum<string>

The receiverType of the message. either user or group

Available options:
user,
group
category
enum<string>
default:message

Category of the message. The available categories are message and custom.

Available options:
message
quotedMessageId
string

ID of the message being quoted. If provided, the send message response will include a quotedMessage node in the response containing the referenced message object.

type
enum<string>
default:text

Type of the message. The available values are text, image, file, audio, video.

Available options:
text,
image,
file,
audio,
video
data
object

JSON containing message attributes.

multipleReceivers
object

JSON containing array of UIDs and GUID for whom the message must be sent. Format for multiple receivers - {"uids": ["uid1","uid2"], "guids":["guid1"]}

tags
string[]

A list of tags to identify specific messages.

Response

200 - application/json

Send Bot Message

data
object