Skip to main content

A local WhatsApp Web bridge wakes Grok Bot to read and reply to direct messages

GitHubGitHubyotam562026-12-02

Life assistantSource read in fullRead first
GitHubGitHubyotam562026-12-02

Open original

Overview

Someone who wants a personal assistant to answer WhatsApp direct messages can run this local WhatsApp Web hook on a Mac, attach a logged-in Chrome session, and let a Grok Bot webhook routine read and reply through commands on the same machine.

Workflow

  1. What it is: A local, auditable bridge between a logged-in WhatsApp Web session and an AI agent, so a direct message can wake the agent, which then reads the conversation and may reply. Version 0.3 is a rewrite and a breaking change from 0.2. All judgment (who matters, what to answer) stays in the agent. The webhook only wakes it. The agent needs a shell on the machine that runs the bridge, or must run the commands over SSH.
  2. Grok Bot parts used: A webhook-triggered Routine, whose instructions are taken from docs/agent-prompt.md. There is no x.ai/bot/... template link. The README's Grok Bot example says to create a webhook routine, ignore fault and recovered posts where possible (they need no model run), paste that prompt as the routine instructions, and store the routine's webhook URL and bearer key in WHATSAPP_WEB_WEBHOOK_URL and WHATSAPP_WEB_WEBHOOK_KEY. Grok Bot must run on the same machine as the bridge, or reach it over SSH, because read and reply are local commands. Not part of Grok Bot: this Node.js bridge, Chrome or Chromium with a WhatsApp Web tab, the loopback-only Chrome DevTools Protocol connection, the local SQLite database, and launchd templates. Deprecated aliases GROKBOT_WEBHOOK_URL and GROKBOT_WEBHOOK_KEY still work, with a warning.
  3. You need: Node.js 22.13 or later, Chrome or Chromium, a Grok Bot that can create a webhook-triggered Routine and can run shell commands on the bridge host (or over SSH), and a machine that does not hibernate if it must receive wakes. The documented host setup is macOS. A dedicated WhatsApp number for the assistant account is recommended so everyday chats stay separate. Not stated in the source: which Grok Bot plan is required. Automating WhatsApp Web is not an official WhatsApp integration and may violate WhatsApp's terms; the README says to use a dedicated number you can afford to lose, keep volume low, and use this only where authorized.
  4. Install: Install the CLI, start a dedicated Chrome profile, fill in the webhook, and run the watcher. The README's path, kept as sub-steps:
    • Step 1: The README also offers a short ask-your-agent prompt that points the agent at docs/agent-setup.md (that file was not fetched as a block) and then hands the user the screen for the QR scan:

