2. Chat with the Chatbot

Chat with the Chatbot

POST /api/v1/backend/chatbot/{bot_uid}/chat

The Chat API enables programmatic interaction with chatbots through a POST request. This API is accessible to users with a paid subscription and facilitates communication with chatbots.

Path Parameters

  • bot_uid (string, required): The unique ID of the chatbot with which you intend to engage in conversation.

Body Parameters

Content-Type of the request should be set to application/json

  • q (string, required): The question you want to pose to the chatbot.

  • conversation_uid (string, optional): The session ID for the chat. Note that you should not manually construct a session ID. After conversing with the chatbot, a session ID will be returned. If you wish to continue the same session, you can pass this session ID in subsequent interactions.

  • language (string, optional, default is auto): The desired language for chatting with the chatbot. Currently supports English, French, Spanish, Russian, Simplified Chinese, and more. Refer to the table below for language codes.

  • stream (boolean, optional, default is False): Indicates whether to enable streaming output.

Returns

Normal

{
  "code": 0,
  "data": {
    "answer": "answer",
    "conversation_uid": "f05f1800-a728-4e23-adb8-69abd55b5dcb",
    "is_qa_mode": true,
    "question": "Ut minim ex",
    "system_message": ""
  },
  "msg": "Success.",
  "request_id": "25a40914-d8d9-4b0f-a92d-b8844bfc9852"
}

Stream

{"answer": "", "question": "Ut minim ex", "related_docs": [], "conversation_uid": "9628808a-dbb6-42c3-aba6-9fe5b772c724", "is_qa_mode": true, "system_message": ""}
645130146e8d07b175fd8b1d5682d520answer

Data

  • answer (string): The chatbot's response to the question.

  • conversation_uid (string): The session ID for the current conversation.

  • is_qa_mode (boolean): Indicates whether it's in QA mode (QA mode provides references to answers).

  • question (string): The user's posed question.

  • system_message (string): System-generated message for displaying system notifications.

Note: In streaming mode, the response data is separated by the magic number "645130146e8d07b175fd8b1d5682d520" Before this magic number is a JSON string, and after the magic number is the actual answer.

Language Codes

CodeNameNative NameRemark

auto

Auto

Auto

Automatically determines language based on input

en

English

English

fr

French

Français

es

Spanish

Español

ru

Russian

Русский

zh-Hans

Simplified Chinese

中文 (简体)

zh-Hant

Traditional Chinese

中文 (繁體)

ar

Arabic

العربية

de

German

Deutsch

jp

Japanese

日本語

pt

Portuguese

Português

hi

Hindi

हिंदी

ko

Korean

한국어

it

Italian

Italiano

uk

Ukrainian

Українська

Last updated