Answer the question
In order to leave comments, you need to log in
Accepting reports in a telegram bot and structuring them?
Good afternoon, tell me how to do / what to see, read.
I want to do something so that the telegram bot I made with the help BotFather + ManyBot
of sends data from the survey form data to Google spreadsheets.
It has different menu items, poll is one of them.
The bottom line is that I want
ставить задачи людям и отчет принимать в телеграм в виде опроса (пошаговая форма)
and structure it in google spreadsheets. не сложные
options for receiving / checking reports? var token = "880958063:qqqqqqqqqqqqqqqqqqqqqqq";
var telegramUrl = "https://api.telegram.org/bot" + token;
var webAppUrl = "https://script.google.com/macros/s/qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq/exec";
var ssId = "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq";
function getMe() {
var url = telegramUrl + "/getMe";
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
function setWebhook() {
var url = telegramUrl + "/setWebhook?url=" + webAppUrl;
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
function sendText(id,text) {
var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + text;
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
function doGet(e) {
return HtmlService.createHtmlOutput("Hi there");
}
function doPost(e) {
// this is where telegram works
var data = JSON.parse(e.postData.contents);
Logger.log(data);
var text = data.message.text;
var id = data.message.chat.id;
var name = data.message.chat.first_name + " " + data.message.chat.last_name;
var answer = "Hi " + name + ", thank you for your comment " + text;
sendText(id,data);
SpreadsheetApp.openById(ssId).getSheets()[0].appendRow([new Date(),id,name,text,answer]);
if(/^@/.test(text)) {
var sheetName = text.slice(1).split(" ")[0];
var sheet = SpreadsheetApp.openById(ssId).getSheetByName(sheetName) ? SpreadsheetApp.openById(ssId).getSheetByName(sheetName) : SpreadsheetApp.openById(ssId).insertSheet(sheetName);
var comment = text.split(" ").slice(1).join(" ");
sheet.appendRow([new Date(),id,name,comment,answer]);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question