/*============================================
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
}
[
{
"type":"text",
"text":"Hello, user"
},
{
"type":"text",
"text":"May I help you?"
}
]
{
"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 \
[
{
"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 \
{
"type": "button",
"style": "primary",
"color": "#905c44",
"margin": "xxl",
"action": {
"type": "uri",
"label": "action",
"uri": "http://linecorp.com/"
}
}
{
"type": "button",
"style": "primary",
"color": "#905c44",
"margin": "xxl",
"action": {
"type": "message",
"label": "action",
"text": "hello"
}
}