'Issue about Google Sheet feature for my Chatbot
I will explain this feature first. I want my chatbot to connect with google sheet so when users want data they just input data that match the row they want, for example, if the user wants data in row 3 column 2, they just input the value that matches the value in row 3 column 1 and chatbot will provide the information in the next column but in the same row. If you don't understand because of my poor grammar or unclear explanation, take this image as an example.
So I wrote the code in Google Apps Script and connected it to the Chatbot maker platform called "Botnoi", the problem is I don't know why it doesn't work as I expected. this is my code in the Apps Script.
var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/111ie_I8hWjenCM9KB7EbuMnNtWxLkZdauQUm5979evE/edit?usp=sharing");
var sheet = ss.getSheetByName("Score_Paper");
function doGet(e) {
var userMsg = e.parameter.msg
var dataRange = sheet.getDataRange();
var values = dataRange.getValues();
var row = "";
for (var i = 0; i < values.length; i++) {
for (var j = 0; j < values[i].length; j++) {
if (values[i][j] == "User") {
row = values[i][j+1];
Logger.log(row);
Logger.log(i);
}
}
}
var replyJSON = ContentService.createTextOutput(JSON.stringify({result:row})).setMimeType(ContentService.MimeType.JSON);
return replyJSON;
}
this is API in the Botnoi platform that I use to connect with Google Sheet and use to receive the values from chatbot users.
I want to know why this feature doesn't work as I expected, How I can fix this, if you want more information about this issue, ask me In the comment section. also sorry for my poor grammar.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
