Skip to content

Instantly share code, notes, and snippets.

@neno-tech
Last active February 23, 2021 09:01
Show Gist options
  • Save neno-tech/d762627c15d70a5988fbc22db6756780 to your computer and use it in GitHub Desktop.
Save neno-tech/d762627c15d70a5988fbc22db6756780 to your computer and use it in GitHub Desktop.
โค้ดไลน์แชตบอต อัปเดต 2021
var ss = SpreadsheetApp.openById("xxx");
var sheet = ss.getSheetByName("xxx");
function doPost(e) {
var data = JSON.parse(e.postData.contents)
var userMsg = data.originalDetectIntentRequest.payload.data.message.text;
var values = sheet.getRange(2, 1, sheet.getLastRow(),sheet.getLastColumn()).getValues();
for(var i = 0;i<values.length; i++){
if(values[i][0] == userMsg ){
i=i+2;
var Data = sheet.getRange(i,2).getDisplayValue();
var result = {
"fulfillmentMessages": [
{
"platform": "line",
"type": 4,
"payload" : {
"line": {
"type": "text",
"text": Data
}
}
}
]
}
var replyJSON = ContentService.createTextOutput(JSON.stringify(result)).setMimeType(ContentService.MimeType.JSON);
return replyJSON;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment