您可以發送多種不同 HTTP 請求方法,讓機器人解析您的伺服器回應並回覆訊息。
具體而言,您將可以執行:
創建動態訊息
執行 postbacks
取得並設定使用者參數(即將到來)
轉向其他節點(即將到來)
我們將解析您回傳的 JSON,以此為根據發送訊息給您的顧客。更多訊息請參考 LINE API 文件。
以下回應將發送文字訊息。
{"messages": [{"type": "text","text": "歡迎使用最聰明的聊天機器人平台 —— YOCTOL.AI"},{"type": "text","text": "您打算創建怎樣的機器人呢?"}]}
目前圖片格式支援 JPG,以下回應將發送圖片訊息。
{"messages": [{"type": "image","originalContentUrl": "https://example.com/original.jpg","previewImageUrl": "https://example.com/preview.jpg"}]}
以下回應將發送影片檔案。目前 LINE 僅支援 10MB 以下、1 分鐘以內的 MP4 檔網址。
{"messages": [{"type": "video","originalContentUrl": "https://example.com/original.mp4","previewImageUrl": "https://example.com/preview.jpg"}]}
以下回應將發送語音檔案;目前 LINE 僅支援 10MB 以下、1 分鐘以內的 M4A 語音檔網址。
{"messages": [{"attachment": {"type": "audio","payload": {"url": "https://ccrma.stanford.edu/~jos/mp3/bachfugue.mp3"}}}]}
以下回應將發送貼圖。目前 LINE 支援的貼圖清單。
{"messages": [{"type": "sticker","packageId": "1","stickerId": "1"}]}
以下回應將發送按鈕。您可以設定各個按鈕的動作,例如打開網站。更多關於按鈕的用法,請參考 LINE 按鈕。
{"messages": [{"type": "template","altText": "This is a buttons template","template": {"type": "buttons","thumbnailImageUrl": "https://example.com/bot/images/image.jpg","imageAspectRatio": "rectangle","imageSize": "cover","imageBackgroundColor": "#FFFFFF","title": "Menu","text": "Please select","defaultAction": {"type": "uri","label": "View detail","uri": "http://example.com/page/123"},"actions": [{"type": "postback","label": "Buy","data": "action=buy&itemid=123"},{"type": "postback","label": "Add to cart","data": "action=add&itemid=123"},{"type": "uri","label": "View detail","uri": "http://example.com/page/123"}]}}]}
另外您也可以傳送特殊按鈕,例如打開相機。
{"messages": [{"type": "template","altText": "This is a buttons template","template": {"type": "buttons","text": "Please select","actions": [{"type": "camera","label": "Camera"},{"type": "cameraRoll","label": "Camera roll"}]}}]}
以下回應將發送快速回覆。
{"messages": [{"type": "text","text": "Did you enjoy the last game of the CF Rockets?","quickReply": {"items": [{"type": "action","action": {"type": "cameraRoll","label": "Send photo"}},{"type": "action","action": {"type": "camera","label": "Open camera"}}]}}]}