---
schema_version: "1"
id: e85ffccfdf5609367e92cc5196ecc51d7ad2839e1ee2037426c20ae87dc49102
title: agent preview send
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/agent/cli_reference_agent_preview_send.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_agent_preview_send.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 077b71ff978ee99d8af68f4d0f4dc213d786cd22d76f2701e29ac06a97767fda
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# agent preview send

Send a message to an existing agent preview session.

## Description for agent preview send

You must have previously started a programmatic agent preview session with the "agent preview start" command to then use this command to send the agent a message (utterance). This command then displays the agent's response.

The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this command to send a message. You don't have to specify the --session-id flag if an agent has only one active preview session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring bundle or the published agent, respecitvely. To find either API name, navigate to your package directory in your DX project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata directory.

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <code>&#8209;&#8209;api&#8209;name</code> | <code>&#8209;n</code> | **Type:** Value<br><br>API name of the activated published agent you want to preview. |
| <code>&#8209;&#8209;api&#8209;version</code> | N/A | **Type:** Value<br><br>Override the api version used for api requests made by this command |
| <code>&#8209;&#8209;authoring&#8209;bundle</code> | N/A | **Type:** Value<br><br>API name of the authoring bundle metadata component that contains the agent's Agent Script file. |
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;json</code> | N/A | **Type:** Boolean<br><br>Format output as json. |
| <code>&#8209;&#8209;session&#8209;id</code> | N/A | **Type:** Value<br><br>Session ID outputted by "agent preview start". Not required when the agent has exactly one active session. Run "agent preview sessions" to see list of all sessions. |
| <code>&#8209;&#8209;target&#8209;org</code> | <code>&#8209;o</code> | **Type:** Value<br>**Required**<br><br>Username or alias of the target org. Not required if the `target-org` configuration variable is already set. |
| <code>&#8209;&#8209;utterance</code> | <code>&#8209;u</code> | **Type:** Value<br>**Required**<br><br>Utterance to send to the agent, enclosed in double quotes. |

## Examples for agent preview send

Send a message to an activated published agent using its API name and session ID; use the default org:

```shell
sf agent preview send --utterance "What can you help me with?" --api-name My_Published_Agent --session-id <SESSION_ID>
```

Similar to previous example, but don't specify a session ID; you get an error if the agent has more than one active session. Use the org with alias "my-dev-org":

```shell
sf agent preview send --utterance "What can you help me with?" --api-name My_Published_Agent --target-org my-dev-org
```

Send a message to an agent using its authoring bundle API name; you get an error if the agent has more than one active session:

```shell
sf agent preview send --utterance "what can you help me with?" --authoring-bundle My_Local_Agent
```
<!-- prettier-ignore-end -->
