Home>

var LINE_TOKEN = "token";
var LINE_URL ='https://api.line.me/v2/bot/message/reply';

function doPost(e) {

// parse to Json
var json = JSON.parse(e.postData.contents);
// Get the response token
var replyToken = json.events[0].replyToken;
// Create a reply message
var reply = null;
// get the message
if(json.events[0].message.type =='text'){
var userMessage = json.events[0].message.text;
}

if(userMessage == "specified character"){

var babbleMsgs = [];
for(var i=0 ;i<3 ;i++){
var babbleMsg = {
"type": "bubble",
"hero": {
"type": "image",
"url": "Image URL",
"size": "full",
"aspectRatio": "4:3",
"aspectMode" :"cover",
"backgroundColor": "#f0f0f0"
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "a",
},
{
"type": "text",
"text": "b",
}
]
},
babbleMsgs.push(babbleMsg);
}
var reply = {
"type": "flex",
"altText" :"this is a carousel message",
"contents" :{
"type": "carousel",
"contents": babbleMsgs
}
};
someMessage(reply,replyToken);
}
}
}

function someMessage(text,place) {
var headers = {
'Content-Type':'application/json;charset=UTF-8',
'Authorization':'Bearer' +LINE_TOKEN
};

var payload = JSON.stringify({
'replyToken': place,
'messages': text
})

var options = {
'headers': headers,
'method' :'post',
'payload': payload };

// reply message
UrlFetchApp.fetch(LINE_URL ,options)
}

  • Answer # 1

    It was a program mistake

Related articles