---
name: wiki-notify-gchat
description: Turn wiki.adom.inc notification emails into a live Google Chat board and sweep them out of the Gmail inbox. Use when the user wants wiki notifications in Google Chat instead of email, a chat board of open wiki issues, wiki emails auto-trashed/archived/labeled, or asks to set up, check, backfill, or change wiki-notify-gchat. Trigger words - wiki-notify-gchat, wiki notifications in chat, stop wiki emails, wiki notification board, sweep wiki emails, wiki issues board in gchat, forward wiki notifications.
user-invocable: true
---

# Wiki Notify for Google Chat

Polls Gmail for wiki.adom.inc notification emails, folds them into per-issue
state, and maintains ONE card in the user's own Chat space - a table with a
row per item (newest first, OPEN/CLOSED status, origination date, actor,
View link at the end) - then sweeps the emails out of the inbox. Closed items
drop off the board at 6am the next day.

## Fastest path (per team member - each uses their OWN space + webhook)

Prerequisite: authorized adom-google (`adom-google status` shows a refresh
token; else run `adom-google auth`).

1. Install: `adom-wiki pkg install adom/wiki-notify-gchat`
2. Have the user create their own Chat space (e.g. "Wiki Notifications" -
   must be a space THEY create; the tool deletes its old board card as space
   manager) and add an incoming webhook: space name > Apps & integrations >
   Webhooks > Add webhook, copy the URL.
3. Configure entirely from the CLI - no file editing:

```bash
wiki-notify-gchat setup
wiki-notify-gchat config set webhook '<url>'         # personal secret; stays in the 0600 config, never in a repo
wiki-notify-gchat config set timezone America/Chicago  # IANA zone; 6am closed-item purge follows it
wiki-notify-gchat config set meName Drew             # first name shown in the involvement line
wiki-notify-gchat config set fullName 'Drew Owens'   # wiki author name; detects pages they own
wiki-notify-gchat config set action trash            # trash (default) | archive | label | keep
wiki-notify-gchat config show                        # review (webhook token masked)
```

4. Verify and go live:

```bash
wiki-notify-gchat health          # auth + config + cron check
wiki-notify-gchat run --dry-run   # preview what would be ingested + swept
wiki-notify-gchat backfill        # seed the board from the last 30 days (no sweeping)
wiki-notify-gchat run             # ingest + sweep + post the board
wiki-notify-gchat install-cron    # keep the board live every 2 min
```

## Config keys (all via `config set <key> <value>`)

- `webhook` - the user's incoming-webhook URL (secret, validated on set).
- `action` - what happens to swept emails: `trash` (default, recoverable 30
  days), `archive`, `label` (uses `labelName`, auto-created), or `keep`.
- `timezone` - IANA zone; container default is often UTC, which makes the
  6am purge fire overnight in the US - set it.
- `meName` / `fullName` - involvement line ("Drew owns this page"); fullName
  is matched against `adom-wiki page stats` author_name, auto-derived from
  the notification To header when unset.
- `style` - `table` (default) or `blocks`. Chat cards have no native table
  widget; avoid single-line pipe columns, they wrap unreadably at card width.
- `purgeHour`, `maxRows`, `pollSeconds`, `boardTitle`, `query`,
  `requireInBody` as needed.

## How the board updates (why you may see a delete)

Webhooks can only create messages, so each change POSTs a fresh card and
deletes the previous one via adom-google (the user is a manager of their own
space). Always exactly one board card. If deletion ever fails the tool logs
WARN and the user must be made a space manager (or use a space they created).

## Pitfalls

- Cold boots self-heal: `install-cron` wires @reboot + a bashrc snippet + a
  Claude UserPromptSubmit hook, all calling `wiki-notify-gchat ensure`
  (restarts cron via passwordless sudo, or runs a detached watch fallback).
  Never tell the user to run sudo by hand; `ensure --force` heals instantly.
- Updates arrive automatically via adom-hook's `adom-wiki pkg update` pass -
  do not build a separate updater.
- Gmail search cannot match quoted URLs; precision comes from the
  `requireInBody` guard, not the query - do not "fix" the query by quoting.
- A failed board post never sweeps the email; it retries next pass.
- `board --dry-run` prints the exact card JSON; `status` shows counts + log.
- Add `--json` to any command for a `{status, data, hints}` envelope.
