Search...
Menu

Send Message

API Description

Create an agent message and add it to a specific conversation using the conversation ID.
Only conversations created via API are supported.


Request URL

Copy
POST https://api.helpbots.ai/api/chats/message

Request Headers

Parameter Name Type Required Description
x-api-key string Yes User’s API Key for authentication

Request Parameters (JSON Body)

Parameter Name Type Required Description
id int Yes The agent ID associated with the message
conversation_id string Yes The conversation ID where the message belongs
question string array Yes
stream boolean No Whether to enable streaming mode. Default: true
extra_params object No Extra parameters for third-party partners

Examples for "question":


Response Description

The response "message_type" indicates what kind of message was triggered.
Supported types:

  • 0 – AI Q&A
  • 1 – Image Search
  • 2 – FAQ Match

AI Q&A Request Example

Copy
curl --location --request POST 'https://api.helpbots.ai/api/chats/message' \
--header 'x-api-key: yourapikey' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": 1,
  "conversation_id": "64xalvljy2jrasyxxxx",
  "question": [{"type":"text","text":"question"}],
  "extra_params": {
    "scene_type": "customer_service",
    "scene_data": {
      "project_id":"1",
      "conversation_id":"1",
      "chat_user_id":"uid"
    }
  }
}'

Streaming Response Example

json Copy
// AI response
data: {"choices":[{"delta":{"content":"关于","role":"assistant"},"index":0}],"created":1752140585,"id":"021752140583993817f2a48b003f7ed02744c0aecf079de74a6e2","model":"deepseek-v3-250324","service_tier":"default","object":"chat.completion.chunk","usage":null}
json Copy
//Source documents used for the response
data: {"object":"source","source":[{"resource_id":32,"resource_type":1,"content_id":1835,"title":"今天星期几?","content":"今天星期五","score":0.4715660354961766,"resource_url":"http://10.101.****/common/system/redirect?resource_id=32&resource_type=1"}]}
json Copy
//End
data: [DONE]  

Non-Streaming Response Example

Copy
{
  "data": {
    "model": "deepseek-v3-250324",
    "question": "Question",
    "answer": "Answer",
    "usage": {
      "completion_tokens": "331",
      "prompt_tokens": "5698",
      "total_tokens": "6029",
      "prompt_tokens_details": { "cached_tokens": "0" },
      "completion_tokens_details": { "reasoning_tokens": "0" }
    },
    "source": [
      {
        "resource_id": "50",
        "resource_type": "1",
        "content_id": "28392",
        "title": "Ape",
        "sub_title": "Origin of Apes",
        "content": "Excerpt",
        "score": "0.74227011203766",
        "index": "1",
        "extra_data": {},
        "resource_url": "https://testing-api.helpbots.ai/common/system/redirect?doc_id=28392&doc_type=article",
        "record_id": "2248",
        "add_time": "1752140719"
      }
    ],
    "object": "chat",
    "message_type": "0"
  },
  "msg": "Success",
  "code": 200
}
Copy
curl --location --request POST 'https://api.helpbots.ai/api/chats/message' \
--header 'x-api-key: yourapikey' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": 18,
  "conversation_id": "kh07y73amutqwb5d2273vf65",
  "question": [{"type":"goods_image","goods_image":"https://xxx.com/a.png"}]
}'

Streaming Response Example

Copy
data: {"source":[{"resource_id":"1","resource_type":"4","content_id":"1","title":"SHOP3","sub_title":"","content":"","extra_data":{"id":"DD003","goods_name":"Product Name","goods_link":"https://example.com","original_price":"93","sale_price":"46.4","currency":"CNY","desc":"Product Description","main_image":"main_image.png","image1":"image1.png","image2":"image2.png"},"score":"0.69207616495632","resource_url":"","record_id":"2099","add_time":"1751374304"}],"message_type":"1"}

Non-Streaming Response Example

Copy
{
  "data": {
    "source": [
      {
        "resource_id": "1",
        "resource_type": "4",
        "content_id": "1",
        "title": "SHOP3",
        "sub_title": "",
        "content": "",
        "extra_data": {
          "id": "DD003",
          "goods_name": "Product Name",
          "goods_link": "https://example.com",
          "original_price": "93",
          "sale_price": "46.4",
          "currency": "CNY",
          "desc": "Product Description",
          "main_image": "main_image.png",
          "image1": "image1.png",
          "image2": "image2.png"
        },
        "score": "0.69207616495632",
        "resource_url": "",
        "record_id": "2099",
        "add_time": "1751374304"
      }
    ],
    "message_type": "1"
  },
  "msg": "Success",
  "code": 200
}

FAQ Match Request Example

Copy
curl --location --request POST 'https://api.helpbots.ai/api/chats/message' \
--header 'x-api-key: yourapikey' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": 18,
  "conversation_id": "kh07y73amutqwb5d2273vf65",
  "question": [{"type":"text","text":"FAQ matching question"}]
}'

Streaming Response Example

Copy
data: {"message_type":"2","data":[{"type":"text","value":"Message 1"},{"type":"text","value":"Message 2"}]}

Non-Streaming Response Example

Copy
{
  "data": {
    "message_type": "2",
    "data": [
      { "type": "text",      "value": "Message 1" },   # text message
      { "type": "image",     "value": "https://xxxxx.com/x.png" },   # image message
      { "type": "attachment","value": "https://xxxxx.com/x.docx" }   # attachment message
    ]
  },
  "msg": "Success",
  "code": 200
}
Previous
View Conversation List
Next
View Message List
Last modified: 2025-10-28SaleSmartly