High-level helpers for constructing and sending WhatsApp messages.
This module handles:
- Message ID generation
- Message node construction
- Protobuf payload encoding
- Message routing (direct, group, broadcast)
Message Flow
1. User calls send_text/3
2. Message proto is built and encoded
3. Binary node is constructed with proper attributes
4. Signal encryption is applied (when implemented)
5. Node is sent via the connectionExample
# Simple text message
ExWapp.Messages.send_text(session, "1234567890@s.whatsapp.net", "Hello!")
# Reply to a message
ExWapp.Messages.send_text(session, jid, "Reply text",
quoted_id: "ABC123",
quoted_participant: "sender@s.whatsapp.net"
)
Summary
Functions
Builds an audio message protobuf from uploaded media metadata.
Builds a single WhatsApp contact-card protobuf.
Builds context info for replies and mentions.
Builds a document message protobuf from uploaded media metadata.
Builds WhatsApp's calendar event message (E2E Message field 75).
Builds an image message protobuf from uploaded media metadata.
Builds a static or live GPS location protobuf.
Builds the binary XML node for a message.
Builds a protocol message requesting resend of an unavailable placeholder.
Builds a presence subscription request.
Builds a receipt node for read/played acknowledgments.
Builds a text message protobuf.
Builds a typing indicator node.
Builds a typing indicator node while preserving the legacy three-argument
API. WhatsApp no longer accepts the local sender identity in chat-state
attributes, so from_jid is intentionally ignored.
Generates a unique message ID matching whatsmeow/Baileys/whatsapp-rust format.
Sends a delivery receipt for a message.
Sends a read receipt for messages.
Sends a text message to a JID.
Types
Functions
@spec build_audio_proto( ExWapp.Media.Upload.t(), keyword() ) :: WAWebProtobufsE2E.Message.t()
Builds an audio message protobuf from uploaded media metadata.
Builds a single WhatsApp contact-card protobuf.
@spec build_context_info(keyword()) :: WAWebProtobufsE2E.ContextInfo.t() | nil
Builds context info for replies and mentions.
@spec build_document_proto( ExWapp.Media.Upload.t(), keyword() ) :: WAWebProtobufsE2E.Message.t()
Builds a document message protobuf from uploaded media metadata.
@spec build_event_proto(String.t(), integer() | DateTime.t(), keyword()) :: WAWebProtobufsE2E.Message.t()
Builds WhatsApp's calendar event message (E2E Message field 75).
WhatsApp Web also attaches a 32-byte message secret to event messages; it is
generated automatically unless :message_secret is supplied.
@spec build_image_proto( ExWapp.Media.Upload.t(), keyword() ) :: WAWebProtobufsE2E.Message.t()
Builds an image message protobuf from uploaded media metadata.
Builds a static or live GPS location protobuf.
@spec build_message_node(String.t(), String.t(), binary(), integer(), keyword()) :: ExWapp.Binary.Node.t()
Builds the binary XML node for a message.
@spec build_placeholder_resend_proto(String.t(), String.t(), String.t(), keyword()) :: WAWebProtobufsE2E.Message.t()
Builds a protocol message requesting resend of an unavailable placeholder.
@spec build_presence_subscribe(String.t()) :: ExWapp.Binary.Node.t()
Builds a presence subscription request.
Builds a receipt node for read/played acknowledgments.
Builds a text message protobuf.
Builds a typing indicator node.
Builds a typing indicator node while preserving the legacy three-argument
API. WhatsApp no longer accepts the local sender identity in chat-state
attributes, so from_jid is intentionally ignored.
Generates a unique message ID matching whatsmeow/Baileys/whatsapp-rust format.
Format: "3EB0" + uppercase hex of SHA256(timestamp + ownJID@c.us + 16 random bytes)[:9] Total length: 22 characters (4 prefix + 18 hex).
@spec send_delivery_receipt(pid(), String.t(), String.t(), String.t() | nil) :: :ok | {:error, term()}
Sends a delivery receipt for a message.
Sends a read receipt for messages.
Sends a text message to a JID.
Options
:quoted_id- ID of message to reply to:quoted_participant- JID of quoted message sender (for groups):mentions- List of JIDs to mention
Returns
{:ok, message_id}- Message was queued for sending{:error, reason}- Failed to send