Documentation

Complete guide to deploying and using your WhatsApp Claude Agent.

Overview

WhatsApp Claude Agent connects Claude AI to WhatsApp, allowing you to chat with Claude directly from your phone. The agent runs on your own infrastructure (Railway) using your own API keys.

Key features:

Prerequisites

Before you begin, you'll need:

Requirement Where to Get It
Anthropic API Key console.anthropic.com
Railway Account railway.app (free tier available)
WhatsApp Account Phone with WhatsApp installed
About Costs

Railway's free tier works but may not persist sessions. For reliable operation, the paid tier (~$5/mo) is recommended. Anthropic charges per API usage — see Costs section.

Deployment

Follow these steps to deploy your WhatsApp Claude Agent:

1 Click Deploy Button

Go to the homepage and click the "Deploy on Railway" button. You'll be redirected to Railway to configure your deployment.

2 Configure Environment Variables

Railway will prompt you to enter two required values:

Variable Value Example
ANTHROPIC_API_KEY Your API key from Anthropic sk-ant-api03-xxx...
WHATSAPP_WHITELIST Your phone number with country code +14155551234

3 Deploy and Wait

Click "Deploy" and wait approximately 2-3 minutes for Railway to build and start your container. You can watch the progress in the Railway dashboard.

4 Get Your Deployment URL

Once deployed, Railway will provide a public URL like https://your-app.up.railway.app. If you don't see it, go to your project > Settings > Networking > Generate Domain.

5 Scan QR Code

Open the deployment URL in your browser. You'll see a QR code. Scan it with WhatsApp:

  1. Open WhatsApp on your phone
  2. Go to Settings → Linked Devices
  3. Tap "Link a Device"
  4. Point your camera at the QR code
You're Ready!

Once authenticated, you can start sending messages to Claude via WhatsApp.

Environment Variables

Configure your agent's behavior with these environment variables:

Variable Required Default Description
ANTHROPIC_API_KEY Yes Your Anthropic API key
WHATSAPP_WHITELIST Yes Allowed phone number(s)
PERMISSION_MODE No default Claude's permission level
WORKING_DIRECTORY No /app Directory for file operations
AGENT_NAME No Claude Custom name for the agent
MODEL No claude-sonnet-4-20250514 Claude model to use
PORT No 3000 QR server port

Permission Modes

Control what Claude can do with different permission modes:

Mode Description
default Claude asks for permission before making changes
acceptEdits Claude can edit files without asking, but asks for other operations
bypassPermissions Claude can perform any operation without asking
plan Claude plans actions but doesn't execute them
Use with Caution

bypassPermissions mode gives Claude full control. Only use this if you understand the implications.

Scanning QR Code

Via Web Page (Recommended)

Open your deployment URL in any browser. The page will show:

The page auto-refreshes every few seconds, so you'll see updates automatically.

Via Deployment Logs

Alternatively, view the QR code in Railway's deployment logs:

  1. Go to your Railway dashboard
  2. Click on your deployment
  3. Click "View Logs"
  4. Find the ASCII QR code in the output

Chatting with Claude

Once connected, simply send messages via WhatsApp. Claude will respond to any message from your whitelisted number.

Example Conversations

You: What's the capital of France?
Claude: The capital of France is Paris.

You: Write a Python function to calculate fibonacci numbers
Claude: Here's a Python function for Fibonacci numbers:

def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

You: Can you help me debug this code? [paste code]
Claude: I'd be happy to help! Looking at your code...

WhatsApp Commands

The agent supports special commands you can send via WhatsApp:

Command Description
/session Show current session info
/fork Create a branch of the current conversation
/mode [mode] Change permission mode
/model [model] Change Claude model
/prompt [text] Set custom system prompt
/config View current configuration

Troubleshooting

QR code not showing

QR code expired

Bot not responding

Session disconnected

"Unauthorized" or API errors

Costs

Service Cost Notes
Railway (Free tier) $0/mo Limited hours, sessions may not persist
Railway (Paid) ~$5/mo Persistent storage, always-on
Anthropic API Pay per use See anthropic.com/pricing
Typical Usage

For casual use (a few conversations per day), expect ~$5-15/month total including Railway and API costs.

Security

What's protected

Best practices

WhatsApp Terms of Service

Automated WhatsApp usage may violate WhatsApp's Terms of Service. Use at your own risk and avoid high-volume messaging.