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
Parameter | Description | Data Type | Required |
---|---|---|---|
auth | Go to Dashboard -> Developer -> Private Key is your auth | String | Yes |
Request Body
The request payload should be a JSON object containing the following fields:
Field | Description | Data Type | Required | Constraints |
---|---|---|---|---|
userId | Unique User ID | String | No | |
uniqueUserIdentifier | Unique Identifier for the User | String | No | None |
messageId | ID of the message to which bot will reply | String | No | |
message | Text of the message to send | String | Yes | Max Length: 1000 |
actionButtons | Array of action buttons | Array | No | None |
Action Button Object Schema
Field | Description | Data Type | Required | Constraints |
---|---|---|---|---|
displayText | Text to display on the button | String | Yes | Max Length: 100 |
id | Button ID | String | Yes | Max Length: 100 |
imageURL | URL of the image | String | No | Must be a valid HTTPS URL |
iconURL | URL of the icon | String | No | Must be a valid HTTPS URL |
type | Type of button ('link' or 'action') | String | Yes | Either 'link' or 'action' |
url | URL for the link button | String | Conditional | Must be a valid URL (required if type is 'link') |
payload | Any additional payload data | String | No | Max 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'
}
]
})
})