I've managed to figure out how to attach an inline button to message from my Telegram bot. I'm not sure how to make this button actually do something.
I have a simple invoice table in my Google Spreadsheet. I manually connected a Form to it, through which managers can request some financial transactions.
My perfect scenario: on every new form submit bot sends me a message with all the transaction's data. It already works perfectly (I'm using variables from form responses in combination with sendMessage
and UrlFetchApp.fetch
).
Now, I want to attach a functional button that will delete the particular message it's connected to and then send me a "Transaction completed" message.
My inline keyboard code excerpt:
'{"inline_keyboard":[[{"text":"Del","callback_data":"delete_message"}]]}'
I use most primitive webhook:
function setWebhook() {
var url = telegramUrl + "/setWebhook?url=" + webAppUrl;
var response = UrlFetchApp.fetch(url);
}
And I have a doPost
function for just replying to /start command (if some manager got lost in space and time):
function doPost(e) {
var contents = JSON.parse(e.postData.contents);
var chat_id = contents.message.from.id;
var fname = contents.message.from.first_name;
var text = (""+fname +", this bot is for notification only, fill the form located on our website.");
sendMessage(chat_id,text)
}
I've Googled a lot, and tried some solutions, but it seems like my callback listening still isn't working.