Skip to main content

CLI Chat

You can configure the command-line chat interface (CLI Chat) and integrate it with Solace Agent Mesh. The CLI Chat allows you to communicate with Solace Agent Mesh through your terminal.

Learn about agents

Before you configure CLI Chat, we recommend that learn about the Solace Agent Mesh CLI. For more information, see Solace Agent Mesh CLI.

Setting Up the Environment

First, you need to install Solace Agent Agent and Solace Agent Mesh CLI. Then, you'll need to create a new Solace Agent Mesh (SAM) project.

Set Up the REST Interface

The CLI chat uses the REST interface to communicate with Solace Agent Mesh. Depending on your REST interface settings, the CLI Chat may need to authenticate using the REST interface authentication endpoint.

You can configure the CLI Chat when you create the SAM project. You'll need to set the host, port, and endpoint of the REST interface, which together form a URL. During installation, you can enable authentication by adding the required authentication configuration to the .env file. The authentication is disabled by default. If authentication is enabled, you'll need to log in to Solace Agent Mesh; otherwise, login is not required.

Running the CLI Chat

If authentication is enabled in the REST interface, you must log in using the following command before starting a chat:

sam chat login SERVER

Where:

  • SERVER: Use your authentication host address.

This command provides a URL for OAuth 2.0 authentication. Use the URL to authenticate in your browser to generate a token in JSON format.

  • Copy the JSON object that's returned.
  • Press Enter in the terminal to paste and save the token.

After successfully logging in, start a chat with the following command:

sam chat start -a

Where:

  • -a: Specifies an argument that ensures each chat session is authenticated in the background. This argument is not required if authentication is not configured.

During your first chat session after login, the command makes a request for endppoint of the REST interface. Subsequent chats reuse the saved endpoint information until you log out. The token is automatically renewed using the refresh token in the background, so you only need to log in once. If you no longer need the token, you can log out using:

sam chat logout

This command permanently deletes the token. After logging out, you'll need to log in again to start a new chat.