Guide

The Grok Bot routine

One routine, one prompt and one connector. That is all the Bot side needs.

Create the routine

On your Bot, create a routine with a webhook trigger. Copy its URL and key intoGROK_BOT_WEBHOOK_URL and GROK_BOT_WEBHOOK_KEY.

Paste the prompt

Use this as the routine's instruction. It stops the Bot from answering in its own thread or sending a shortened summary.

prompt
You are being woken by my iMessage bridge. The webhook body is JSON with these
fields: text, from, platform, reply_url, reply_token, correlation_id, sent_at,
message_id.

Treat `text` as a message I sent you over iMessage. Answer it the way you
normally would: use your memory, your skills, your cloud computer, and any tool
you would use in a normal conversation. Do the actual work. Do not reply with a
plan to do the work.

When you have the final answer, deliver it by calling the MCP tool send_reply on
the grok-imessage-bridge connector:

  send_reply(
    text:           <your complete answer>,
    reply_token:    <the reply_token value from THIS webhook body>,
    correlation_id: <the correlation_id value from THIS webhook body>
  )

Rules for that call:

1. Use the reply_token from this run only. Never one from an earlier run, never
   one you remember, never one you construct. It is single use and already bound
   to the chat the message came from. You do not choose the recipient.

2. Send the complete answer, verbatim. Put the whole thing in text. Do not
   summarise it, trim it, or send a short version with "let me know if you want
   the details". If the answer is long, it is long.

3. Plain text only. iMessage renders no markdown. No bold, no italics, no
   backticks, no headings, no [text](links), no tables, no code fences. Use blank
   lines and ordinary dashes for structure, and write URLs bare.

4. Call send_reply exactly once per run. The token is consumed on the first
   successful call; a second returns {"ok":false,"error":"consumed"} and sends
   nothing. If a call returns ok:false with "invalid" or "expired", stop. Do not
   retry with a different token and do not try another delivery route.

5. Deliver only through send_reply, or the fallback below. Do not email, message
   or post the answer anywhere else.

If the send_reply tool is unavailable, fall back to HTTP: POST the value of
reply_url with header Authorization: Bearer <reply_token>, header
Content-Type: application/json, and body
{"text": "<your complete answer>", "correlation_id": "<correlation_id>"}.
Put the token in the header, never in the URL or a query string.

Add the connector

Register https://<your base URL>/mcp as a custom MCP connector on the Bot. It exposes one tool, send_reply. If the Bot's auto-review has an allowlist, add the connector to it.

Set MCP_AUTH_TOKEN

Without it, /mcp is open to anyone who can reach your tunnel. Use the same value as the connector's Bearer token.

What the Bot receives

json
{
  "text": "what's on my calendar tomorrow?",
  "from": "<spectrum sender id>",
  "platform": "imessage",
  "reply_url": "https://your-bridge.example.com/reply",
  "reply_token": "<32 random bytes, base64url>",
  "correlation_id": "<uuid>",
  "sent_at": "2026-11-09T05:26:00.000Z",
  "message_id": "<spectrum message id>"
}

The token is bound to the chat the message came from, so the Bot can only ever reply there.