iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 13
0
Modern Web

用Vue實作一個LINE@聊天機器人後台系列 第 13

[Day13] 寫一個基本的WebHook(四):完成WebHook設定

  • 分享至 

  • xImage
  •  

取得https的網址後,需要再次回到Line Developer後台設定WebHook的URL:
相關的設定在Messaging settings這個區塊裡面
Imgur
在填入網址後,必須按下Verify驗證網址的可用性
按下驗證後,LINE將會傳送像這樣的訊息來Call你的Webhook:

{
  "destination": null,
  "events": [
    {
      "replyToken": "00000000000000000000000000000000",
      "type": "message",
      "timestamp": 1560397869724,
      "source": {
        "type": "user",
        "userId": "Udeadbeefdeadbeefdeadbeefdeadbeef",
        "groupId": null
      },
      "message": {
        "id": "100001",
        "type": "text",
        "text": "Hello, world",
        "contentProvider": null,
        "duration": null,
        "fileName": null,
        "fileSize": null,
        "title": null,
        "address": null,
        "latitude": null,
        "longitude": null,
        "packageId": null,
        "stickerId": null
      },
      "joined": null,
      "left": null,
      "postback": null,
      "beacon": null,
      "link": null,
      "things": null
    },
    {
      "replyToken": "ffffffffffffffffffffffffffffffff",
      "type": "message",
      "timestamp": 1560397869724,
      "source": {
        "type": "user",
        "userId": "Udeadbeefdeadbeefdeadbeefdeadbeef",
        "groupId": null
      },
      "message": {
        "id": "100002",
        "type": "sticker",
        "text": null,
        "contentProvider": null,
        "duration": null,
        "fileName": null,
        "fileSize": null,
        "title": null,
        "address": null,
        "latitude": null,
        "longitude": null,
        "packageId": "1",
        "stickerId": "1"
      },
      "joined": null,
      "left": null,
      "postback": null,
      "beacon": null,
      "link": null,
      "things": null
    }
  ]
}
  • userId 全部都是UdeadbeefdeadbeefdeadbeefdeadbeefXD
    驗證通過後,會顯示Success
    如果一直無法驗證通過,可以用上面的JSON使用POSTMAN之類的工具看一下可能是出現了什麼問題
  • Use webhooks 也要記得打開

上一篇
[Day12] 寫一個基本的WebHook(三):透過SSL for Free申請SSL憑證
下一篇
[Day14] 訊息設計工具:LineBotDesigner
系列文
用Vue實作一個LINE@聊天機器人後台30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言