For those cases when you need a quick response to what happened in scripts — you want to have an alert in instant messengers.

Google’s examples contain code for integrating with Slack — But at some point I had to write an integration with Telegram as well:

function main() {

	var CONFIG = {
		// The token must be obtained from BotFather by creating a new bot

		// Write something in the chat to your bot, then follow the link<TOKEN>/getUpdates
		// find the line in the response text ..."chat":{"id":123456789,"first_name"... you need an id value.
		CHAT_ID: '123456789'

	var message = 'Hello world!';

	function sendTelegramMessage(text) {
		var telegramUrl = `${CONFIG.TOKEN}/sendMessage?chat_id=${CONFIG.CHAT_ID}&text=`;
		var message = encodeURIComponent(text);
		var sendMessageUrl = telegramUrl + message;
		var options = {
			method: 'POST',
			contentType: 'application/json'
		UrlFetchApp.fetch(sendMessageUrl, options);