Skip to main content

Send Bot Message

info

Advanced API is available in the Business Plan.

Use this endpoint to send a message using the bot in a specific chat room. You can also send action buttons, when the action button is pressed a webhook will be triggered to the bot webhook URL.


POST
https://api.deadsimplechat.com/consumer/api/v2/bot/:botId/chatroom/:roomId/message?auth=YOUR_SECRET_KEY

Request

POST /consumer/api/v2/bot/:botId/chatroom/:roomId/message?auth=YOUR_SECRET_KEY

Query Parameters

ParameterDescriptionData TypeRequired
authGo to Dashboard -> Developer -> Private Key is your authStringYes

Request Body

The request payload should be a JSON object containing the following fields:

FieldDescriptionData TypeRequiredConstraints
userIdUnique User IDStringNo
uniqueUserIdentifierUnique Identifier for the UserStringNoNone
messageIdID of the message to which bot will replyStringNo
messageText of the message to sendStringYesMax Length: 1000
actionButtonsArray of action buttonsArrayNoNone

Action Button Object Schema

FieldDescriptionData TypeRequiredConstraints
displayTextText to display on the buttonStringYesMax Length: 100
idButton IDStringYesMax Length: 100
imageURLURL of the imageStringNoMust be a valid HTTPS URL
iconURLURL of the iconStringNoMust be a valid HTTPS URL
typeType of button ('link' or 'action')StringYesEither 'link' or 'action'
urlURL for the link buttonStringConditionalMust be a valid URL (required if type is 'link')
payloadAny additional payload dataStringNoMax Length: 1000

Responses

Success Response

HTTP Status: 200 OK

Body:

{
"success": true,
"message": "message sent"
}

Error Responses

  • Invalid Request:

    HTTP Status: 400 Bad Request

    Body:

    {
    "success": false,
    "message": "invalid request",
    "error": "<Validation Error Details>"
    }
  • Bot Not Found or Unauthorized:

    HTTP Status: 400 Bad Request

    Body:

    {
    "success": false,
    "message": "Bot not found or the user does not have permission to access the bot"
    }
  • Chat Room Not Found:

    HTTP Status: 400 Bad Request

    Body:

    {
    "success": false,
    "message": "ChatRoom not found or user does not have permission to access"
    }

Code Examples

curl

curl -X POST 'https://api.deadsimplechat.com/consumer/api/v2/bot/BOT_ID/chatroom/ROOM_ID/message?auth=YOUR_SECRET_KEY' \
-H "Authorization: YOUR_API_KEY" \
-d '{
"userId": "USER_ID",
"message": "Hello, this is a bot message",
"actionButtons": [
{
"displayText": "Click Me",
"id": "click_me",
"type": "action",
"payload": "payload_data"
}
]
}'

JavaScript (Fetch API)

fetch('https://api.deadsimplechat.com/consumer/api/v2/bot/BOT_ID/chatroom/ROOM_ID/message?auth=YOUR_SECRET_KEY', {
method: 'POST',
headers: {
'Authorization': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
userId: 'USER_ID',
message: 'Hello, this is a bot message',
actionButtons: [
{
displayText: 'Click Me',
id: 'click_me',
type: 'action',
payload: 'payload_data'
}
]
})
})