# Messaging

Send chat messages to your agent as if the user typed them.

Send messages to your agent as if the user typed them, blending conversation, actions, and UI components into your product flows.

Every call references your Agent API Name, found in **Agent Studio → Setup**.

## Initialize the agent

Call agent methods once the SDK is ready.

```javascript
foldspace("when", "ready", () => {
  const agent = foldspace.agent({ /* …common setup… */ });
  // Now you can call any of the methods below:
  agent.message("What actions can you do?");
});
```

## Send a message

### `message(text: string): this`

Send a chat message as if the user typed it into the agent. Returns the agent instance for chaining.

| Parameter | Type | Description |
| --- | --- | --- |
| `text` | string | The message content to send. |

```javascript
foldspace.agent("myproduct-agentic-agent")
  .message("Configure brand settings for me");
```

### Interpolate runtime values

Because `text` is a plain string, you can interpolate runtime values and chain other methods such as `.open()`.

```javascript
const userName = "John";
agent("myproduct-agentic-agent")
  .message(`Hi ${userName}, let's review your pipeline today`)
  .open();
```

## Related

- [Conversation API](/reference/conversation-api/): list, search, pin, and manage conversations.
- [Agent Event API](/reference/agent-event-api/): listen to agent, UI, and conversation events.
