From agent-messenger
Interact with WhatsApp via CLI: send messages, read/list chats, manage conversations and accounts. Authenticates as companion device using QR code or pairing code for AI agents.
npx claudepluginhub agent-messenger/agent-messenger --plugin agent-channeltalkbotThis skill is limited to using the following tools:
A Baileys-backed WhatsApp CLI for AI agents. Links as a companion device via QR code or pairing code, so your phone stays connected. Each command connects on demand and disconnects when done.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
A Baileys-backed WhatsApp CLI for AI agents. Links as a companion device via QR code or pairing code, so your phone stays connected. Each command connects on demand and disconnects when done.
Use one of these entrypoints:
agent-whatsapp ...bunx --package agent-messenger agent-whatsapp ...Before diving in, a few things about WhatsApp's architecture:
1234567890@s.whatsapp.net. Group: 123456789-123345@g.us. You can pass plain phone numbers and the CLI resolves them to JIDs automatically.auth list and auth use to switch between them.# Link as companion device via QR code (scan with your phone)
agent-whatsapp auth login --qr
# Or link via pairing code (enter the code on your phone)
agent-whatsapp auth login --phone +1234567890
# List chats
agent-whatsapp chat list
# Send a message
agent-whatsapp message send +1234567890 "Hello from agent-whatsapp"
WhatsApp supports two authentication methods. Both register the CLI as a companion (linked) device, so your phone session is never affected.
--qr): A QR code is displayed in the terminal and opened in the browser. Scan it with WhatsApp on your phone. No phone number needed.--phone): A numeric code is displayed. Enter it in WhatsApp on your phone under Linked Devices > Link with phone number.When a command fails because no account is configured, the agent MUST drive the auth flow itself. Never tell the user to run commands. The agent runs everything.
Step 1: Check for existing accounts
agent-whatsapp auth list
If accounts exist, use agent-whatsapp auth use <account-id> and retry the original command.
Step 2: If no accounts, start QR login (preferred)
agent-whatsapp auth login --qr
# -> QR code displayed in terminal + opened in browser
# -> {"next_action":"scan_qr","qr_url":"...","message":"Scan with WhatsApp on your phone"}
Tell the user to scan the QR code with WhatsApp: Settings > Linked Devices > Link a Device > scan the QR code.
Alternative: Pairing code login
If QR scanning is not possible (e.g. headless environment), ask for the phone number and use pairing code:
agent-whatsapp auth login --phone +1234567890
# -> {"pairing_code":"A1B2-C3D4","message":"Enter this code in WhatsApp > Linked Devices > Link with phone number"}
Tell the user the pairing code and ask them to enter it on their phone.
Step 3: Wait for confirmation
The CLI waits until the user confirms on their phone. Once confirmed:
# -> {"authenticated":true,...}
Step 4: Retry the original command
After successful auth, immediately execute whatever the user originally asked for.
agent-whatsapp auth status # Check current auth state
agent-whatsapp auth status --account <id> # Check specific account
agent-whatsapp auth list # List all linked accounts
agent-whatsapp auth use <id> # Switch active account
agent-whatsapp auth logout # Unlink current account
agent-whatsapp auth logout --account <id> # Unlink specific account
The agent maintains a ~/.config/agent-messenger/MEMORY.md file as persistent memory across sessions. This is agent-managed. The CLI does not read or write this file. Use the Read and Write tools to manage your memory file.
At the start of every task, read ~/.config/agent-messenger/MEMORY.md using the Read tool to load any previously discovered chat IDs, contact names, and preferences.
After discovering useful information, update ~/.config/agent-messenger/MEMORY.md using the Write tool. Write triggers include:
chat list)When writing, include the complete file content. The Write tool overwrites the entire file.
Never store auth credentials, session keys, or any sensitive data. Never store full message content (just IDs and chat context).
If a memorized JID returns an error, remove it from MEMORY.md. Don't blindly trust memorized data. Prefer re-listing over using a memorized JID that might be stale.
# Agent Messenger Memory
## WhatsApp Account
- Phone: +1234567890
- JID: 1234567890@s.whatsapp.net
## Chats
- `1234567890@s.whatsapp.net` - Alice (1:1)
- `5678901234@s.whatsapp.net` - Bob (1:1)
- `123456789-123345@g.us` - Project Team (group, 8 members)
- `987654321-654321@g.us` - Family (group, 5 members)
## Aliases
- "alice" -> `1234567890@s.whatsapp.net`
- "project" -> `123456789-123345@g.us` (Project Team)
- "family" -> `987654321-654321@g.us` (Family group)
## Notes
- User prefers --pretty output
- Project Team is the most frequently used chat
Memory lets you skip repeated
chat listcalls. When you already know a JID from a previous session, use it directly.
# Link as companion device via QR code (no phone number needed)
agent-whatsapp auth login --qr
# Link as companion device via pairing code
agent-whatsapp auth login --phone +1234567890
# Check auth status
agent-whatsapp auth status
agent-whatsapp auth status --account <id>
# List linked accounts
agent-whatsapp auth list
# Switch active account
agent-whatsapp auth use <id>
# Unlink account
agent-whatsapp auth logout
agent-whatsapp auth logout --account <id>
# Show current authenticated user
agent-whatsapp whoami
agent-whatsapp whoami --pretty
agent-whatsapp whoami --account <account-id>
Output includes the authenticated user's identity information.
# List chats (sorted by most recent activity)
agent-whatsapp chat list
agent-whatsapp chat list --limit 50
agent-whatsapp chat list --account <id>
# Search chats by name
agent-whatsapp chat search "project"
agent-whatsapp chat search "project" --limit 10
agent-whatsapp chat search "project" --account <id>
Output includes:
jid - chat JID (individual or group)name - contact or group nameunread_count - unread message countlast_message - most recent message preview# List messages in a chat
agent-whatsapp message list <chat> --limit 20
agent-whatsapp message list +1234567890 --limit 50
agent-whatsapp message list 123456789-123345@g.us --limit 10
agent-whatsapp message list +1234567890 --limit 20 --account <id>
# Send a text message
agent-whatsapp message send <chat> <text>
agent-whatsapp message send +1234567890 "Hello!"
agent-whatsapp message send 123456789-123345@g.us "Hello team!"
agent-whatsapp message send +1234567890 "Hello!" --account <id>
# React to a message
agent-whatsapp message react <chat> <message-id> <emoji>
agent-whatsapp message react +1234567890 ABC123DEF456 "๐"
agent-whatsapp message react +1234567890 ABC123DEF456 "๐" --from-me
agent-whatsapp message react +1234567890 ABC123DEF456 "๐" --account <id>
The <chat> argument accepts:
+1234567890 (auto-resolved to JID)1234567890@s.whatsapp.net123456789-123345@g.usThe --from-me flag on message react indicates the target message was sent by you (outgoing). Without it, the reaction targets an incoming message.
All commands output JSON by default for AI consumption:
{
"jid": "1234567890@s.whatsapp.net",
"name": "Alice",
"unread_count": 3,
"last_message": {
"id": "ABC123DEF456",
"text": "See you tomorrow!",
"from": "1234567890@s.whatsapp.net",
"timestamp": 1705312200
}
}
Use --pretty flag for formatted output:
agent-whatsapp chat list --pretty
| Option | Description |
|---|---|
--pretty | Human-readable output instead of JSON |
--account <id> | Use a specific account for this command |
# List chats to see unread counts
agent-whatsapp chat list --limit 20
# Read messages from a specific chat
agent-whatsapp message list +1234567890 --limit 10
# By phone number (simplest)
agent-whatsapp message send +1234567890 "Hey, are we still on for tomorrow?"
# By JID
agent-whatsapp message send 1234567890@s.whatsapp.net "Hey, are we still on for tomorrow?"
# Find the group first
agent-whatsapp chat search "Project Team"
# Send to the group JID
agent-whatsapp message send 123456789-123345@g.us "Status update: deployment complete."
# Get the latest message ID
agent-whatsapp message list +1234567890 --limit 1
# React to it
agent-whatsapp message react +1234567890 <message-id> "๐"
All commands return consistent error format:
{
"error": "No WhatsApp account linked. Run: agent-whatsapp auth login --qr"
}
Common errors:
No WhatsApp account linked - not authenticated. Run auth login --qr or auth login --phone <number>.Connection timeout - WebSocket connection to WhatsApp failed. Retry the command.Invalid JID - malformed phone number or JID. Use international format with + prefix.Not a group participant - can't send to a group you're not a member of.1234567890@s.whatsapp.net, groups use 123456789-123345@g.us. Phone numbers can be passed directly and are auto-resolved.auth list to see all accounts and auth use <id> to switch.+1234567890, +821012345678).agent-whatsapp returns JSON by default and --pretty for indented output.agent-whatsapp: command not foundagent-whatsapp is NOT the npm package name. The npm package is agent-messenger.
If the package is installed globally, use agent-whatsapp directly:
agent-whatsapp chat list --pretty
If the package is NOT installed, use --package to install and run:
npx -y --package agent-messenger agent-whatsapp chat list --pretty
bunx --package agent-messenger agent-whatsapp chat list --pretty
pnpm dlx --package agent-messenger agent-whatsapp chat list --pretty
NEVER run npx agent-whatsapp, bunx agent-whatsapp, or pnpm dlx agent-whatsapp without --package agent-messenger. It will fail or install a wrong package since agent-whatsapp is not the npm package name.
auth login --qr again for a fresh codeauth login --phone <number>auth login --phone <number> again for a fresh codeWhatsApp companion devices receive their chat list from the primary phone โ there's no server API to fetch it directly. On a freshly linked device, chat list may return only group chats (or nothing at all) for individual/DM conversations.
chat list again. History trickles in over time and is saved locally, so subsequent runs will show more chats.This is a WhatsApp protocol limitation, not a bug.
WhatsApp may disconnect linked devices that are inactive for extended periods. If commands start failing:
# Check if still linked
agent-whatsapp auth status
# Re-link if needed
agent-whatsapp auth login --qr