Telegram API with Google Apps Script

google-apps-script, telegram

Solution

I was searching for something similar, and couldn't find any, so I have made my own, I will write it down here perhaps someone would make use of it.

This is a simple proof of concept that works:

function sendTelegramNotification(botSecret, chatId, body) {
var response = UrlFetchApp.fetch("https://api.telegram.org/bot" + botSecret + "/sendMessage?text=" + encodeURIComponent(body) + "&chat_id=" + chatId + "&parse_mode=HTML");
}

Other commands can be made same way.

Problem

I'm searching an example of Telegram API usage with Google Apps Script, or anyone/anything that can help me to learn how to use this API, for instance to send a message to a certain user

Original source