I am trying to use a spreadsheet through a Telegram bot as a TODO list so that when I input something on my phone, it is saved in the spreadsheet. (I'm following this tutorial https://www.youtube.com/watch?v=XoTpdxbkGGk, which seems accurate with Google Sheet and the Telegram bot setup.) However, for some reason, when I input data into the Telegram bot, nothing gets saved in the Google Sheet.
Can anyone help me with this issue?
var token="<<BOT-TOKEN>>";
var url="https://api.telegram.org/bot" + token ;
var webAppUrl="https://script.google.com/macros/s/<<secret>>/exec";
var spId='<<secret>>';
function getme() {
var response=UrlFetchApp.fetch(url + "/getme");
Logger.log(response.getContentText());
}
function getupdates() {
var response=UrlFetchApp.fetch(url + "/getupdates");
Logger.log(response.getContentText());
}
function setwebhook() {
var response=UrlFetchApp.fetch(url + "/setWebhook?url=" + webAppUrl);
Logger.log(response.getContentText());
}
function setwebhook() {
var response=UrlFetchApp.fetch(url + "/sendMessage?chat_id=" + id + "&text" + text);
Logger.log(response.getContentText());
}
function doGet(m){
return HtmlService.createHtmlOutput("Hello" + JSON.stringify(m));
}
function doPost(m){
var contents = JSON.parse(m.PostData.contents);
GmailApp.sendEmail(Session.getEffectiveUser().getEmail(),"Telegram Bot Update",JSON.stringify(contents,null,4));
var text = contents.message.text;
var id = contents.message.from.id;
var name = contents.message.from.first_name + ' ' + contents.message.from.last_name;
sendText(id, "HI" + name);
SpreadsheetApp.openById(spId).appendRow([new Date(),id,text,contents,name]);
SpreadsheetApp.openById(spId).appendRow([1,2,3,4,5]);
}
/*
{
"parameter": {},
"contextPath": "",
"contentLength": 310,
"queryString": "",
"parameters": {},
"postData": {
"type": "application/json",
"length": 310,
"contents": "{\"update_id\":*,\n\"message\":{\"message_id\":12,\"from\":{\"id\":*,\"is_bot\":false,\"first_name\":\"*\\*\",\"username\":\"*\",\"language_code\":\"fa\"},\"chat\":{\"id\":*,\"first_name\":\"*\\*\",\"username\":\"*\",\"type\":\"private\"},\"date\":1558331571,\"text\":\"salaaaaaaaaaaaaam\"}}",
"name": "postData"
}
*/
I expected this code to save everything typed by the Telegram bot and display the data in Google Sheet rows. Unfortunately, it's not working as intended and doesn't show anything in the sheet cells.