The Message variable exposes the last message sent by the user that triggered your skill. It is ideal when you need to react to the text, attachments, or metadata of the incoming message.
Message structure
The object changes depending on the type of message you receive. Below you will find real examples returned by WhatsApp.
Text
{
"type": "TEXT",
"text": "Hello"
}
Audio
Audio is automatically transcribed when possible. You will receive both the file URL and the recognized text.
{
"type": "AUDIO",
"mediaUrl": "https://cdn.jelou.ai/...mp3",
"contentType": "mp3",
"text": "This is an audio message"
}
Image
{
"type": "IMAGE",
"mediaUrl": "https://cdn.jelou.ai/....png",
"caption": "This is an image",
"width": 680,
"height": 462,
"length": 58137
}
Video
{
"type": "VIDEO",
"mediaUrl": "https://cdn.jelou.ai/....mp4",
"caption": "This is a video"
}
Location
{
"type": "LOCATION",
"lat": "-2.1646540164948",
"lng": "-79.895797729492",
"url": "http://maps.google.com/maps..."
}
File
{
"type": "FILE",
"mediaUrl": "https://cdn.jelou.ai/...",
"mimeType": "application/pdf",
"caption": "This is a file"
}
Accessing the last message
You can access the message from any node with the syntax {{$message.property}}:
{{$message.type}} indicates the type (TEXT, IMAGE, AUDIO, etc.).
{{$message.text}} returns the message content for TEXT types and the transcription for AUDIO.
{{$message.mediaUrl}} exposes the URL of the attached file (image, audio, video, or document).
{{$message.caption}} shows the additional text sent along with the file.
{{$message.lat}} and {{$message.lng}} deliver the coordinates when the type is LOCATION.
Message in code nodes
Inside a code node, access each property with $message.get('property'):
const firstMessage = $message.get('text')
const messageType = $message.get('type')
const attachmentUrl = $message.get('mediaUrl')
Message always shows the most recent message the user has sent. If it is the first time the user writes, that first message will also be considered the “last message”.