Logo: Imessage Grok Bot

Imessage Grok Bot

Communautéit
jeffhuber
imessage-grok-bot

Read, search, triage, and send iMessages on macOS via the iMessage helper bridge. Use when the user asks to review messages, find messages that need a reply, search message history, pull a conversation, compute response-time stats, or send a plain-text iMessage. macOS only—uses an on-device launchd helper to query the Messages SQLite database and AppleScript (osascript) to send outbound messages.

Iwwersiicht

Editeurjeffhuber
Repositorygrokbot-imessage-skill
Skill-Nummimessage-grok-bot
Stären
44
Forks
7
Matgeliwwert Dateien
37
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 37 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    jeffhuber huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Imessage Grok Bot an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/jeffhuber/grokbot-imessage-skill/tree/main
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jeffhuber/grokbot-imessage-skill.git \
  .claude/skills/imessage-grok-bot
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Imessage Grok Bot an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Imessage Grok Bot automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Imessage Grok Bot net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

iMessage on macOS — Grok Bot

When to use this skill

Use when the user asks to:

  • Review / triage recent iMessages or SMS
  • Find messages that need a response
  • Search history for a topic, person, or phrase
  • Pull a specific conversation's recent messages
  • Compute response-time statistics (e.g., "average reply time to Alex over the last 24 hours")
  • Send a plain-text iMessage to an existing contact

