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:
Message-level context (messageContextInfo)
contextInfo above lands on the content submessage — that is where a quote, mentions and the expiration go. A few things live one level up, on the Message itself, and since 1.11.0 every typed content takes an optional messageContextInfo for them:
messageAssociation, which previously meant uploading the media and building the whole proto by hand.
Two rules decide what wins:
- Fields the builder already sets win over yours. A pin’s add-on duration, for instance, is stamped by the builder and your value is ignored.
- The send pipeline still merges its own metadata in — the message secret and device-list metadata are added on top of what you pass.
Proto.IMessage content is passed through untouched, so a hand-built proto keeps full control.
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.