Skip to main content
Short, complete patterns built on the real API. They assume you already have a connected client — see the Quickstart for setup.

Extract text from any message

Incoming text can arrive as a plain conversation or an extendedTextMessage (when it has a reply/preview). Normalize both:

Command router

Parse a leading /command and dispatch. Skip your own outgoing messages with event.key.fromMe:

Reply with a quote and a mention

Auto-download incoming media

Stream straight to disk — never buffer large files in memory:
See Media › Downloading incoming media for video/audio/documents and maxBytes.

Welcome new group members

The group event fires on membership changes. Greet everyone added (action: 'add') and @-mention them:

Send a poll

React to a message

Keep the bot alive across drops

zapo doesn’t auto-reconnect — wire the connection event to a backoff loop. The full pattern (including when not to reconnect) is in Reconnection and Errors & disconnects.
Every snippet uses the content union — the same shapes client.message.send accepts everywhere. See Sending messages and the message types reference for the full set.
Last modified on May 29, 2026