From agent-messenger
Interact with Instagram DMs via CLI: list conversations, send messages, manage multiple accounts using browser cookie extraction or username/password auth with 2FA.
npx claudepluginhub agent-messenger/agent-messenger --plugin agent-channeltalkbotThis skill is limited to using the following tools:
An Instagram DM CLI for AI agents. Supports browser cookie extraction (zero-config, extracts from Chromium browsers) and username/password authentication (with 2FA). Uses Instagram's private mobile API to read and send direct messages.
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.
An Instagram DM CLI for AI agents. Supports browser cookie extraction (zero-config, extracts from Chromium browsers) and username/password authentication (with 2FA). Uses Instagram's private mobile API to read and send direct messages.
Use one of these entrypoints:
agent-instagram ...bunx --package agent-messenger agent-instagram ...chat list.auth list and auth use to switch between them.# Extract cookies from browser (recommended — zero-config)
agent-instagram auth extract
# Or: Log in with Instagram credentials (fallback)
agent-instagram auth login --username myaccount --password "mypassword"
# List DM conversations
agent-instagram chat list
# Send a message
agent-instagram message send <thread-id> "Hello from agent-instagram"
Instagram supports two authentication methods:
Sessions are persisted locally so you don't need to re-authenticate for every command. Browser extraction auto-runs when no session exists.
agent-instagram auth extract reads your Instagram session cookies from Chrome, Edge, Arc, Brave, Vivaldi, or Chromium. You must be logged into instagram.com in one of these browsers.
# Extract cookies from browser — zero-config
agent-instagram auth extract
# With debug output
agent-instagram auth extract --debug
How it works: The CLI reads Instagram cookies (sessionid, csrftoken, ds_user_id) directly from the browser's SQLite cookie database. No browser automation, no password prompts. The session is stored locally in ~/.config/agent-messenger/.
When to re-extract: Browser cookies expire. When your session expires, re-run agent-instagram auth extract or let auto-extraction handle it (the CLI attempts extraction automatically when no valid session exists).
Supported browsers: Chrome, Chrome Canary, Edge, Arc, Brave, Vivaldi, Chromium
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-instagram auth list
If accounts exist, use agent-instagram auth use <account-id> and retry the original command.
Step 2: Try browser extraction first
agent-instagram auth extract
# -> {"authenticated":true,"account_id":"12345678","username":"myaccount"}
If extraction succeeds, proceed with the original command.
Step 3: If extraction fails, ask for credentials
Ask the user for their Instagram username and password. These are the ONLY things the user needs to provide.
Step 4: Start login
agent-instagram auth login --username myaccount --password "mypassword"
# -> {"authenticated":true,"account_id":"myaccount","username":"myaccount"}
Step 4: Handle 2FA if required
If login returns two_factor_required, ask the user for the verification code:
# -> {"two_factor_required":true,"two_factor_identifier":"abc123","message":"..."}
Then complete verification:
agent-instagram auth verify --username myaccount --code 123456 --identifier abc123
# -> {"authenticated":true,"account_id":"myaccount","username":"myaccount"}
Step 5: Retry the original command
After successful auth, immediately execute whatever the user originally asked for.
agent-instagram auth extract # Extract cookies from browser (recommended)
agent-instagram auth extract --debug # Extract with debug output
agent-instagram auth status # Check current auth state
agent-instagram auth status --account <id> # Check specific account
agent-instagram auth list # List all stored accounts
agent-instagram auth use <id> # Switch active account
agent-instagram auth logout # Remove current account
agent-instagram auth logout --account <id> # Remove 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 thread 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, passwords, session tokens, or any sensitive data. Never store full message content (just IDs and chat context).
# Agent Messenger Memory
## Instagram Account
- Username: myaccount
- User ID: 12345678
## Conversations
- `340282366841710300949128138443434234567` - Alice (private)
- `340282366841710300949128138443434234568` - Bob (private)
- `340282366841710300949128138443434234569` - Project Team (group, 5 members)
## Aliases
- "alice" -> `340282366841710300949128138443434234567`
- "project" -> `340282366841710300949128138443434234569` (Project Team)
## Notes
- User prefers --pretty output
Memory lets you skip repeated
chat listcalls. When you already know a thread ID from a previous session, use it directly.
# Extract cookies from browser (recommended — zero-config)
agent-instagram auth extract
agent-instagram auth extract --debug
# Log in (interactive: prompts for username/password)
agent-instagram auth login
# Log in (non-interactive: pass credentials as flags)
agent-instagram auth login --username <username> --password <password>
# Log in with debug output (shows raw API responses)
agent-instagram auth login --username <username> --password <password> --debug
# Complete 2FA verification (non-interactive)
agent-instagram auth verify --username <username> --code <code> --identifier <identifier>
# Resolve a security challenge — send verification code
agent-instagram auth challenge --username <username> --method email
agent-instagram auth challenge --username <username> --method sms
# Resolve a security challenge — submit verification code
agent-instagram auth challenge --username <username> --code <code>
# Check auth status
agent-instagram auth status
agent-instagram auth status --account <id>
# List stored accounts
agent-instagram auth list
# Switch active account
agent-instagram auth use <id>
# Remove account
agent-instagram auth logout
agent-instagram auth logout --account <id>
# Show current authenticated user
agent-instagram whoami
agent-instagram whoami --pretty
agent-instagram whoami --account <account-id>
Output includes the authenticated user's identity information.
# List DM conversations (sorted by most recent activity)
agent-instagram chat list
agent-instagram chat list --limit 50
agent-instagram chat list --account <id>
# Search conversations by name
agent-instagram chat search "alice"
agent-instagram chat search "alice" --limit 10
agent-instagram chat search "alice" --account <id>
Output includes:
id - thread IDname - contact or group nametype - private or groupis_group - booleanparticipant_count - number of participantsunread_count - unread message countlast_message - most recent message preview# List messages in a conversation
agent-instagram message list <thread-id>
agent-instagram message list <thread-id> --limit 50
agent-instagram message list <thread-id> --limit 10 --account <id>
# Send a text message to a thread
agent-instagram message send <thread-id> <text>
agent-instagram message send <thread-id> "Hello!" --account <id>
# Send a text message to a user by @username
agent-instagram message send-to <username> <text>
agent-instagram message send-to @alice "Hello!"
# Search messages by text content
agent-instagram message search <query>
agent-instagram message search "meeting" --thread <thread-id>
agent-instagram message search "hello" --limit 10
# Search Instagram users by username
agent-instagram message search-users <query>
agent-instagram message search-users "alice"
All commands output JSON by default for AI consumption:
{
"id": "340282366841710300949128138443434234567",
"name": "Alice",
"type": "private",
"is_group": false,
"participant_count": 2,
"unread_count": 3,
"last_message": {
"id": "29876543210987654",
"thread_id": "340282366841710300949128138443434234567",
"from": "12345678",
"timestamp": "2026-03-29T10:30:00.000Z",
"is_outgoing": false,
"type": "text",
"text": "See you tomorrow!"
}
}
Use --pretty flag for formatted output:
agent-instagram chat list --pretty
| Option | Description |
|---|---|
--pretty | Human-readable output instead of JSON |
--account <id> | Use a specific account for this command |
# List conversations to see unread counts
agent-instagram chat list --limit 20
# Read messages from a specific conversation
agent-instagram message list <thread-id> --limit 10
# Find the contact first
agent-instagram chat search "Alice"
# Send to the thread ID
agent-instagram message send <thread-id> "Hey, are we still on for tomorrow?"
# Find the group
agent-instagram chat search "Project Team"
# Send to the group thread
agent-instagram message send <thread-id> "Status update: deployment complete."
All commands return consistent error format:
{
"error": "Not authenticated. Run \"agent-instagram auth login --username <username>\" first."
}
Common errors:
Not authenticated - no account configured. Run auth extract or auth login.Session expired or missing - session is no longer valid. Run auth extract to re-extract from browser, or auth login to log in again.Login failed - wrong username/password. Double-check credentials.Two-factor authentication failed - wrong 2FA code. Get a new code and try auth verify again.Rate limited - too many requests. Wait and retry.~/.config/agent-messenger/instagram/. Sessions may expire if Instagram detects unusual activity.auth list to see all accounts and auth use <id> to switch.agent-instagram returns JSON by default and --pretty for indented output.agent-instagram: command not foundagent-instagram is NOT the npm package name. The npm package is agent-messenger.
If the package is installed globally, use agent-instagram directly:
agent-instagram chat list --pretty
If the package is NOT installed, use --package to install and run:
npx -y --package agent-messenger agent-instagram chat list --pretty
bunx --package agent-messenger agent-instagram chat list --pretty
pnpm dlx --package agent-messenger agent-instagram chat list --pretty
NEVER run npx agent-instagram, bunx agent-instagram, or pnpm dlx agent-instagram without --package agent-messenger. It will fail or install a wrong package since agent-instagram is not the npm package name.
Instagram may require additional verification (e.g., confirming your identity from the Instagram app). Open the Instagram app on your phone, complete any security challenges, then try logging in again.
Instagram invalidates sessions based on device fingerprinting and activity patterns. If sessions expire often: