---
# System prepended metadata

title: (D8AI)機器人訊息

---

# (D8AI)機器人訊息

## 發送訊息問(D8AI)機器人格式
組成格式

> POST /mp/webhooks/native/messages/{organization}/{chatbotName}

實際使用
```URL
POST https://iqs.d8ai.ai/mp/webhooks/native/messages/iqservice/iqservice_chatbot
```

 ```json
{
  "userId": "8fcc179e-302e-4d80-9719-e61df2163a1c",
  "accessToken": "f4d7ed0f5eca2bd0449021444db50f6a24a7614d98c3fe5792c7684fdc4a592e",
  "payload": {
    "userSay": "保單延期",
    "userInfo": {
      "id": "8fcc179e-302e-4d80-9719-e61df2163a1c"
    }
  }
}
 ```
 
## 根據八維提供的資料
 | property   | type   | required | desc                                                 |
| ---------- | ------ | -------- | ---------------------------------------------------- |
| events     | array  | required |                                                      |
| chatObject | object | required | ```chatObject```                                     |
| to.userId  | string | required | format = tp-{projectId}-native-{userId from Request} |
| messages   | array  | required | array of ```message```                               |

```
{
  "events: [{
    "chatObject": {...},
    "to": {
      "userId": "tp-2-native-11037#1581565331651"
    },
    "messages": [
      {...},
      {...},
      {...}
    ]
  }]
}
```

## chatObject
| property  | type    | required | desc                                       |
| --------- | ------- | -------- | ------------------------------------------ |
| id        | string  | required | chatObject id in database                  |
| from      | string  | required | format = cb-{projectId}                    |
| roomId    | string  | required | room id in database                        |
| timeStamp | integer | required | the number of milliseconds from 1970-01-01 |

```
{
  "id": "5d46b3e1-a3cb-4bd7-b276-1d51a906fe5a",
  "from": "cb-2",
  "roomId": "eddc1552-ebd9-4bbf-bb43-fa107fd52fbd",
  "timeStamp": 1581565403332
}
```
 
## D8AI 機器人回覆

來源:Webhook

```json
{
  "events":[
    {
      "chatObject":{
        "id":"19fb4b0c-ae81-4702-8109-142701620358",
        "from":"cb-2",
        "roomId":"aac7561e-97ff-4204-9b3c-a876687fcf85",
        "timeStamp":1581929954449.0
      },
      "to":{
        "userId":"tp-2-native-8fcc179e-302e-4d80-9719-e61df2163a1c"
      },
      "messages":[
        {
          "type":"text",
          "text":"可經由以下途徑辦理：\n1.臨櫃服務：要/被保險人攜帶身分證正本及附有照片之第二證明文件(雙證件)到各分公司辦理。\n2.委託服務人員送件辦理。\n3.傳真或郵寄辦理：可來電客服專線索取、或自行上網下載申請書。\n4.網路借款：本借款方式限要、被保險人為同一人之保單且需事先約定，惟其保單號碼為TWE開頭及保單號碼為7110000010~7200000000保單之網路借款功能尚在建置中，敬請期待。\n5.ATM保單借款：本借款方式需事先約定，相關操作說明詳見CC銀行ATM保單借還款Q&A。惟其保單號碼為TWE開頭及保單號碼為7110000010~7200000000保單之ATM保單借款功能尚在建置中，敬請期待。",
          "extensions":{
            "showFeedbackButtons":false
          }
        }
      ]
    }
  ]
}

---測試----
 
 {
  "events":[
    {
      "chatObject":{
        "id":"064ccef3-e01d-497e-9b86-0786ac4f4fdd",
        "from":"cb-2",
        "roomId":"aac7561e-97ff-4204-9b3c-a876687fcf85",
        "timeStamp":1583491398571.0
      },
      "to":{
        "userId":"tp-2-native-8fcc179e-302e-4d80-9719-e61df2163a1c"
      },
      "messages":[
        {
          "type":"text",
          "text":"客戶可選擇多筆保單還款(操作時輸入身分證字號)或指定保單(操作時輸入身分證字號及指定保單號碼)還款，還款金額為自行輸入。\n還款順序為先清償全部利息，再依借款利率高低及借款時間先後逐筆清償本金。\n本公司若有保單借款專案活動 本公司若有保單借款專案活動，則依專案活動之還款順序 則依專案活動之還款順序 則依專案活動之還款順序。",
          "extensions":{
            "showFeedbackButtons":false
          }
        }
      ]
    }
  ]
}
```

## 轉成 CHATX 格式

```json
{
  "platformid":"cb-2", 
  "community_id":"aac7561e-97ff-4204-9b3c-a876687fcf85",
  "name":"chatbot",
  "message_type":"text",
  "since":"2020-02-17T16:59:14.449",
  "email":null,
  "community_pic":null,
  "content":"客戶可選擇多筆保單還款(操作時輸入身分證字號)或指定保單(操作時輸入身分證字號及指定保單號碼)還款，還款金額為自行輸入。\n還款順序為先清償全部利息，再依借款利率高低及借款時間先後逐筆清償本金。\n本公司若有保單借款專案活動 本公司若有保單借款專案活動，則依專案活動之還款順序 則依專案活動之還款順序 則依專案活動之還款順序。",
  "attachmentid":null,
  "payload":null,
  "uid":null,
  "mid":null
}
 ```
 
