So I have Telegram Bot that works with Google App Script.
My bot sends the last row that was edited in my Sheet in any List ( more then 10 list).
And the message from bot goes with inline button "Accepted" - and I'm receiving an array with call_back data.
But I don't know how can I fix "Accepted" to the row ( fixed cell ) where I got message from.
Func - message to telegram
function onEdit(e) {
sendTelegram(e)
}
function sendTelegram(e){
var row = e.range.getRow();
var col = e.range.getColumn();
var startRow = 2; // Starting row
var targetColumn = 2; // Row, where placed trigger to send msg
var ws = sheetName; //List name
var sheet = e.source.getActiveSheet();
var sheetName = e.source.getActiveSheet().getName(); //Takes list name
let Company = e.source.getActiveSheet().getRange(row,13).getValue(); //Takes data from row 2 to 13 Column in every list
var firstCol = 2; // Starting from 2 column
var numOfCols = 13;//Ending in 13 column
var fullRowValues = sheet.getRange(row, firstCol, 1, numOfCols).getValues();
var fullRowString = fullRowValues.flat().toString(); // Makes array toString.
let chatId = "ChatId";// Telegram groupId
var text = encodeURIComponent(Company + " New Document has Been added" + ws)
if(e.source.getActiveSheet().getRange(row,2).getValue() == "Yanson"){ //Yanson- trigger.If in column 2 "Yanson" is set - sends row to group chat.
sendText(chatId,"[New Doc Added!] " + Company + sheetName + " , " + fullRowString,accepted);} //accepted - inline button
Send Text Func.
function sendText(chatId, text, keyBoard) {
let data = {
method: 'post',
payload: {
method: 'sendMessage',
chat_id: String(chatId),
text: text,
parse_mode: 'HTML',
reply_markup: JSON.stringify(keyBoard)
}
}
UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data);
}
And doPost func that track when button was clicked and saving it in "Log" list as array of data.
function doPost(e) {
let contents = JSON.parse(e.postData.contents);
SpreadsheetApp.openById("SheetId").getSheetByName("Log").appendRow([contents]);
So what I just need is to make When someone click on the button "Accepted" - text "Accepted" appears in 15 column near edited row that just was sent by bot.
This is how one of my list looks (example).
And this is how looks array that I'm receiving from bot[Contents].
I'm sure we can connect list and button by the Case Name (111/111/111) but don't know how :(
1.Yanson - trigger to send msg
2.Bot sends Msg with row.
3.Pressing inline button in bot msg.
4. Accepted appears near the row that was sent. Thats what I'm trying to get and searching for the solution for step 4.