A Google Apps Script-based monitoring library that validates remote app-ads.txt content from Google Sheets and dispatches change alerts to Telegram or Slack.
Important
This repository is built for Google Apps Script runtime and is designed to execute inside a Google Spreadsheet-bound script project.
- Title and Description
- Features
- Tech Stack & Architecture
- Getting Started
- Testing
- Deployment
- Usage
- Configuration
- License
- Contacts & Community Support
- Batch-validates
app-ads.txtendpoints listed in a spreadsheet. - Uses HTTP status-aware fetch logic (
200pass-through, non-200status reporting). - Compares expected text lines against remote content with newline-based parsing.
- Tracks per-row validation status in a dedicated output column.
- Detects status deltas between the current and prior execution snapshots.
- Supports Telegram alerting via Bot API integration.
- Supports Slack alerting via Incoming Webhook integration.
- Minimizes write operations with batched
setValuesfor history updates. - Uses idempotent comparison flow (
newStatusvsoldStatus) to reduce noise. - Handles fetch exceptions and logs runtime errors for observability.
Note
The checker logic reads expected directives from one cell and splits by newline (\n), allowing each expected app-ads.txt rule to be maintained on a separate line.
- Runtime: Google Apps Script (V8 JavaScript runtime).
- Host Application: Google Sheets (bound-script execution model).
- Core APIs:
SpreadsheetAppfor tabular I/O.UrlFetchAppfor HTTP requests.Loggerfor execution logs.
- External Integrations:
- Telegram Bot API (
sendMessage). - Slack Incoming Webhooks.
- Telegram Bot API (
.
├── checkAppAdsContent.gs # Core validator: fetch and verify app-ads.txt lines
├── SHEETSmonitorChangesAndNotify.gs # Change detector + Telegram notifier
├── SLACKmonitorChangesAndNotify.gs # Change detector + Slack notifier
└── LICENSE # Apache License 2.0
- Spreadsheet-first orchestration: configuration and state history are stored directly in sheet columns for non-developer operability.
- Separation of concerns: validation and notification logic are split into distinct scripts for maintainability.
- Diff-based notifications: alerts only trigger when status transitions are detected.
- Batch writes: status history updates are buffered to reduce Apps Script API calls.
flowchart TD
A[Time-driven Trigger] --> B[checkAppAdsContent]
B --> C[Read B:C from sheet]
C --> D[Fetch app-ads.txt URLs]
D --> E[Compare expected lines]
E --> F[Write status to column D]
A --> G[monitorChangesAndNotify*]
G --> H[Read A, D, E columns]
H --> I{newStatus != oldStatus?}
I -- No --> J[Skip]
I -- Yes --> K[Send Telegram/Slack message]
K --> L[Update column E with newStatus]
Tip
Keep validation and notification functions on separate time-based triggers. This allows independent schedule tuning (e.g., run validation every 15 minutes, notifications every 5 minutes).
- Google account with access to Google Sheets.
- A spreadsheet containing monitoring rows.
- Google Apps Script editor access.
- For Telegram alerts:
- Bot token from BotFather.
- Target chat ID.
- For Slack alerts:
- Slack Incoming Webhook URL.
- Clone this repository:
git clone https://github.com/<your-org>/GAP_checkAppAdsContent.git
cd GAP_checkAppAdsContent- Create or open your target Google Spreadsheet.
- Open Extensions → Apps Script.
- Copy script contents from:
checkAppAdsContent.gsSHEETSmonitorChangesAndNotify.gsSLACKmonitorChangesAndNotify.gs
- Save the project.
- Replace secrets/constants in notifier scripts (
TELEGRAM_TOKEN,CHAT_ID,SLACK_WEBHOOK_URL). - Configure time-driven triggers for your selected functions.
Warning
The repository stores placeholder credentials. Never commit real secrets into version control. Use Apps Script Properties Service for production-grade secret management.
This project is script-runtime-centric (Google Apps Script), so validation is primarily done through Apps Script execution logs and sheet-state assertions.
Recommended checks:
# Optional static syntax check if clasp is configured
clasp pull
# Review repository status before deployment
git statusRuntime validation checklist:
- Execute
checkAppAdsContentmanually once from Apps Script editor. - Verify column
Dis populated with one of:ValidMissing: ...Error: HTTP <code>Error: <message>
- Execute
monitorChangesAndNotify(Telegram) ormonitorChangesAndNotifySlack(Slack). - Confirm outbound alert delivery and that column
Emirrors new status values.
Caution
If column E is manually edited or cleared, the next notifier run may generate a notification burst because all rows appear as changed.
Production deployment options:
- Bound script in Google Sheets (recommended): easiest operational model for spreadsheet-driven workflows.
- Versioned Apps Script deployments: create immutable versions for rollback safety.
- CI-assisted sync with
clasp: push script changes from GitHub workflows to Apps Script project (advanced).
Suggested production workflow:
- Update code in Git.
- Run peer review.
- Sync to Apps Script project.
- Create a versioned deployment.
- Monitor execution logs and quota usage.
Example Dockerized CI helper for clasp-based pipelines:
# docker-compose.yml (example)
services:
clasp:
image: node:20-alpine
working_dir: /repo
volumes:
- ./:/repo
command: sh -c "npm i -g @google/clasp && clasp push"Note
For enterprise environments, prefer non-interactive auth with dedicated service credentials and secure secret injection from your CI platform.
function runValidation() {
// Reads URLs from column B and expected directives from column C
// Writes validation status to column D
checkAppAdsContent();
}Expected behavior:
- Every row is fetched from URL in column
B. - Expected rules in column
Care split by newline. - Missing lines are aggregated into a single status message.
function runTelegramMonitor() {
// Compares current status (D) against previous status snapshot (E)
// Sends Telegram alerts only when a row transitions
monitorChangesAndNotify();
}function runSlackMonitor() {
// Compares status deltas and emits Slack webhook notifications
monitorChangesAndNotifySlack();
}| Column | Purpose | Required | Example |
|---|---|---|---|
A |
Site URL / Display label for notifications | Yes | https://example.com |
B |
app-ads.txt URL to fetch |
Yes | https://example.com/app-ads.txt |
C |
Expected lines (\n separated) |
Yes | google.com, pub-123, DIRECT |
D |
Current validation status (managed by script) | Yes | Valid |
E |
Previous status snapshot (managed by notifier) | Yes | Valid |
- In
SHEETSmonitorChangesAndNotify.gs:TELEGRAM_TOKENCHAT_ID
- In
SLACKmonitorChangesAndNotify.gs:SLACK_WEBHOOK_URL
- In all scripts:
sheetName(currentlytest1)
Recommended schedule:
checkAppAdsContent: every 15-60 minutes.monitorChangesAndNotify/monitorChangesAndNotifySlack: every 5-15 minutes.
Important
Keep trigger frequency within Google Apps Script quotas and external API rate limits.
This project is licensed under the Apache License 2.0. See LICENSE for full legal terms.
If you find this tool useful, consider leaving a star on GitHub or supporting the author directly.