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://www.xsapi.bot.cd.xsmerchant.info.mp/chat_api.php

Content-Type: application/json. Authenticate using the X-API-Key header.

2. Request Parameters

FieldRequiredDescription
messageYesUser question in Bangla, English or Banglish.
api_keyHeader recommendedYour private API key. You may also send it in JSON for server-to-server testing.
{
  "message": "আপনাদের ওয়েবসাইটের নাম কী?"
}

3. PHP Example

<?php
$endpoint = 'https://www.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://www.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