對話與訊息

發送訊息 (串流)

POST /api/chatbots/{chatbotId}/completions/

參數

參數名稱
必填
類型
說明

chatbotId

string

請求內容

請求參數

欄位
類型
必填
說明

conversation

string (uuid)

對話的唯一識別碼,如果為空則會建立新對話(可選)

message

object (含 6 個屬性: content, contentPayload, queryMetadata...)

要發送的訊息內容

message.content

string

訊息的文字內容

message.contentPayload

object

訊息的額外內容負載,JSON 格式(可選)

message.queryMetadata

object

查詢元數據,JSON 格式(可選)

message.metadata

object

訊息的環境元數據,例如時區等資訊,JSON 格式(可選)

message.attachments

array[AttachmentInput]

訊息的附件列表(可選)

message.sender

string (uuid)

發送者的 Contact ID(可選)

isStreaming

boolean

是否使用串流模式回應,預設為 false(可選)

請求結構範例

{
  "conversation"?: string (uuid) // 對話的唯一識別碼,如果為空則會建立新對話(可選) (非必填)
  "message":  // 要發送的訊息內容
  {
    "content": string // 訊息的文字內容
    "contentPayload"?: object // 訊息的額外內容負載,JSON 格式(可選) (非必填)
    "queryMetadata"?: object // 查詢元數據,JSON 格式(可選) (非必填)
    "metadata"?: object // 訊息的環境元數據,例如時區等資訊,JSON 格式(可選) (非必填)
    "attachments"?: [ // 訊息的附件列表(可選) (非必填)
      {
        "id": string (uuid) // 附件的唯一識別碼
        "type":  // 附件類型,可選值:image(圖片)、video(影片,開發中,尚未支援)、audio(音訊)、sticker(貼圖,開發中,尚未支援)、other(其他)

* `image` - Image
* `video` - Video
* `audio` - Audio
* `sticker` - Sticker
* `other` - Other
        {
        }
        "filename": string // 附件的檔案名稱
        "file": string (uri) // 附件檔案的 URL 位址
      }
    ]
    "sender"?: string (uuid) // 發送者的 Contact ID(可選) (非必填)
  }
  "isStreaming"?: boolean // 是否使用串流模式回應,預設為 false(可選) (非必填)
}

請求範例值

程式碼範例

回應內容

狀態碼
說明

200

對話回應內容,若是串流則為事件流

400

請求參數錯誤,可能原因包括:Contact ID 不屬於該組織


發送訊息 (建立)

POST /api/messages/

請求內容

請求參數

欄位
類型
必填
說明

conversation

string (uuid)

type

string

content

string

contentPayload

object

attachments

array[AttachmentCreateInput]

canvas

object

canvas.name

string

canvas.canvasType

object

canvas.title

string

canvas.content

string

queryMetadata

object

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 201

回應結構範例

回應範例值


建立新的對話

POST /api/conversations/

請求內容

請求參數

欄位
類型
必填
說明

webChat

string (uuid)

請求結構範例

請求範例值

程式碼範例

回應內容

狀態碼: 201

回應結構範例

回應範例值


取得訊息列表

GET /api/messages/

參數

參數名稱
必填
類型
說明

conversation

string

對話 ID

cursor

string

The pagination cursor value.

pageSize

integer

Number of results to return per page.

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得特定訊息

GET /api/messages/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this 訊息.

conversation

string

對話 ID

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得對話列表

GET /api/conversations/

參數

參數名稱
必填
類型
說明

cursor

string

The pagination cursor value.

inbox

string

對話平台 ID

keyword

string

關鍵字搜尋

pageSize

integer

Number of results to return per page.

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


取得特定對話

GET /api/conversations/{id}/

參數

參數名稱
必填
類型
說明

id

string

A UUID string identifying this 對話.

程式碼範例

回應內容

狀態碼: 200

回應結構範例

回應範例值


Last updated

Was this helpful?