Dashboard

Send Message

Send a message to your chatbot and receive an AI response

POST
5 min read

Endpoint Details

Send a chat message and receive an AI-powered response

HTTP Method & URL

POST https://your-domain.com/api/v1/chatbots/{chatbotId}/chat

Path Parameters

chatbotId

The unique identifier of the chatbot (required)

string

Request Body

JSON payload with your message and options

Example Request

{
  "message": "Hello, how can you help me?",
  "conversationId": "cm5abc123xyz456",
  "stream": true,
  "metadata": {
    "source": "mobile_app",
    "userId": "user_123"
  }
}

Required Fields

message

The user's message to send to the chatbot

string

Optional Fields

conversationId

Continue an existing conversation

string
stream

Enable streaming response (SSE)

boolean
metadata

Custom metadata for the request

object

Streaming Behavior

If stream is provided, it overrides the chatbot's default setting. If not provided, the chatbot's configured streaming preference is used.

Response Formats

Different response formats based on streaming mode

Success Response (200)

{
  "success": true,
  "data": {
    "response": "Hello! I'm here to help you. What would you like to know?",
    "conversationId": "cm5abc123xyz456",
    "messageId": "cm5msg789def012"
  }
}

Continue Conversation

Use the returned conversationId in your next request:

{
  "message": "Tell me more about that",
  "conversationId": "cm5abc123xyz456"
}

Error Responses

Common error codes and their meanings

401
Authentication Error
{
  "success": false,
  "error": "Invalid or inactive API key",
  "code": "INVALID_API_KEY"
}
404
Chatbot Not Found
{
  "success": false,
  "error": "Chatbot not found or access denied",
  "code": "CHATBOT_NOT_FOUND"
}
429
Rate Limit Exceeded
{
  "success": false,
  "error": "Rate limit exceeded. Please wait before sending another message.",
  "code": "RATE_LIMIT_EXCEEDED",
  "retryAfter": 60
}
402
Insufficient Credits
{
  "success": false,
  "error": "Insufficient credits to generate AI response. Please upgrade your plan.",
  "code": "INSUFFICIENT_CREDITS"
}

Code Examples

Ready-to-use examples in popular languages

# Non-streaming request
curl -X POST https://your-domain.com/api/v1/chatbots/{chatbotId}/chat \
  -H "Authorization: Bearer sk-workspace_xxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Hello, how can you help me?"
  }'

# Streaming request
curl -X POST https://your-domain.com/api/v1/chatbots/{chatbotId}/chat \
  -H "Authorization: Bearer sk-workspace_xxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Hello!",
    "stream": true
  }' --no-buffer

Rate Limiting

Rate limits are configured per chatbot. Check your chatbot's settings for the specific limits. The response headers include rate limit information:

X-RateLimit-LimitMaximum requests allowed
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the limit resets
    PollyBot.ai - Smart Conversations, Seamless Automation