> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Message

> Variables - Message

The `Message` variable exposes the last message sent by the user that triggered your workflow. 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

```json theme={null}
{
  "type": "TEXT",
  "text": "Hello"
}
```

### Audio

> Audio is automatically transcribed when possible. You will receive both the file URL and the recognized text.

```json theme={null}
{
  "type": "AUDIO",
  "mediaUrl": "https://cdn.jelou.ai/...mp3",
  "contentType": "mp3",
  "text": "This is an audio message"
}
```

### Image

```json theme={null}
{
  "type": "IMAGE",
  "mediaUrl": "https://cdn.jelou.ai/....png",
  "caption": "This is an image",
  "width": 680,
  "height": 462,
  "length": 58137
}
```

### Video

```json theme={null}
{
  "type": "VIDEO",
  "mediaUrl": "https://cdn.jelou.ai/....mp4",
  "caption": "This is a video"
}
```

### Location

```json theme={null}
{
  "type": "LOCATION",
  "lat": "-2.1646540164948",
  "lng": "-79.895797729492",
  "url": "http://maps.google.com/maps..."
}
```

### File

```json theme={null}
{
  "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')`:

```js theme={null}
const firstMessage = $message.get('text')
const messageType = $message.get('type')
const attachmentUrl = $message.get('mediaUrl')
```

<Info>
  `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".
</Info>
