Buni.aiDocs
API referenceBots

Send a message to a chatbot (sync)

Sends one user message into a chatbot session and waits for the bot's reply. The message runs against the published (production) bot.

POST/bots/{projectId}/message

Sends one user message into a chatbot session and waits for the bot's reply. The message runs against the published (production) bot.

Requires the bot:invoke scope. Only available for chatbot projects; any other project type returns 400.

Reuse the same sessionId to continue a conversation. When you omit it, userId is used as the session ID, and when both are missing a new random session is started.

Authorization

AuthorizationBearer <token>

Authorization: Bearer bai_ext_.... Tokens belong to one project and carry scopes: bot:invoke, flow:trigger, automation:trigger.

In: header

Scope: bot:invoke

Path Parameters

projectId*string

The project ID. The token must belong to this project.

Header Parameters

x-idempotency-key?string

Up to 128 characters. A repeat of a key already used for the same project, target and mode returns the original run instead of starting a new one. Longer keys are ignored.

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/bots/string/message" \  -H "Content-Type: application/json" \  -d '{    "message": "What are your opening hours?",    "sessionId": "customer-4821",    "userId": "customer-4821",    "userName": "Ama Mensah",    "platform": "web"  }'

{  "invocationId": "clx9k2m4p0001ab12cd34ef56",  "status": "SUCCEEDED",  "result": {    "messages": [      "We are open Monday to Friday, 8am to 6pm."    ],    "actions": [],    "raw": {      "messages": [        "We are open Monday to Friday, 8am to 6pm."      ]    }  }}