Title1

Title2

Title3

5-2 Line Bot 樣版

發送回覆訊息

  1. 參考:https://developers.line.biz/en/reference/messaging-api/#send-reply-message
  2. 格式化程式碼:shift + alt + F
  3. 架構:
    
    /*============================================
      Line Bot 回覆
    ============================================*/
    function lineReplyMessage(replyToken, replyMessage) {
      //-----------------------------------回傳訊息給line 並傳送給使用者  
      let url = 'https://api.line.me/v2/bot/message/reply';
      try {
        UrlFetchApp.fetch(url, {
          'headers': {
            'Content-Type': 'application/json; charset=UTF-8',
            'Authorization': 'Bearer ' + CHANNEL_ACCESS_TOKEN,
          },
          'method': 'post',
          'payload': JSON.stringify({
            'replyToken': replyToken,
            'messages': replyMessage
          }),
        });
      } catch (e) {
        //---------------------------------- 記錄Line Bot 回覆 錯誤訊息
        let formData = {
          sn: '',
          timestamp: '',
          type: 'Line Bot 回覆 錯誤訊息',
          code: e
        }
        insert_sheet_record(formData);
        //---------------------------------- 記錄Line Bot 回覆 錯誤訊息 end
      }
      //---------------------------------------回傳訊息給line 並傳送給使用者 end
    }

     

  4.  請比對 replayMessage
    陣列 包 物件(最多5組)
    [
            {
                "type":"text",
                "text":"Hello, user"
            },
            {
                "type":"text",
                "text":"May I help you?"
            }
        ]


     

Line Bot 樣版

  1. 訊息類型
    1. 文字
    2. 圖片
      {
        "type": "image",
        "originalContentUrl": "https://example.com/original.jpg",//實際圖片網址
        "previewImageUrl": "https://example.com/preview.jpg"//縮圖網址
      }
      link to https://developers.line.biz/en/reference/messaging-api/#image-message \
    3. flex
      [
          {
            "type": "flex",
            "altText": "This is a Flex Message",
            "contents": {
              "type": "bubble",
              "body": {
                "type": "box",
                "layout": "horizontal",
                "contents": [
                  {
                    "type": "text",
                    "text": "Hello,"
                  },
                  {
                    "type": "text",
                    "text": "World!"
                  }
                ]
              }
            }
          }
        ]
      link to https://developers.line.biz/en/docs/messaging-api/using-flex-messages/#sending-messages-with-the-messaging-api \
  2. flex樣版網站
  3. 從Showcase,找一個輪播樣版(Local Search)

Action

  1. uri
       {
            "type": "button",
            "style": "primary",
            "color": "#905c44",
            "margin": "xxl",
            "action": {
              "type": "uri",
              "label": "action",
              "uri": "http://linecorp.com/"
            }
          }
  2. message
     {
            "type": "button",
            "style": "primary",
            "color": "#905c44",
            "margin": "xxl",
            "action": {
              "type": "message",
              "label": "action",
              "text": "hello"
            }
          }
  3.