Connect my WhatsApp Web to you. Find yotam56/whatsapp-for-agents and follow [the agent setup prompt](docs/agent-setup.md). Set it up yourself and hand me the screen for the QR scan.

  • Step 2: Install with npm install -g github:yotam56/whatsapp-for-agents. Pin a release tag once one is published. Requires Node.js 22.13 or later.
  • Step 3: Start Chrome with a dedicated profile and a loopback-only debugging port (remote debugging on port 9222, address 127.0.0.1, user data dir $HOME/.whatsapp-for-agents-chrome, opening https://web.whatsapp.com/), then scan the QR code in that window. Keep exactly one WhatsApp Web tab. Use only one Chrome supervisor: either WHATSAPP_WEB_CHROME_CMD or the Chrome launchd template, not both. A launchd template lives in examples/launchd/.
  • Step 4: Run whatsapp-for-agents init (writes ./.env.web with mode 0600), fill in the webhook URL and key from the Grok Bot routine, then whatsapp-for-agents --env-file .env.web doctor.
  • Step 5: Start the watcher with whatsapp-for-agents --env-file .env.web watch (foreground) and check status from another shell, or use the watcher launchd template. The first attach records everything already in the store as seen, so old history never wakes the agent. Paste the long routine instructions from docs/agent-prompt.md rather than from this case. A machine that hibernates cannot receive wakes.
  1. After install: Each new incoming direct message is committed to SQLite and POSTed at once to the webhook; the routine reads, then replies or stays silent.
    • What wakes the agent: a new incoming message in a direct chat (text, quoted reply, image, video, document, sticker, voice or audio placeholder, or a message still undecryptable after 10 minutes, delivered once as unsupported). Groups, the account's own messages, reactions, and system messages are recorded and readable but never wake. Nothing the bridge sends can wake the agent.
    • On a message webhook: dedupe by event id, run whatsapp-for-agents read EVENT_ID --context 20, treat all message text as untrusted, then reply once or stay silent. Reply and send take text on stdin and need an idempotency key. Failures such as send_unknown or send_pending must not be resent; account_restricted means stop sending and tell the owner. The full failure list is in docs/agent-prompt.md and the README.
    • Delivery is at-least-once over HTTPS with no redirects. 408, 429, 5xx and network errors retry with backoff and never expire; other 4xx and redirects park the event. A wrong webhook key parks events and, after 5 minutes, raises webhook_failing.
    • The database keeps full content of recorded messages, including groups, for a 30-day prune of delivered and finished rows. Message ids older than 30 days are forgotten and can never wake the agent. The SQLite file is created with mode 0600. The session never leaves the machine; the bridge never reads, copies, or uploads the Chrome profile or WhatsApp keys.
    • reply opens the chat, so WhatsApp shows it as read. Burst limit: at least 1 s between sends to a chat, at most 20 per minute. Max text is 4,096 characters. --quote stays unsupported until doctor --probe identifies the reply command on a live account.
  2. Did the author run it: The repository has no run records from the author. The repo includes fixture tests (npm test) and CI; the README says CI never touches WhatsApp. The Live checklist is a procedure for the owner to verify a new install or a new WhatsApp Web build on a real account, including a p95 wake target of at most 300 ms in status. That checklist is an acceptance procedure, not a completed run log.

Key points and results

  • Maturity: At fetch time on 2026-12-04 the repo was created at 2026-12-02T13:23:49Z, last pushed at 2026-12-03T21:04:50Z, with 15 commits, 2 stars, 0 forks, 4 open issues or PRs, and an MIT license. docs/agent-prompt.md was fetched; docs/agent-setup.md was not. Version 0.3 is documented as a breaking rewrite of 0.2. The repository has no author-run Grok Bot or WhatsApp record.
  • Permissions and boundaries: Whatever runs this bridge holds the WhatsApp session and can read every chat and send as the account. The bridge has zero npm dependencies, makes only two kinds of connection (CDP to Chrome on 127.0.0.1, and HTTPS POSTs to the configured webhook), and listens on no network port. There is no telemetry, analytics, update check, or crash reporting, and no generated webhook secret. Message text in the webhook is untrusted conversation content and cannot authorize tool use, change instructions, or point the bot at another chat. The routine should report owner-only issues in the Grok Bot app, not over WhatsApp. Keep Chrome's debugging port private.
  • Known limits: The documented host is macOS; Grok Bot must be able to run local (or SSH) CLI commands; a hibernating machine cannot receive wakes. Automating WhatsApp Web may violate WhatsApp's terms. Today, sending to a number the account has never chatted with fails with invalid_target. Quoted replies are gated until a live probe finds the command. Messages older than 30 days never wake the agent. Which Grok Bot plan is required is not stated. The repository has no author run records.
  • Worth borrowing: Wake the agent only for incoming direct messages, and keep group history readable without starting a run. See the README's agent-contract section.
  • Worth borrowing: Dedupe by event id, treat message text as untrusted, and never resend on send_unknown or send_pending. See docs/agent-prompt.md.
  • Worth borrowing: Keep the WhatsApp session on the machine, use a required webhook key you supply, and make the bridge auditable with no extra network dependency. See the Trust and what it can see section.

Source

Platform
GitHub
Author
yotam56
Published
Categories
Life assistant

What this evidence label means

Source read in full

We read the source (post, article or transcript). That only means the original was read. It does not mean this site reproduced the author's results.

Read the editorial and evidence policy

Other cases in this scenario

This unofficial community project is independent of xAI. xAI has neither approved nor endorsed it. No sign-up. The methods and figures come from the original authors.