to— the recipient (5511999999999@s.whatsapp.net, a group...@g.us, etc.). See JID helpers for building these.content— a string, a typed content object, or a rawProto.IMessage.options— quoting, mentions, forwarding, view-once, edits, and more.
WaMessagePublishResult once the server acks:
Plain text
The simplest content is a string:Replying (quoting)
Pass the original message event (or a reference) asoptions.quote:
Mentions
options.mentions is a list of JIDs to tag. Include the matching @number text in the body so WhatsApp renders the mention:
Link previews
Link-preview behavior is controlled per message via the text object’slinkPreview field:
linkPreview client option.
Forwarding
Setoptions.forward to mark a message as forwarded:
Send options reference
WaSendMessageOptions (third argument) includes:
Sending to a username
A username handle (@alice) is not an addressable JID on its own. Resolve it to the account’s LID with client.profile.resolveUsername first, then send to that JID — the send API takes the JID exactly like any other 1:1 recipient.
resolveUsername returns a discriminated union you have to switch on. Every case has a next step:
resolveUsername throws before any round-trip when the handle or the key fails local validation (bad characters, wrong length, reserved word, key that is not exactly 4 digits) — so a call that returns has passed local rules and the status reflects the server-side outcome.
The content union
content accepts any WaSendMessageContent. The typed variants are documented across these guides:
Media
Images, video, audio, documents, stickers.
Polls & reactions
Polls, votes, reactions, pins, edits, revokes, events.
Proto.IMessage for anything not covered by a typed builder:
Proto.IMessage fields (location, live location, contacts, group invite, product, order, …) is listed in the message types reference.