Create Bot
info
Advanced API is available in the Business Plan
Create a new bot for chat rooms. This endpoint allows for customization of bot behaviors, including triggers and message visibility.
POST
https://api.deadsimplechat.com/consumer/api/v2/bot
Request
POST /consumer/api/v2/bot
Query Parameters
Parameter | Description | Data Type | Required |
---|---|---|---|
auth | Go to Dashboard -> Developer -> Private Key is your auth | String | Yes |
Body Parameters
Parameter | Description | Data Type | Required | Constraints |
---|---|---|---|---|
name | The name of the bot | String | Yes | |
description | Brief description of the bot's functionality | String | No | Max 1000 characters |
trigger | Event that will trigger the bot (message or mention ) | String | No | One of message , mention |
messageVisibility | Visibility of bot's messages (public or private ) | String | No | One of public , private |
isAllowedInAllChatRooms | Whether the bot is allowed in all chat rooms | Boolean | No | |
messageHistoryLimit | Limit to the number of historical messages accessible by the bot | Number | No | |
webhookURL | The URL for the bot's webhook | String | Yes | Must be a valid URI |
metadata | Additional metadata in JSON format | String | No | Max 10000 characters |
enabled | Whether the bot is enabled or disabled | Boolean | No |
Responses
Success Response
A JSON object containing the following field:
Field | Description | Data Type |
---|---|---|
_id | The unique ID of the created bot | String |
HTTP Status: 200 OK
Body:
{
"success": true,
"bot": { /* Updated bot object */ }
}
Error Responses
Validation Error:
HTTP Status:
400 Bad Request
Body:
{
"success": false,
"message": "invalid request",
"error": "Detailed error description"
}Trigger and Visibility Conflict:
HTTP Status:
400 Bad Request
Body:
{
"success": false,
"message": "Error: Bots cannot be configured to trigger on every message when message visibility is set to private. Either change the bot trigger to \"mention\" or set the message visibility to \"public\"."
}
Code Examples
curl
curl -X POST "https://api.deadsimplechat.com/consumer/api/v2/bot?auth=<YOUR_API_KEY>" -H "Content-Type: application/json" -d '{"name": "MyBot", "description": "This is my bot"}'
JavaScript (Fetch API)
fetch("https://api.deadsimplechat.com/consumer/api/v2/bot?auth=<YOUR_API_KEY>", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
name: "MyBot",
description: "This is my bot"
})
})