Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Kr-Yogsa/ECE-BOT/llms.txt

Use this file to discover all available pages before exploring further.

POST /chat is the core endpoint of ECE-BOT. It accepts a user message, routes it through the hardware-specific intent classifier, and returns a structured reply. If the intent model’s confidence falls below 0.75, ECE-BOT automatically falls back to Gemini to generate a response. Each message is persisted to a session — either a new one created automatically from the first message, or an existing one you supply via session_id.
This endpoint requires a valid Bearer token. The active hardware assistant is determined by the session’s hardware_id (for existing sessions) or the bot selected via POST /select-bot (for new sessions).

POST /chat

Request headers

Authorization
string
required
Bearer token obtained at login. Format: Bearer <token>.
Content-Type
string
required
Must be application/json.

Request body

message
string
required
The user’s question or message. Must be a non-empty string. Leading and trailing whitespace is stripped before processing.
session_id
integer
The ID of an existing session to continue. If omitted or null, ECE-BOT creates a new session and auto-generates a title from the first message. If provided, the message is appended to that session and the session’s hardware_id overrides the currently selected bot.

Response

reply
string
required
The AI-generated response to the user’s message.
source
string
required
Which AI backend produced the reply:
  • "intent_model" — the hardware-specific intent classifier answered with confidence above 0.75.
  • "LLM" — Gemini was used as a fallback because intent confidence was at or below 0.75.
confidence
number
required
The intent model’s confidence score, rounded to four decimal places. Range: 0.01.0. When the source is "LLM", this reflects the intent model’s score that triggered the fallback (or 0.0 if the model produced no prediction).
hardware_id
string
required
The hardware assistant that handled the request (e.g., "melfa", "plc", "cnc").
session_id
integer
required
The ID of the session this message was saved to. Use this value in subsequent requests to continue the conversation.

Errors

StatusCondition
400message field is missing or empty.
401Missing or invalid Bearer token.
404The supplied session_id does not exist or belongs to another user, or no valid hardware assistant is currently selected.
503The chat service is temporarily unavailable. Retry after a short delay.
A 503 response means the underlying AI service encountered an unrecoverable error for this request. The message was not saved. Retrying the same request is safe.

How the reply source is determined

ECE-BOT first runs the user message through the hardware-specific intent classifier:
  • If confidence > 0.75 — the intent model’s matched response is returned as-is and source is "intent_model".
  • If confidence ≤ 0.75 or the model produces no prediction — Gemini receives the message along with conversation history and source is "LLM".
The confidence field always reflects the intent model’s score, regardless of which source ultimately answered.

Session auto-creation

When session_id is null or omitted, ECE-BOT derives a title from the first message by:
  1. Removing common stop words and words that match the hardware ID.
  2. Taking up to three meaningful words from the cleaned message.
  3. Prepending the hardware ID in uppercase (e.g., "CNC Error Code").
Titles are capped at 40 characters. If no meaningful words remain, the title defaults to "New chat".

Example

curl --request POST \
  --url https://your-ece-bot-host/chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "message": "What is error code E100?",
    "session_id": null
  }'
200 — intent model reply
{
  "reply": "Error code E100 indicates a servo alarm on axis 1. Check the servo amplifier status LEDs and inspect the motor encoder cable for damage.",
  "source": "intent_model",
  "confidence": 0.9231,
  "hardware_id": "melfa",
  "session_id": 42
}
200 — LLM fallback reply
{
  "reply": "Based on the MELFA documentation, you should power-cycle the controller and verify that all axis cables are seated correctly before re-enabling the servo.",
  "source": "LLM",
  "confidence": 0.4102,
  "hardware_id": "melfa",
  "session_id": 42
}
503 response
{
  "error": "Chat service is busy right now. Please try again in a moment."
}

Build docs developers (and LLMs) love