A Cloudflare Worker that turns a Google Sheet into a scheduled announcement API. Rows become visible only once their publishTime has passed, so you can stage announcements ahead of time directly from a spreadsheet.
- The Worker fetches your sheet via Google's
gvizCSV export endpoint. - Each row's
publishTime(Taipei time, AM/PM Chinese format) is parsed into a Unix timestamp. - Rows whose timestamp is
<=the current time are returned; future rows are hidden. - Results are cached in-memory for
CACHE_TTL_MSto avoid hammering the sheet.
The sheet must have these columns as the header row:
| Column | Description |
|---|---|
msgEn |
Announcement message in English. |
msgZh |
Announcement message in Chinese. |
uri |
Link associated with the announcement (optional). |
publishTime |
When the row becomes visible. Format: YYYY/M/D 上午/下午 H:MM:SS (Asia/Taipei). |
Example publishTime values:
2026/5/16 上午 9:30:00
2026/5/16 下午 11:05:00
This is the default format produced by Google Sheets when a cell is formatted as date-time with the locale set to Traditional Chinese (Taiwan).
The sheet must be published / shared so that "anyone with the link can view" — the Worker fetches it anonymously.
Returns a JSON array of currently-visible rows. Each row includes the original sheet columns plus a datetime field (Unix seconds parsed from publishTime).
[
{
"msgEn": "Maintenance window tonight",
"msgZh": "今晚系統維護",
"uri": "https://example.com/status",
"publishTime": "2026/5/16 上午 9:00:00",
"datetime": 1763254800
}
]Returns { "ok": true }.
Set these in wrangler.toml under [vars], or in .dev.vars for local dev:
| Variable | Required | Default | Description |
|---|---|---|---|
SHEET_ID |
yes | — | The Google Sheet ID (the long string in the sheet URL). |
SHEET_GID |
no | 0 |
The gid of the specific tab to read. |
CACHE_TTL_MS |
no | 10000 |
How long to cache the sheet in memory, in milliseconds. |
npm install
npm run dev # wrangler dev — local Worker at http://localhost:8787Hit http://localhost:8787/announcement to see the current visible rows.
npm run deploy # wrangler deployMIT