建立對話與訊息
建立對話
建立一個新的對話。
端點: https://api.maiagent.ai/api/v1/conversations
請求方法: POST
請求標頭:
Authorization: Api-Key <您的API金鑰>
Content-Type: application/json請求內容:
「Web Chat ID」請由「AI 助理」詳細頁面最下方取得
{
"webChat": "String" // Web Chat ID
}請求範例:
import requests
response = requests.post(
url='https://api.maiagent.ai/api/v1/conversations/',
headers={
'Authorization': 'Api-Key <您的API金鑰>'
},
json={
'webChat': '您的 Web Chat ID'
}
)回應內容:
若是要用於串接訊息,只需要將「ID」記下來。對話「ID」能取得整個對話中的所有訊息,也能用於透過「對話 ID」來知道目前訊息 Webhook 是在哪一個對話內。
傳送訊息
建立一則新訊息
端點: https://api.maiagent.ai/api/v1/messages/
請求方法: POST
請求標頭:
請求內容:
請求參數說明:
conversation
string
是
對話的唯一識別碼
content
string
是
要發送的訊息內容
attachments
array
否
附件陣列,預設為空陣列 []
附件物件欄位說明
id
string
是
附件的唯一識別碼
type
string
是
附件的類型
filename
string
是
附件的檔案名稱
file
string
是
附件的URL
請求範例:
Python 範例
cURL 範例
回應格式:
收到回應代表訊息建立成功,回覆的訊息會以 Webhook 的方式提供,請參考 Webhook 章節
回應範例:
回應欄位說明
id
string
訊息唯一識別碼 (UUID)
conversation
string
對話唯一識別碼 (UUID)
sender
object
發送者資訊物件
sender.avatar
string
發送者頭像網址
type
string
訊息類型 (incoming/outgoing)
content
string
訊息內容
feedback
object
null
createdAt
string
訊息建立時間戳記
attachments
array
附件清單
citations
array
引用來源文件列表
citationNodes
array
引用來源節點列表
訊息類型說明
incoming: 收到的訊息outgoing: 發送的訊息
Last updated
Was this helpful?
