Connect (QR login)¶
connect is the heart of PyWacli. It launches the Node.js Baileys bridge, shows the login QR,
and then owns the single live WhatsApp socket — streaming events, saving them to the database, and
hosting a small local command server so other commands can send through the same connection.
Start a session¶
- PyWacli starts the WhatsApp bridge and prints "Waiting for QR code…".
- A QR code renders in the terminal.
- On your phone: WhatsApp → Settings → Linked Devices → Link a Device, then scan.
- You'll see
Connected as <your-number>.
Keep this terminal open — closing it ends the session. Press Ctrl+C to disconnect cleanly.
What happens under the hood¶
flowchart LR
A[WhatsApp mobile] -- Baileys --> B[Node bridge\nbaileys_service.js]
B -- JSON events over stdout --> C[Python event processor]
C --> D[(Database)]
C --> E[Media storage\nS3 / R2 / B2 / local]
F[Send / Automate] -- local command server --> B
- Incoming events (messages, edits, reactions, statuses, media) are normalized to JSON and saved.
- Media is downloaded and synced to your configured storage targets.
- A local command server (default
127.0.0.1:8765) lets Send and Automate push outgoing messages through this one connection.
Reconnects & logout¶
- If the socket drops, PyWacli reconnects automatically (unless you logged out from the phone).
- If you log out, it waits and shows a fresh QR to re-link.
One session, many terminals
You only need one connect session. Run the dashboard, send, and automate in separate
terminals — they all coordinate through the running session and the shared database.
Troubleshooting¶
QR code never appears
Make sure Node.js is installed and the Baileys deps are present. Run pywacli init to install
them, then try again.
“WhatsApp service not reachable” when sending
The Send menu talks to a running connect session over the local command server. Start
pywacli connect in another terminal first, then send.