Skip to main content
Connect your AI agent to WhatsApp with a single command. Choose between the official Cloud API (production) or Web mode (scan a QR code, no tokens needed).

Quick Start

No tokens, no developer account — just scan a QR code.
1

Install

pip install 'praisonai[bot-whatsapp-web]'
2

Start

praisonai bot whatsapp --mode web
A QR code appears in your terminal. Open WhatsApp → Linked Devices → scan it.
3

Chat

Open your own contact (message yourself) and send a message. The bot replies.
Experimental — Web mode uses a reverse-engineered protocol. Your number may be banned by WhatsApp. Use Cloud API for production.

How It Works

Cloud API vs Web Mode

FeatureCloud APIWeb Mode
SetupMeta developer account + tokensQR code scan
StabilityOfficial, stableReverse-engineered, may break
WebhooksRequired (public HTTPS)Not needed
GroupsDMs onlyDMs + groups
RiskNoneAccount may be banned
Best forProductionDevelopment, personal use

Message Filtering

By default, the bot responds only to self-chat — when you message your own number. This prevents it from replying to every conversation.

Four Layers of Protection

Stale Message Guard

Messages older than when the bot connected are dropped. Prevents replaying old conversations on reconnect.

Self-Chat Check

Only messages where sender = chat JID pass.

Outgoing Guard

Your messages sent to other people’s chats are always blocked — even if they’re in the allowlist.

Allowlists

Optionally allow specific phone numbers or groups.

Expand Who Can Message the Bot

praisonai bot whatsapp --mode web
Only responds when you message your own number.

Filtering Matrix

ScenarioDefault--respond-to 123--respond-to-groups g@g.us--respond-to-all
Self-chat (your own number)
Your msg in someone else’s chat
DM from 123
DM from 999
Group g@g.us
Other group
Old/offline messages
Phone numbers are normalized automatically — +1-234-567-890 and 1234567890 match the same number.

Python SDK Filtering

from praisonai.bots import WhatsAppBot

bot = WhatsAppBot(
    mode="web",
    agent=agent,
    allowed_numbers=["1234567890", "9876543210"],
    allowed_groups=["120363123456@g.us"],
    respond_to_all=False,  # default
)

YAML Config

platform: whatsapp
mode: web

respond_to:
  - "1234567890"
respond_to_groups:
  - "120363123456@g.us"
respond_to_all: false

agent:
  name: "My Assistant"
  instructions: "You are a helpful AI assistant."
  llm: "gpt-4o-mini"
praisonai bot start --config bot.yaml

Built-in Commands

CommandDescription
/helpShow available commands
/statusBot info, model, uptime
/newReset conversation session
Register custom commands:
@bot.on_command("ping")
async def ping(msg):
    return "Pong!"

CLI Options

praisonai bot whatsapp --mode web [OPTIONS]
FlagDescriptionExample
--modecloud (default) or web--mode web
--respond-toAllowed phone numbers (comma-separated or repeated)--respond-to 123,456 or --respond-to 123 --respond-to 456
--respond-to-groupsAllowed group JIDs (comma-separated or repeated)--respond-to-groups grp@g.us
--respond-to-allRespond to everyone--respond-to-all
--creds-dirCredentials directory--creds-dir ~/.myapp/wa
--agentAgent YAML config--agent agents.yaml
--memoryEnable conversation memory--memory
--webEnable web search tool--web
--thinkingExtended thinking mode--thinking high
--auto-approveAuto-approve tool calls--auto-approve

Architecture

Key Components

ComponentRole
WhatsAppBotMain bot class — handles lifecycle, filtering, routing
WhatsAppWebAdapterBridges neonize (Go) events to Python asyncio
Session ManagerPer-user conversation sessions with expiry
Message FilterStale guard → self-chat check → allowlist check
AI AgentYour configured agent processes the message and responds

Troubleshooting

Fixed in latest version. The stale-message guard drops any message older than when the bot connected. If you still see this, update to the latest version:
pip install --upgrade praisonai
Fixed in latest version. The default filter now checks that both the sender AND chat JID match (true self-chat), not just IsFromMe. Update your installation.
WARNING Ignoring message ... failed to decrypt prekey message
WARNING Ignoring message ... failed to decrypt group message
These are normal and harmless. They come from the WhatsApp protocol layer (whatsmeow) when old session keys can’t decrypt certain messages. The bot automatically suppresses most of these. They don’t affect functionality.
[ERROR] SessionCipher.go:310 ▶ Unable to get or create message keys
This is an upstream protocol error from the Signal encryption layer. It means a message had expired keys. This is not a bug in PraisonAI — it’s a normal part of the WhatsApp protocol. The message is simply skipped.
WARNING Error sending close to websocket
This appears when Ctrl+C is pressed. It’s harmless — the bot is disconnecting from WhatsApp servers. The latest version suppresses this warning.
ERROR Error executing command: No such file or directory: '/home/user'
This happens when the AI agent tries to run a command in /home/user (a Linux path) on macOS. Fixed in latest version — the tool now automatically falls back to your home directory.
Exception ignored in: <module 'threading' ...>
KeyboardInterrupt
Fixed in latest version. The bot now properly shuts down background threads on exit. Update your installation.
  1. Use a modern terminal (iTerm2, Windows Terminal)
  2. Ensure segno is installed: pip install 'praisonai[bot-whatsapp-web]'
  3. If a saved session exists, no QR is needed. Delete to re-link:
rm -rf ~/.praisonai/whatsapp/
WhatsApp Web sessions expire if your phone is offline for 14+ days. Delete and re-scan:
rm -rf ~/.praisonai/whatsapp/
praisonai bot whatsapp --mode web