serverserv serverserv

How to connect WhatsApp to OpenClaw on your own server

By Siam Ahmed, software engineer · 10 min read · Updated

Install the WhatsApp plugin, set who may message the agent, scan a QR code from WhatsApp's "Linked devices" screen, then start the gateway. It takes about 10 minutes on a server that already runs OpenClaw.

Before you start

  • A server running OpenClaw. serverserv OpenClaw Hosting arrives ready.
  • A phone with WhatsApp. OpenClaw recommends a separate, dedicated number for the agent rather than your personal one.
  • A way to see the QR code live on screen. QR codes can expire if you send them as a screenshot.

Step 1: Install the WhatsApp plugin

openclaw plugins install @openclaw/whatsapp

Step 2: Decide who can message your agent

In your OpenClaw config, keep strangers out until you approve them:

{ channels: { whatsapp: { dmPolicy: "pairing", allowFrom: ["+14165550100"], groupPolicy: "allowlist", groupAllowFrom: ["+14165550100"], }, }, }

pairing means an unknown sender must be approved before the agent answers them. Replace the example number with your own.

Step 3: Link WhatsApp with a QR code

openclaw channels login --channel whatsapp

On your phone, open WhatsApp → Settings → Linked devices → Link a device, and scan the code.

Step 4: Start the gateway

openclaw gateway

If you set OpenClaw up as a service, it is already running.

Step 5: Approve the first message

openclaw pairing list whatsapp openclaw pairing approve whatsapp <CODE>

Requests expire after 1 hour, and each account can hold 3 pending requests at once.

Use your agent in WhatsApp groups

By default the agent only replies in a group when someone mentions it, which keeps it from answering every message. Three settings decide what happens:

  • groupPolicy: allowlist (only senders in groupAllowFrom), open (anyone in an allowed group) or disabled (no groups at all).
  • groups: leave it out to allow every group the number is in, or list group IDs to allow only those. "*" allows all.
  • requireMention: set groups["<group-id>"].requireMention: false if you want the agent to read and answer every allowed message in that group.

Replying to one of the agent's messages, or a voice note that mentions it, also counts as a mention.

Using your personal number instead

A dedicated number is recommended, but your own number works too. In that setup you message yourself to talk to the agent:

{ channels: { whatsapp: { dmPolicy: "allowlist", allowFrom: ["+14165550100"], selfChatMode: true, }, }, }

With selfChatMode on, messages you send to your own chat reach the agent. Set it to false if you only want the agent to answer other people. Keep dmPolicy on allowlist so friends and family who message you are not answered by an AI.

Troubleshooting

ProblemWhat to do
The QR code expires before you can scan itRun openclaw channels login --channel whatsapp again and scan it live from your screen, not from a screenshot or a chat message.
It says the account is not linkedLog in again, then check with openclaw channels status.
Linked, but it keeps disconnectingRun openclaw channels status --probe, openclaw doctor and openclaw logs --follow. If it keeps looping, back up the login folder, log out and link again (below).
Messages send nothingThe gateway is not running or the account is not linked. Check openclaw gateway status.
The reply shows in OpenClaw but never arrives in WhatsAppSearch the logs for "auto-reply delivery failed". A tick or reaction on your message does not prove the reply was delivered.
The agent ignores a groupCheck, in order: groupPolicy, groupAllowFrom, the groups list, requireMention, and duplicate keys in your config (a later entry overrides an earlier one).
QR login times out behind a proxyMake sure the gateway sees your HTTPS_PROXY settings, and that NO_PROXY does not include mmg.whatsapp.net.

Back up and re-link your WhatsApp login

OpenClaw stores the WhatsApp login in ~/.openclaw/credentials/whatsapp/<account>/. Back that folder up before you change anything, so you can restore it instead of scanning a new code:

cp -a ~/.openclaw/credentials/whatsapp/default ~/.openclaw/credentials/whatsapp/default.bak openclaw channels logout --channel whatsapp --account default openclaw channels login --channel whatsapp --account default

Replace default with your account name if you set one. You can link more than one WhatsApp number to the same agent with --account, for example a work number and a support number.

Good to know

  • OpenClaw connects through WhatsApp Web as a linked device, so keep the phone online now and then and do not log the device out.
  • Because it is a linked device rather than the official Business API, avoid bulk or unsolicited messages. Let customers message the agent first.
  • Files up to 50 MB go through by default (mediaMaxMb), images are resized automatically, and long replies are split into chunks of about 4,000 characters.
  • Use a dedicated number for customer-facing agents, and follow WhatsApp's own business rules.

Want this done for you? Our WhatsApp AI agent setup includes the server, the connection and your business details.

Prefer Telegram? Follow our OpenClaw Telegram or Discord setup guide. It takes about 10 minutes and the same agent can answer on both apps.

Questions

Do I need the WhatsApp Business API?

No. OpenClaw links to WhatsApp as a linked device, the same way WhatsApp Web does.

Can I use my personal WhatsApp number?

You can, but OpenClaw recommends a separate, dedicated number for the agent.

Why does my QR code not work?

QR codes expire quickly. Scan the code live from the screen rather than from a screenshot, and run the login command again if it times out.

Can the agent answer in WhatsApp groups?

Yes. Allow the group in your config. By default the agent replies only when it is mentioned; set requireMention to false for a group if it should answer every message there.

Why does WhatsApp keep disconnecting from OpenClaw?

Usually the phone has been offline for a long time or the linked device was logged out. Run openclaw channels status --probe and openclaw doctor, and if it keeps looping, back up the login folder and link again.

Can I connect two WhatsApp numbers?

Yes. Link each one with its own --account name, for example work and support. Each number keeps its own login and settings.

Sources

Skip the setup

OpenClaw Hosting arrives installed and secured on your own server.

See OpenClaw plansGet it done for you
Plans from $2.99/moSee plans