Send Telegram Notifications from Google Sheets Using Apps Script

Telegram's Bot API is one of the simplest messaging APIs to work with — no SDK required. Combined with Apps Script, you can fire off notifications, alerts, and reports to any Telegram chat.

Step 1 — Create a Telegram Bot

  1. Open Telegram and search for @BotFather.
  2. Send /newbot and follow the prompts to name your bot.
  3. BotFather will give you a Bot Token — save it.
  4. Start a chat with your new bot, then visit: https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates Send a message to the bot first, then check the response for your chat_id.

Step 2 — Store credentials

function storeTelegramCredentials() { PropertiesService.getScriptProperties().setProperties({ 'TELEGRAM_BOT_TOKEN': 'your_bot_token_here', 'TELEGRAM_CHAT_ID': 'your_chat_id_here', }); }

Send a basic message

function sendTelegramMessage(text) { const props = PropertiesService.getScriptProperties(); const token = props.getProperty('TELEGRAM_BOT_TOKEN'); const chatId = props.getProperty('TELEGRAM_CHAT_ID'); const url = `https://api.telegram.org/bot${token}/sendMessage`; UrlFetchApp.fetch(url, { method: 'POST', contentType: 'application/json', payload: JSON.stringify({ chat_id: chatId, text, parse_mode: 'Markdown', // Supports *bold*, _italic_, `code` }), muteHttpExceptions: true, }); } // Usage: // sendTelegramMessage('*Alert!* Value exceeded threshold.');

Send an alert when a Sheet value changes

function checkAndAlert() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const value = sheet.getRange('C2').getValue(); const threshold = 500; if (value > threshold) { sendTelegramMessage( `⚠️ *Threshold Exceeded*\nCell C2 is currently *${value}*, above the limit of ${threshold}.` ); } }

Send a daily summary from a Sheet

function sendDailySummaryToTelegram() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Summary'); const data = sheet.getDataRange().getValues().slice(1); // Skip header let message = `📊 *Daily Summary — ${new Date().toDateString()}*\n\n`; data.forEach(([label, value]) => { message += `${label}: *${value}*\n`; }); sendTelegramMessage(message); }

Send a file or document

function sendTelegramDocument(fileId) { const props = PropertiesService.getScriptProperties(); const token = props.getProperty('TELEGRAM_BOT_TOKEN'); const chatId = props.getProperty('TELEGRAM_CHAT_ID'); const file = DriveApp.getFileById(fileId); const blob = file.getBlob(); const url = `https://api.telegram.org/bot${token}/sendDocument`; const formData = { chat_id: chatId, document: blob, caption: `📄 ${file.getName()}`, }; UrlFetchApp.fetch(url, { method: 'POST', payload: formData, muteHttpExceptions: true, }); Logger.log('Document sent to Telegram.'); }

Schedule a daily morning ping

function createMorningPingTrigger() { ScriptApp.newTrigger('sendDailySummaryToTelegram') .timeBased() .everyDays(1) .atHour(8) .create(); }

Tips

  • parse_mode: 'Markdown' supports *bold*, _italic_, `inline code`, and [link text](url).
  • For group chats, the chat_id is negative (e.g. -1001234567890). Get it the same way — send a message to the group with the bot added, then call getUpdates.
  • Telegram bots can only send messages to chats they are already a member of. Make sure the bot has been started or added to the group.
  • The Bot API is free and has generous rate limits — 30 messages/second to different chats, 1 message/second to the same chat.