Google Sheets to Telegram Notifier | Real-Time Notifications using Google Apps Script & Telegram Bot API
By Samarpan
Get instant Telegram notifications whenever a new entry is added to a Google Sheet. Works with Google Forms, HTML forms, portfolio contact forms, lead generation forms, customer inquiries, and spreadsheet monitoring.
Using a Website Contact Form or HTML Form?
- Features
- Which Method Should I Use?
- Telegram Bot Setup
- Get Chat ID
- Method 1: Trigger-Based Monitoring
- Method 2: Instant Notifications with doPost()
- Troubleshooting
- Real-time Telegram notifications
- Google Sheets monitoring
- Google Forms notifications
- HTML form notifications
- Portfolio contact form alerts
- No backend required
- No database required
- Free to use
- Easy setup
- Mobile notifications through Telegram
| Use Case | Recommended Method |
|---|---|
| Google Forms | Method 1 |
| Existing Google Sheet | Method 1 |
| Manual Spreadsheet Entry | Method 1 |
| Shared Spreadsheet | Method 1 |
| Portfolio Website Contact Form | Method 2 |
| HTML Form | Method 2 |
| Apps Script Web App | Method 2 |
| Lead Generation Form | Method 2 |
Uses a scheduled Apps Script trigger to monitor a Google Sheet and detect new rows.
Sends Telegram notifications directly from doPost() when form data is submitted.
Faster, simpler, and more reliable.
Open Telegram and search:
@BotFather
Run:
/newbot
Create your bot and save the Bot Token.
Example:
123456789:ABCDefGhIjKlMnOpQrStUvWxYz
Open your bot.
Click:
Start
Send any message.
Open:
https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates
Example response:
{
"message": {
"chat": {
"id": 123456789
}
}
}Copy:
123456789
This is your Chat ID.
- Google Forms
- Existing Google Sheets
- Manual spreadsheet updates
- Third-party integrations
Google Sheet
↓
Apps Script Trigger
↓
Detect New Row
↓
Telegram Notification
const BOT_TOKEN = "YOUR_BOT_TOKEN";
const CHAT_ID = "YOUR_CHAT_ID";
function checkForNewRows() {
const sheet = SpreadsheetApp
.getActiveSpreadsheet()
.getSheetByName("Sheet1");
const currentRows = sheet.getLastRow();
const props =
PropertiesService.getScriptProperties();
let previousRows =
props.getProperty("LAST_ROW");
if (!previousRows) {
props.setProperty("LAST_ROW", currentRows);
return;
}
previousRows = parseInt(previousRows);
if (currentRows > previousRows) {
UrlFetchApp.fetch(
"https://api.telegram.org/bot" +
BOT_TOKEN +
"/sendMessage",
{
method: "post",
payload: {
chat_id: CHAT_ID,
text:
"🔔 New Entry Added\n\nSheet: " +
sheet.getName()
}
}
);
props.setProperty(
"LAST_ROW",
currentRows
);
}
}Extensions
→ Apps Script
→ Triggers
→ Add Trigger
Function:
checkForNewRows
Event Source:
Time-driven
Frequency:
Every Minute
🔔 New Entry Added
Sheet: Form Responses 1
- Portfolio websites
- Contact forms
- HTML forms
- Apps Script Web Apps
- Lead generation forms
HTML Form
↓
Apps Script doPost()
↓
Google Sheet
↓
Telegram Notification
const BOT_TOKEN = "YOUR_BOT_TOKEN";
const CHAT_ID = "YOUR_CHAT_ID";
function doPost(e) {
var sheet = SpreadsheetApp
.getActiveSpreadsheet()
.getActiveSheet();
var name = e.parameter.name || "";
var email = e.parameter.email || "";
var phone = e.parameter.phone || "";
var message = e.parameter.message || "";
sheet.appendRow([
new Date(),
name,
email,
phone,
message
]);
UrlFetchApp.fetch(
"https://api.telegram.org/bot" +
BOT_TOKEN +
"/sendMessage",
{
method: "post",
payload: {
chat_id: CHAT_ID,
text:
"🔔 New Portfolio Inquiry\n\n" +
"👤 Name: " + name + "\n" +
"📧 Email: " + email + "\n" +
"📱 Phone: " + phone
}
}
);
return ContentService
.createTextOutput("Success")
.setMimeType(ContentService.MimeType.TEXT);
}🔔 New Portfolio Inquiry
👤 Name: John Doe
📧 Email: john@example.com
📱 Phone: 9876543210
Notifications typically arrive within a few seconds.
Check:
- Bot token is correct
- Chat ID is correct
- Bot has been started
- Apps Script permissions are granted
{
"ok": true,
"result": []
}Solution:
- Open the bot
- Click Start
- Send a message
- Run getUpdates again
This only affects Method 1.
The stored row count may become larger than the current row count.
Fix:
- Add enough rows to exceed the stored value
- Or reset the Script Property
Method 2 is not affected.
- Google Apps Script
- Google Sheets
- Telegram Bot API
- JavaScript
- HTML Forms
google-sheets
google-apps-script
telegram-bot
telegram-api
notifications
google-forms
spreadsheet-monitoring
telegram-notifications
javascript
automation
MIT License
Feel free to use, modify, and distribute this project.
⭐ If this project helped you, consider starring the repository.