# CLI Chat > Start a conversation with a QwryAI agent, send messages as a customer and read its replies from the terminal Use the chat tools to talk to an agent the way a customer on the API channel does: start a conversation, send a message, and get the agent's reply back in the same call. They need the **Chat with agents** permission. Sign in first (see [CLI Auth](/docs/cli/auth)) and keep the agent's id in `$AGENT` (see [CLI Agents](/docs/cli/agents)). ## Send a message Start a conversation on the API channel: ```bash qwryai-cli tools:call create_conversation --args "{\"chatbotId\":\"$AGENT\"}" ``` ```json {"success":true,"data":{"conversationId":"","chatbotId":"","channel":"api"}} ``` Add a `metadata` object, such as `{"orderNumber":"1043"}`, to store your own details with the conversation. Send a message as the customer: ```bash CONV=$(qwryai-cli tools:call create_conversation --args "{\"chatbotId\":\"$AGENT\"}" | jq -r '.data.conversationId') qwryai-cli tools:call send_message --args "{\"chatbotId\":\"$AGENT\",\"conversationId\":\"$CONV\",\"content\":\"How do I reset my password?\"}" ``` The CLI waits up to 60 seconds for the agent and prints its whole reply: ```json { "success": true, "data": { "conversationId": "", "turnId": "", "status": "completed", "replies": [ { "id": "", "sender": "ai", "timestamp": "2026-12-01T09:14:05.112Z", "content": "Select **Forgot password?** on the sign-in page and enter your email. We'll send you a reset link within a few minutes." } ] } } ``` `status` tells you what happened to the turn: | `status` | Meaning | | - | - | | `completed` | The agent answered; its messages are in `replies` | | `pending` | The reply isn't ready after 60 seconds. Don't send anything else; read it later with `get_conversation_detail` | | `no_ai_reply` | The AI isn't replying here because a human agent is handling the conversation or AI replies are paused. `reason` says which | | `failed` | The reply couldn't be generated; send the message again | A message can be up to 10,000 characters. ## Continue a conversation Send the next message with the same `conversationId`. The agent sees the whole conversation so far, so you never resend earlier messages: ```bash qwryai-cli tools:call send_message --args "{\"chatbotId\":\"$AGENT\",\"conversationId\":\"$CONV\",\"content\":\"I don't get the email.\"}" ``` > [!TIP] > > Read back everything said so far, newest first, with `get_conversation_detail` and `"newestFirst":true`. See [CLI Conversations](/docs/cli/conversations). ## Scripting output Every reply is JSON, so pull out just the agent's text with `jq`: ```bash qwryai-cli tools:call send_message --args "{\"chatbotId\":\"$AGENT\",\"conversationId\":\"$CONV\",\"content\":\"hi\"}" | jq -r '.data.replies[].content' ``` The CLI exits with a non-zero code when a call fails, so CI steps stop on errors. ## Search the agent's knowledge Check what the agent would draw on for a question, without starting a conversation: ```bash qwryai-cli tools:call search_knowledge --args "{\"chatbotId\":\"$AGENT\",\"query\":\"refund policy\",\"limit\":2}" ``` ```json { "success": true, "data": { "query": "refund policy", "results": [ { "title": "Shipping, late orders and missing parcels policy", "sourceId": "", "score": 0.405, "content": "Shipping, late orders and missing parcels policy\n\nProcessing time\n- Orders are packed and handed to the courier within 1-2 business days…" } ] } } ``` Results come best first, five by default and up to 20. Scores are relative; good matches usually land between about 0.3 and 0.6. ## Fill in a lead form When the agent asks the customer for details, list the lead forms they can submit in this conversation and send one: ```bash qwryai-cli tools:call get_conversation_lead_forms --args "{\"chatbotId\":\"$AGENT\",\"conversationId\":\"$CONV\"}" qwryai-cli tools:call submit_conversation_lead_form --args "{\"chatbotId\":\"$AGENT\",\"conversationId\":\"$CONV\",\"formId\":\"\",\"data\":{\"email\":\"sam@example.com\"}}" ``` `data` maps each field `name` from the form to its value. ## Commands | Tool | Purpose | | - | - | | `create_conversation` | Start a customer conversation on the API channel | | `send_message` | Send a message as the customer and wait for the agent's reply | | `search_knowledge` | Find the passages the agent knows that best match a question | | `get_conversation_lead_forms` | List the lead forms the customer can submit | | `submit_conversation_lead_form` | Submit a lead form as the customer | > [!NOTE] > > Conversations you start here are on the API channel, so the agent answers with the API channel's own instructions and model when you've set them (`channel_specific_instructions` with `api`, and `apiChannelModel`). See [CLI Agents](/docs/cli/agents).