# Wait for message

> Wait for Message suspends until the user sends a message, then outputs the latest conversation context for downstream conversational nodes to consume.

## What it does

Waits until the user sends the next message on the conversation, then resumes with the latest **conversation context**: the chat history and user profile information: as its output.

**Always place a Wait for Message node immediately after the [conversation trigger](./node-conversation-trigger.md)** to ensure the workflow is ready for the user's first message. You can loop back to it for follow-up turns, or add more Wait for Message nodes elsewhere in the workflow.

![The Wait for message node selected, with Conversation ID set to {{ $vars.conversationTrigger1.output.conversationId }}, From set to User, and Exchange limit set to 10.](https://dev-assets.cms.uipath.com/assets/images/maestro-automate/chat-wait-for-message-automate-4f2edab2.webp)

## Inputs

| Field | Description |
|---|---|
| **Conversation ID** | The ID of the conversation to wait on. Bind to the conversation trigger's output, for example `$vars.conversationTrigger1.output.conversationId`. |
| **From** | The role of the message sender to wait for. It's set to **User** and can't be changed. |
| **Exchange limit** | Maximum number of past exchanges (back-and-forth turns) to include in the returned conversation history. Determines how many past messages in the conversation history are returned. |

## Output

| Field | Description |
|---|---|
| `conversationContext` | The latest conversation context, including the message history. |

The `conversationContext` contains the following fields:

| Field | Description |
|---|---|
| `latestExchangeId` | Identifier of the most recent exchange (back-and-forth turn). Use as the Exchange ID input to [Send Message](./node-send-message.md) when replying to the conversation. |
| `messages` | The recent conversation history, including both the user's and Maestro Automate's messages. **Exchange limit** determines how many past exchanges to include. |
| `userSettings` | User-level profile fields, configurable by the end-user on the channels. |

## Usage examples

Reference the full conversation context in a downstream [**Conversational Agent**](./node-conversational-agent.md) node:

```javascript
$vars.waitForMessage1.output.conversationContext
```

Reference the outputted `latestExchangeId` in a downstream [**Send Message**](./node-send-message.md) node:

```javascript
$vars.waitForMessage1.output.conversationContext.latestExchangeId
```

### Handling multiple Wait for Message nodes
**When you have multiple Wait for Message nodes**, you might accidentally configure a downstream node to reference a stale conversation context from a Wait for Message node that executed earlier.

To avoid that, check which Wait for Message node each downstream node reads from. Select the value with **{ } Insert** instead of typing it, and pick the Wait for Message node that runs last on the same path.

## Next steps
- [Conversation Trigger](./node-conversation-trigger.md): provides the Conversation ID this node consumes.
- [Conversational Agent](./node-conversational-agent.md): the typical consumer of this node's `conversationContext` output.
- [Send Message](./node-send-message.md): write into the conversation, using `latestExchangeId` from this node to continue the same exchange.
- [Chat](./conversational-chat.md) : all the chat conversational nodes.
- [Build a chat agent workflow](./build-a-chat-agent-workflow.md): end-to-end walkthrough.
- [Chat deployment](https://docs.uipath.com/agents/automation-cloud/latest/user-guide/conversational-agents-deployment): deploy the workflow and make it available in chat channels.
- [Community](community.md): ask questions and share workflows with other builders on the UiPath Forum.
