logo
開發者文件
搜尋
人工服務

人工服務

當開發者選擇 Webhook(網路回呼)作為人工服務接入方式 時,需先於伺服器環境中建置 Webhook 服務。開發者需依據規範提供以下三種介面,以接收人工服務請求、用戶訊息及人工客服回覆訊息。同時,GPTBots 也提供兩種介面,供接收客服回覆訊息及對話關閉指令。

重要注意事項:

  1. 開發者必須確保 Webhook 服務運作正常,因其直接影響人工支援服務運作狀態。
    • 若啟用人工支援後顯示「忙碌」,則表示開發者的 Webhook 服務 異常
    • 若啟用人工支援後顯示「連接中」,則表示開發者的 Webhook 服務 正常運行
  2. 成功啟用人工支援服務請求後:

接收人工服務對話請求通知

當終端用戶發起人工服務請求時,GPTBots 會將該請求轉發至開發者的 Webhook 服務。介面服務回應狀態碼為 200,表示成功建立人工服務對話。

請求方法

POST

端點

https://your_domain/conversation/establish

請求範例

curl -X POST 'https://YOUR_DOMAIN/human/service/conversation/establish' \ -H 'Content-Type: application/json' \ -d '{ "body": [ { "text": "human service", "message_type": "QUESTION" }, { "text": "", "message_type": "ANSWER" } ], "timestamp": 1742265090895, "email": "bob@gmail.com", "conversation_id": "67d8db020fa31d1ef64f53dg", "bot_id": "665d88b03ce2b13cf2d573454", "user_info": { "phone": null, "email": "bob@gmail.com", "user_id": "KDslas", "anonymous_id": "652face5184b30540a6ea7fe" } }'
                      
                      curl -X POST 'https://YOUR_DOMAIN/human/service/conversation/establish' \
-H 'Content-Type: application/json' \
-d '{
  "body": [
    {
      "text": "human service",
      "message_type": "QUESTION"
    },
    {
      "text": "",
      "message_type": "ANSWER"
    }
  ],
  "timestamp": 1742265090895,
  "email": "bob@gmail.com",
  "conversation_id": "67d8db020fa31d1ef64f53dg",
  "bot_id": "665d88b03ce2b13cf2d573454",
  "user_info": {
    "phone": null,
    "email": "bob@gmail.com",
    "user_id": "KDslas",
    "anonymous_id": "652face5184b30540a6ea7fe"
  }
}'

                    
此代碼塊在浮窗中顯示

注意:此請求主體中的 conversation_id 僅用於標識人工服務對話場景的唯一 ID,與 建立對話 ID 中的智能代理(Agent)對話場景生成的唯一 ID 不同。

請求參數

參數 類型 描述
conversation_id string 人工客服場景的對話 ID(與智能代理對話 ID 不同),需於客服回覆介面中傳遞至 GPTBots
timestamp long 時間戳
email string 用戶電子郵件,部分人工服務系統需電子郵件以正常提供服務
bot_id string 智能代理(Agent)ID
body list<Object> 訊息主體
body.message_type string 訊息類型,QUESTION/ANSWER
body.text string 用戶向人工客服發起的問題及上下文
user_info object 用戶資訊
user_info.phone string 用戶電話號碼,目前僅於 WhatsApp 切換至人工客服時可用
user_info.email string 用戶電子郵件,當用戶輸入其電子郵件時可用
user_info.user_id string 用戶 ID,企業開發者自訂的用戶唯一標識,針對特定匿名 ID 設定
user_info.anonymous_id string 匿名 ID,當用戶於非 API 渠道平台與智能代理互動時,系統依據渠道平台自動生成

email 欄位注意事項:

  • 透過 iframe/Share/Bubble Widget 發起人工服務時,需填寫用戶電子郵件。開發者亦可自訂用戶 email 以免用戶輸入。
  • 透過 WhatsApp/Telegram/即時聊天等第三方平台請求人工服務時,預設 email 為 support@gptbots.ai。即時聊天可自訂 email。
  • 透過 API 請求人工服務時,email 欄位可為空,預設 email 為 support@gptbots.ai

回應

參數 類型 描述
code int 回應碼
message string 詳細資訊

聊天介面

使用已建立的 conversation_id,將用戶訊息傳送至人工客服。

請求方法

POST

端點

https://your_domain/chat

請求參數

參數 類型 描述
conversation_id string 對話 ID,需於客服回覆介面傳遞至 GPTBots
timestamp long 時間戳
body string 用戶訊息

回應

參數 類型 描述
code int 回應碼
message string 詳細資訊

關閉對話介面

當用戶對話逾時或智能代理用戶主動關閉對話時,調用此介面關閉對話。

請求方法

POST

端點

https://your_domain/conversation/close

請求標頭

欄位 類型 描述
Authorization Bearer ${token} 使用 Authorization: Bearer ${token} 進行身份驗證,從 API 金鑰頁面取得 token。
Content-Type application/json 資料類型,設為 application/json。

請求參數

參數 類型 描述
conversation_id string 對話 ID,需於客服回覆介面傳遞至 GPTBots
timestamp long 時間戳
type string 關閉類型,TIMEOUT(逾時關閉)/ USER_CLOSED(用戶主動關閉)

回應

參數 類型 描述
code int 回應碼
message string 詳細資訊

回覆用戶訊息

當開發者選擇 webhook 作為人工服務整合方式時,GPTBots 提供回覆用戶訊息介面,讓人工客服可將訊息內容回傳給用戶。

請求方法

POST

端點

https://api-${endpoint}.gptbots.ai/v1/human/message/receive

請求標頭

欄位 類型 描述
Authorization Bearer ${token} 使用 Authorization: Bearer ${token} 進行身份驗證,從 API 金鑰頁面取得 token。
Content-Type application/json 資料類型,設為 application/json。

請求參數

參數 類型 描述 必填
conversation_id string 對話 ID,於對話建立及聊天介面傳遞,直接帶入即可 true
timestamp long 時間戳 true
body string 人工客服回覆內容 true

回應

參數 類型 描述
code int 回應碼
message string 詳細資訊

人工客服主動關閉對話

當開發者選擇 webhook 作為人工服務接入方式時,GPTBots 所提供的人工客服可於需要時主動關閉對話。關閉後,除非用戶再次發起人工客服對話,否則不會再收到客服訊息。

請求方法

POST

端點

https://api-${endpoint}.gptbots.ai/v1/human/close

請求標頭

欄位 類型 描述
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key} 進行身份驗證,從 API 金鑰頁面取得 API Key。
Content-Type application/json 資料類型,設為 application/json。

請求參數

參數 類型 描述
conversation_id string 對話 ID,需於客服回覆介面傳遞至 GPTBots
timestamp long 時間戳

回應

參數 類型 描述 必填
conversation_id string 對話 ID,於對話建立及聊天介面傳遞,直接帶入即可 true
timestamp long 時間戳 true