Architecture

  Grok Bot (your context)             macOS (user's local machine)
  -----------------------             ---------------------------
  Writes request-<id>.json  -->  launchd watches control/requests/  -->
  Reads  response-<id>.json  <-- grokbot-imessage-helper (wrapper)   -->
                                 helper.py (FDA-granted, reads
                                 chat.db + AddressBook, drives osascript)

You run in an environment that can execute shell commands on the user's Mac. The iMessage helper is a launchd agent that watches a bridge folder for JSON request files. When you write a request, launchd fires the helper, which reads the Messages database, processes the request, and writes a JSON response back—where you can then read it.

Sending goes through the same request/response bridge. You write a send_preview or send request, the helper calls osascript to drive Messages.app via AppleScript, and the result comes back as JSON. No GUI scripting or automated clicks; sends require a native confirmation dialog click—just a short-lived subprocess plus human approval.


Prerequisites — one-time setup

The helper must be installed on the user's Mac before you can use this skill. Installation is manual and requires the user to:

  1. Clone or download this repository.
  2. Run the standard install.sh (or optionally install-hardened.sh for defense-in-depth).
  3. Grant Full Disk Access to the exact wrapper path printed by the installer.
  4. (For sending) Approve the Automation prompt on first send: "grokbot-imessage-helper wants to control Messages."

If the user hasn't installed the helper yet, direct them to the installation section in README.md, or walk them through it step-by-step. Do not proceed with iMessage actions until the helper is installed and FDA is granted.


Bridge Folder Discovery

Before you can use the helper, you need to know where the bridge folder is located. Ask the user once and remember it for the rest of the conversation.

Example prompt:

"What bridge folder did the iMessage installer print? The hardened default is ~/Library/Application Support/GrokBotIMessage."

Once the user provides the path, verify it by checking for these files:

bash
BRIDGE="<user-provided-path>"
ls -la "$BRIDGE/control/requests" "$BRIDGE/control/responses"

If any are missing, the helper isn't installed. Guide the user through installation.

Before the first message operation, call status. Require protocol major version 1; if it differs, stop and tell the user to update the helper and skill together. If read_policy.mode is allowlist and allowlist_entries is zero, explain that reads are intentionally disabled and direct the user to the hardened installer's configure_allowlist.py command. Never switch policy modes automatically.

Store the bridge folder path in your memory/context for the rest of the conversation. You'll use it for all subsequent request/response operations.


Invoking the Helper (Read/Analyze Actions)

To invoke the helper, you:

  1. Generate a unique request ID (use a UUID or timestamp).
  2. Write a JSON request file to <bridge>/control/requests/request-<id>.json.
  3. Poll for the response at <bridge>/control/responses/response-<id>.json (typically appears within 2–5 seconds).
  4. Read and parse the response, then delete the response file immediately. Responses can contain private message text. The helper reaps abandoned responses after one hour, but client deletion is the primary lifecycle.

Request format:

json
{
  "id": "<unique-request-id>",
  "action": "<action-name>",
  "params": { /* action-specific parameters */ }
}

Response format (success):

json
{
  "id": "<same-as-request-id>",
  "ok": true,
  "action": "<action-name>",
  /* action-specific response fields */
}

Response format (error):

json
{
  "id": "<same-as-request-id>",
  "ok": false,
  "error": "Error message"
}

Actions

Full protocol documentation is in docs/PROTOCOL.md. Below is a quick reference for each action.

status — Verify compatibility

json
{"id": "abc123", "action": "status", "params": {}}

This action returns helper/protocol versions and local installation checks. It does not read chat.db or return message content.

review — Triage recent messages

Request:

json
{"id": "abc123", "action": "review", "params": {"days": 2}}

Response: Three buckets: needs_reply (actionable, full text + context), low_priority (can wait, full text + context), and skip_summary (summary only, no text).

Each entry in needs_reply and low_priority has: chat_id, label, contact_name, display_name, last_ts, last_text, context (array of recent messages), and msg_count.

Example shell workflow:

bash
BRIDGE="$HOME/imessage-bridge"
REQ_ID=$(uuidgen | tr '[:upper:]' '[:lower:]' | head -c 12)

# IMPORTANT: Write to temp file first, then rename atomically.
# This prevents launchd from firing mid-write and processing incomplete JSON.
TMP="$BRIDGE/control/requests/.request-$REQ_ID.json.tmp"
FINAL="$BRIDGE/control/requests/request-$REQ_ID.json"

cat > "$TMP" <<EOF
{"id": "$REQ_ID", "action": "review", "params": {"days": 2}}
EOF

# Atomic rename publishes the complete request.
mv "$TMP" "$FINAL"

# Poll for response (max 15 seconds)
for i in {1..30}; do
  if [[ -f "$BRIDGE/control/responses/response-$REQ_ID.json" ]]; then
    RESPONSE="$BRIDGE/control/responses/response-$REQ_ID.json"
    cat "$RESPONSE"
    rm -f "$RESPONSE"
    break
  fi
  sleep 0.5
done

Critical: Always write requests via temp file + atomic rename. Writing directly to request-*.json can cause the helper to fire mid-write, leading to JSON parse errors.


search — Find messages by substring

Request:

json
{"id": "abc123", "action": "search", "params": {"term": "dinner plans", "days": 30, "limit": 100}}

Response: Array of matches with chat_id, contact_name, ts, is_from_me, text. Sorted by timestamp (newest first).


chat_history — Recent messages in one thread

Request:

json
{"id": "abc123", "action": "chat_history", "params": {"chat": "Alex Example", "days": 14, "limit": 100}}

chat can be:

  • Contact name (resolved via Contacts.app)
  • Phone number (any format; last 10 digits matched)
  • Email address
  • Note: Group chat IDs (e.g., chat123456789) work for read-only actions but are NOT supported for sending.

Response: chat_query, resolved_substr, count, and messages array (each with chat_id, contact_name, ts, is_from_me, text).


response_stats — Average reply time to one contact

Request:

json
{"id": "abc123", "action": "response_stats", "params": {"chat": "Alex Example", "hours": 24}}

Response: chat_query, resolved_substr, hours, sample_size, avg_seconds, avg_human, median_seconds, min_seconds, max_seconds, total_inbound_messages, total_outbound_messages.


contacts_lookup — Find matching contacts

Request:

json
{"id": "abc123", "action": "contacts_lookup", "params": {"name": "Alex"}}

Response: Array of matches with name, and either phone_last10 or email. Returns up to 25 matches.

Useful for disambiguating before chat_history or send.


send_preview — Dry-run a send (validation only)

Request:

json
{"id": "abc123", "action": "send_preview", "params": {"to": "+14155551234", "text": "Confirmed for 3pm.", "service": "iMessage"}}

service can be "iMessage", "SMS", or omitted (defaults to iMessage).

Response:

json
{
  "id": "abc123",
  "ok": true,
  "action": "send_preview",
  "preview": {
    "to": "+14155551234",
    "resolved_name": "Alex",
    "service": "iMessage",
    "text": "Confirmed for 3pm.",
    "text_length": 18,
    "blocked": false
  },
  "send_nonce": "Zk9...short-opaque-string",
  "send_nonce_ttl_seconds": 60
}

CRITICAL: The helper returns a send_nonce that you must echo back in the subsequent send request. The nonce is bound to the exact (to, text, service) triple and expires after send_nonce_ttl_seconds (default 60s). This enforces the preview-then-confirm gate at the helper level.

send_preview does not read chat.db and does not send anything. It only validates the recipient and body, resolves the contact name, and checks the blocklist.


send — Actually send the message

Request:

json
{"id": "abc123", "action": "send", "params": {"to": "+14155551234", "text": "Confirmed for 3pm.", "service": "iMessage", "send_nonce": "Zk9...short-opaque-string"}}

The send_nonce is the one returned by the preceding send_preview. The to, text, and service must match the preview exactly.

Response on success:

json
{
  "id": "abc123",
  "ok": true,
  "action": "send",
  "sent": {
    "to": "+14155551234",
    "resolved_name": "Alex",
    "service": "iMessage",
    "text_length": 18,
    "sent_at": "2026-08-12T00:15:42"
  }
}

Response on error:

json
{"id": "abc123", "ok": false, "error": "send gate: missing nonce; call send_preview first"}

Or:

json
{"id": "abc123", "ok": false, "error": "send cancelled by user or timed out (60s dialog limit)"}

The helper writes text to a temporary UTF-8 file, shells out to /usr/bin/osascript with a short AppleScript, and deletes the tempfile (even on failure).

Send-gate validation (enforced helper-side):

  • The send_nonce must be present, fresh (within TTL), and match the payload.
  • Nonces are single-use: consumed on first send attempt, deleted on any validation failure.
  • Replaying a used nonce, sending without a nonce, or changing the payload after preview all result in rejection before the confirmation dialog appears.
  • After nonce validation succeeds, the helper displays a native macOS dialog showing the resolved name, exact recipient address, service, and full message text in a scrollable view. Cancel is the keyboard default. The user must deliberately select Send; cancelling or waiting 60 seconds aborts the send.
  • Text must be 1–4000 chars with no C0 control bytes other than \n, \r, \t.
  • Recipient must not be on contacts/blocked_chats.txt.
  • Group chat IDs are NOT supported as send targets. Only individual phone numbers or email addresses work for sending.

Sending Flow (Preview → Confirm → Send)

Recommended workflow every time:

  1. Resolve the recipient. If the user provided a name, call contacts_lookup first. If multiple matches, surface them and ask. Note: Group chat IDs cannot be used as send targets—only individual phone numbers or email addresses.
  2. Issue send_preview. Show the user:
    • Resolved recipient name
    • Service (iMessage / SMS)
    • Full text and text_length
    • Whether blocked: true (if so, stop—don't prompt for approval)
  3. Wait for explicit user approval in the chat. Do not proceed without confirmation.
  4. Issue send with the send_nonce from step 2. The to, text, and service must match the preview exactly.
  5. The helper will display a native macOS dialog for final confirmation. The user must click Send in this system dialog.
  6. If the chat approval takes >60s, re-run send_preview to mint a fresh nonce.
  7. Surface sent.sent_at and resolved name as confirmation.

Example shell workflow:

bash
BRIDGE="$HOME/imessage-bridge"
REQ_ID_PREVIEW=$(uuidgen | tr '[:upper:]' '[:lower:]' | head -c 12)

# Step 1: send_preview (atomic write)
TMP="$BRIDGE/control/requests/.request-$REQ_ID_PREVIEW.json.tmp"
FINAL="$BRIDGE/control/requests/request-$REQ_ID_PREVIEW.json"

cat > "$TMP" <<EOF
{"id": "$REQ_ID_PREVIEW", "action": "send_preview", "params": {"to": "+14155551234", "text": "Confirmed for 3pm.", "service": "iMessage"}}
EOF
mv "$TMP" "$FINAL"

# Poll for preview response
for i in {1..30}; do
  if [[ -f "$BRIDGE/control/responses/response-$REQ_ID_PREVIEW.json" ]]; then
    PREVIEW_RESPONSE="$BRIDGE/control/responses/response-$REQ_ID_PREVIEW.json"
    PREVIEW=$(cat "$PREVIEW_RESPONSE")
    rm -f "$PREVIEW_RESPONSE"
    echo "$PREVIEW"
    break
  fi
  sleep 0.5
done

# Extract send_nonce from preview response (use jq or similar)
SEND_NONCE=$(echo "$PREVIEW" | jq -r '.send_nonce')

# Show preview to user, wait for approval...

# Step 2: send (after user approval, atomic write)
REQ_ID_SEND=$(uuidgen | tr '[:upper:]' '[:lower:]' | head -c 12)
TMP="$BRIDGE/control/requests/.request-$REQ_ID_SEND.json.tmp"
FINAL="$BRIDGE/control/requests/request-$REQ_ID_SEND.json"

cat > "$TMP" <<EOF
{"id": "$REQ_ID_SEND", "action": "send", "params": {"to": "+14155551234", "text": "Confirmed for 3pm.", "service": "iMessage", "send_nonce": "$SEND_NONCE"}}
EOF
mv "$TMP" "$FINAL"

# Poll for send response
for i in {1..30}; do
  if [[ -f "$BRIDGE/control/responses/response-$REQ_ID_SEND.json" ]]; then
    SEND_RESPONSE="$BRIDGE/control/responses/response-$REQ_ID_SEND.json"
    cat "$SEND_RESPONSE"
    rm -f "$SEND_RESPONSE"
    break
  fi
  sleep 0.5
done

Common Pitfalls

  • FDA not granted yet. First request returns sqlite3.OperationalError: unable to open database file in control/log.txt. Tell the user to grant FDA to the exact wrapper path printed by their installer.
  • Wrapper re-signed. If the user rebuilt the wrapper, the FDA grant needs to be removed and re-added (macOS identifies the binary by CDHash, not path).
  • Ambiguous contact name. chat: "Alex" resolves via the first contact whose name contains "Alex"—may not be the intended one. Fall back to phone number if the user has multiple Alexes.
  • Group chats. Group chat IDs look like chat1234567…. The review and chat_history actions accept these, but sending to group chats is NOT supported. Use individual phone numbers or emails for sending. Attempting to send to a chatNNNN identifier will be rejected at the preview stage.
  • Wrong folder selected. If the user tells you a new bridge folder path, re-verify that the helper is installed there before proceeding.

Redaction and Privacy

The helper redacts before writing the response:

  • 2FA / verification codes near words like "code", "verification", "OTP"
  • Credit-card-like digit runs (13–19 digits)
  • US SSN patterns

The active read policy is applied before response JSON is written. The hardened default returns only root-allowlisted chats; the blocklist always removes listed threads. Treat redaction as a second line of defense.

Known redaction gaps (see docs/PROTOCOL.md for full list):

  • Dot-separated credit cards
  • PIN-labelled codes
  • API keys
  • Bank account numbers
  • Home addresses
  • Dates of birth

The read policy is the reliable filter; redaction is a second line of defense.


Troubleshooting

SymptomCauseFix
Requests pile up in control/requests/, no responsesFDA not granted yetGrant FDA to the wrapper binary (path printed by install.sh)
sqlite3.OperationalError: unable to open database file in log.txtFDA not granted, or grant staleRe-add the wrapper in System Settings → Full Disk Access
First send fails with Automation promptmacOS needs Automation permissionClick OK on the prompt; future sends will work
send gate: missing noncesend called without prior send_previewAlways call send_preview first and pass the returned nonce
send payload differs from previewBody or recipient changed after previewRe-run send_preview to mint a fresh nonce for the new payload
Messages decode as emptyattributedBody parser failedCheck control/log.txt for a byte-count-only parser diagnostic

Check <bridge>/control/log.txt first when debugging. It contains helper stderr and logging.


What the Helper Won't Do

  • No attachments, images, stickers, audio, Tapback reactions. Text fields only.
  • No message editing or deletion. Once sent, a message is immutable from the helper's perspective.
  • No message effects (balloons, confetti, invisible ink).
  • No group-chat sending. Group chat IDs can be read (review, chat_history), but cannot be used as send targets. Sending requires individual phone numbers or email addresses.
  • No group-chat creation. Cannot create new group chats.
  • Only reads local chat.db. If a thread hasn't synced to this Mac, it won't appear in search/review.

Security Notes

  • The bridge folder is mode 700 (user-only access).
  • The helper runs with Full Disk Access—a bug or compromise becomes a full-user-file-read primitive.
  • Nonces are single-use and expire after 60s. A process that can write to the bridge folder can still exfiltrate message content by crafting a read request, but it cannot silently send without racing a real user-approved preview.
  • See SECURITY.md for full threat-model details.

References

  • Full protocol documentation: docs/PROTOCOL.md
  • Smoke test: docs/SMOKE_TEST.md
  • Security details: SECURITY.md

License

This skill is part of the grokbot-imessage-skill project, licensed under MIT.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Imessage Grok Bot?

Read, search, triage, and send iMessages on macOS via the iMessage helper bridge. Use when the user asks to review messages, find messages that need a reply, search message history, pull a conversation, compute response-time stats, or send a plain-text iMessage. macOS only—uses an on-device launchd helper to query the Messages SQLite database and AppleScript (osascript) to send outbound messages.

Firwat Imessage Grok Bot op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Imessage Grok Bot besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Imessage Grok Bot an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/jeffhuber/grokbot-imessage-skill/tree/main an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Imessage Grok Bot benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Imessage Grok Bot benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Imessage Grok Bot domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Imessage Grok Bot gratis?

Jo. jeffhuber huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