Developer Documentation
Universal Chatbot API
Send a question and receive an answer from the knowledge base configured for your API account.
1. Endpoint
POST https://xsapi.bot.cd.xsmerchant.info.mp/chat_api.php
Content-Type: application/json. Authenticate using the X-API-Key header.
2. Request Parameters
| Field | Required | Description |
|---|---|---|
message | Yes | User question in Bangla, English or Banglish. |
api_key | Header recommended | Your private API key. You may also send it in JSON for server-to-server testing. |
{
"message": "আপনাদের ওয়েবসাইটের নাম কী?"
}3. PHP Example
<?php
$endpoint = 'https://xsapi.bot.cd.xsmerchant.info.mp/chat_api.php';
$apiKey = 'YOUR_API_KEY';
$payload = json_encode(['message' => 'আপনাদের ওয়েবসাইটের নাম কী?']);
$ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-API-Key: '.$apiKey],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_TIMEOUT => 20
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result['data']['reply'] ?? $result['message'];
?>4. JavaScript Example (server-side recommended)
const response = await fetch('https://xsapi.bot.cd.xsmerchant.info.mp/chat_api.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-Key': 'YOUR_API_KEY' },
body: JSON.stringify({ message: 'Hello, what services do you offer?' })
});
const result = await response.json();
console.log(result.data?.reply || result.message);Do not expose a private API key in public browser JavaScript. Call this API from your own backend.
5. Success Response
{
"status": true,
"data": {
"reply": "আমাদের ওয়েবসাইটের নাম Example Store।",
"matched": true,
"language": "auto"
}
}6. Important Behaviour
- Each API key has an independent request quota and expiry.
- Each account has its own isolated knowledge base and brand details.
- Unknown questions return a configured support fallback; the API does not invent answers.
- This included engine is knowledge-base matching, not a generative LLM. Add question/answer entries in your dashboard.
- HTTP errors include 400 (missing fields), 401 (invalid key), 403 (blocked/expired), and 429 (quota exhausted).