Published: 2026-09-16
Deep dive

Grok Bot routines that wake on email: webhook triggers, AgentMail and a twice-daily inbox triage

Chapters / key moments (click to jump — plays here on the page)

Our other Grok Bot pages cover routines that run on a schedule. This one adds the other trigger type: a routine that runs when a webhook fires. Paired with an agent-owned inbox, a bot now wakes up when it receives mail, so other agents (Codex, other automations) can send it tasks by email. The setup has one part that isn't obvious, the auth header, and one annoyance, per-inbox filtering, and both are covered below.

Source video

"Grok Bot Manages My Inbox (and has its own)" by Nate HerkWatch on YouTube →

Build 1 — scheduled inbox triage (about 10 minutes)

  1. Create a bot and state the routing rules.

    Create new bot, then describe the categories: primary and urgent (mark read right away, since these are the ones to act on), notifications (bank, services), outreach (sponsorships, pitches). The bot suggested adding newsletters, and he accepted.

  2. Connect the mailbox.

    Marketplace → search Gmail (or Outlook) → add account. You can add several inboxes. Give each one a label so separate bots can manage separate inboxes.

  3. Ask for the routine.

    "Do this twice a day and send me a ClickUp DM". The bot created a routine at 6:45am and 6:45pm that labels only (it drafts nothing) and ends each DM with "sent by Nat".

Build 2 — a bot with its own inbox that wakes on email

  1. Create an AgentMail inbox.

    Sign up at AgentMail (free tier, limited inboxes) → InboxesCreate inbox. It uses the default agentmail.to domain unless you connect a custom one.

  2. Connect AgentMail inside Grok Bot.

    Marketplace → AgentMail (a native connector) → Add account → name it → AuthorizeAllow.

  3. Create the bot and a webhook routine.

    Tell the new bot its job and which AgentMail credential to use, then ask for a routine whose trigger is a webhook. On the routine you'll see When a webhook fires, with a webhook address and a key. If they aren't shown, update the desktop app. On his machine a bug hid them until the next day's update.

  4. Add the endpoint in AgentMail.

    WebhooksAdd endpoint → paste the routine URL → subscribe to message events → save. Then AdvancedCustom headers:

    Authorization: Bearer <key from the Grok Bot routine>

    Type Authorization by hand, then one space after Bearer.

  5. Scope the webhook to one inbox.

    Every endpoint fires for every inbox by default, so two bots would both wake for any email. You can tell the bot in its routine to ignore other inboxes. The cleaner fix is AgentMail's Advanced → Edit transformation, where you add a JavaScript filter on the inbox ID. He had Codex write it.

  6. Test it.

    Send an email to the new address. The target bot starts working and the other bot doesn't react. The reply shows up in the AgentMail inbox view.

Gotchas & Caveats

  • The webhook URL and key are credentials. Anyone with both can trigger your bot and have it act. Treat them like an API key, and rotate them if they are ever exposed.
  • An agent that acts on inbound email is an injection target. Anyone who can email the address can put instructions in front of the bot. Keep a webhook-woken bot's permissions narrow, and don't give it the power to send money or delete data on an email's say-so. See our security center.
  • The routine UI changed between desktop-app versions during recording. If your screen doesn't match, update first.
  • The video includes a sponsor segment (Clay) unrelated to the build.

Key Takeaways

  • Grok Bot routines have two trigger types: a schedule (cron-like) and a webhook.
  • An agent-owned inbox plus a webhook lets any other agent or automation hand a Grok Bot a task by email.
  • Filter per inbox at the webhook layer rather than in the prompt, so the bot never sees mail meant for another bot.

New to Grok Bot? Start with our Grok Bot hub and the first-week setup video.