Last active
February 23, 2021 09:01
-
-
Save neno-tech/d762627c15d70a5988fbc22db6756780 to your computer and use it in GitHub Desktop.
โค้ดไลน์แชตบอต อัปเดต 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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