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
}
}Sends Message from a Bot.
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
}
}API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
An UID of the Bot.
The receiver of the message.
The muid will be a unique Identifier of the message.
The receiverType of the message. either user or group
user, group Category of the message. The available categories are message and custom.
message 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 of the message. The available values are text, image, file, audio, video.
text, image, file, audio, video JSON containing message attributes.
Show child attributes
JSON containing array of UIDs and GUID for whom the message must be sent. Format for multiple receivers - {"uids": ["uid1","uid2"], "guids":["guid1"]}
Show child attributes
A list of tags to identify specific messages.
Send Bot Message
Was this page helpful?