Skip to main content

Handling Messages

Messages, from a history sync or from a messages.upsert event, come in the form of proto.IWebMessageInfo. This is the protobuf that WhatsApp Web stores its messages in.

The message data specifically is in the format proto.IMessage. You can send messages in this format using the sock.relayMessage function.

Understanding the proto.IWebMessageInfo format

Explain the key, and other fields properly here.

That being said, let's look at some common message types:

Text Messages

Text based messages come in the form of proto.IMessage.conversation and proto.IMessage.extendedTextMessage. If the message comes in with reply data or attached metadata (link preview, group invite), then it is usually extendedTextMessage. Status updates are also only extendedTextMessage as it contains the fields for the color/font of the text-based status updates.

Handling this should be as easy as extracting the text from the

Media Messages

Media messages come in the following protobuf messages: proto.IMessage.audioMessage, proto.IMessage.documentMessage, proto.IMessage.imageMessage, video, sticker .. so on Handle missing media : -> sock.updateMediaMessage