Reference API
L'API AISupportBot vous permet d'envoyer des questions a votre assistant configure et de recevoir des reponses IA basees sur votre base de connaissances. Ideal pour integration dans votre bot Discord, application web ou backend.
Authentication
All Enterprise API requests must include your API key in the request header.
Chat Endpoint
Send a message to your assistant and receive an AI-generated response.
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
| assistantId | string | required | Your assistant's ID (found in the dashboard URL). |
| message | string | required | The user's message / question. |
| history | array | optional | Previous messages for context. Array of {role, content}. Max 15 messages kept. |
| userId | string | optional | Your user's identifier (for logging). |
| channelId | string | optional | Discord channel ID if the question came from a specific channel. |
| userContext | object | optional | JSON object with user-specific data injected into the AI prompt. Max 4KB. More details β |
Minimal Request
curl -X POST https://aisupportbot.io/api/chat \
-H "X-API-Key: ask_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"assistantId": "clz1abc...",
"message": "How do I reset my password?"
}'User Context
The userContext field lets you pass any JSON object about the asking user.
The AI will use this data to personalize its response β addressing
the user by name, referencing their account state, plan, stats,
etc.
π‘ Perfect for platforms with user data
If you're integrating into a game, SaaS, or community platform, pass relevant data like balance, tier, or recent activity. The AI will reference it naturally when it's relevant to the question.
Example β Bot Hosting Platform
{
"assistantId": "clz1abc...",
"message": "Why is my bot offline?",
"userId": "discord_123456",
"userContext": {
"username": "NikolaB",
"plan": "pro",
"servers": [
{ "name": "MyBot", "status": "offline", "uptime": "98.2%" }
],
"coins": 450,
"memberSince": "2024-03-15"
}
}The AI will respond to "Why is my bot offline?" with something like:
Constraints
- β Any valid JSON object is accepted
- β Nested objects and arrays are supported
- β Max size: 4 KB β requests with larger payloads will be rejected
- β The data is read-only context β the AI cannot modify it
Response Schema
All successful responses return 200 OK with a JSON body.
{
"response": "The reset link is sent to your registered emailβ¦",
"requiresEscalation": false,
"usage": {
"prompt_tokens": 312,
"completion_tokens": 48,
"total_tokens": 360
}
}| Field | Type | Description |
|---|---|---|
| response | string | The AI-generated answer. May be an empty string if escalation was triggered. |
| requiresEscalation | boolean | true when
the AI isn't confident enough to answer. You
should route the user to a human agent. |
| usage | object | Token counts for the request (prompt + completion). Useful for cost monitoring. |
Error Codes
All errors return a JSON body with an error field and optional details.
{
"error": "Plan limit reached",
"details": "Upgrade to get more responses. (1000/1000)"
}Examples
Full working examples for common use cases.
JS JavaScript / TypeScript
const askBot = async (message, user, history = []) => {
const res = await fetch('https://aisupportbot.io/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'ask_your_key_here',
},
body: JSON.stringify({
assistantId: 'clz1abc...',
message,
history,
userId: user.id,
userContext: {
username: user.name,
plan: user.plan,
coins: user.coins,
servers: user.servers,
},
}),
});
const data = await res.json();
if (data.requiresEscalation) {
return { reply: "I'll connect you with a human agent.", escalate: true };
}
return { reply: data.response, escalate: false };
};Py Python
import requests
API_KEY = "ask_your_key_here"
ASSISTANT_ID = "clz1abc..."
def ask_bot(message, user_context=None):
response = requests.post(
"https://aisupportbot.io/api/chat",
headers={
"X-API-Key": API_KEY,
"Content-Type": "application/json"
},
json={
"assistantId": ASSISTANT_ID,
"message": message,
"userContext": user_context,
}
)
data = response.json()
if data.get("requiresEscalation"):
return "Escalating to a human agent."
return data["response"]Handling Escalation
When requiresEscalation is true, the AI couldn't
find a confident answer. You should redirect the user to a
human support channel rather than showing an empty or
incorrect response.
β Open a ticket in your Discord server
β Redirect
to a #support channel
β Send a DM to on-call staff
β Don't show
the empty response string
to users
Questions about the API? Join our Discord support server.