> ## Documentation Index
> Fetch the complete documentation index at: https://api.scalysis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat with an agent

> Test an agent by text, without making a phone call.

Type as the customer and see exactly what the agent would say on a call. Use it to test a new agent, a script change or a tool, before calling real customers.

**1. Prepare**

Find out which variables the agent needs.

```bash theme={null}
curl https://app.scalysis.com/api/v1/agent-scripts/2207/chat/prepare \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Check `chat_ready` is `true`, and note every name in `variables`.

**2. Start**

Send a value for each variable. The agent speaks first.

```bash theme={null}
curl -X POST https://app.scalysis.com/api/v1/agent-scripts/2207/chat/sessions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "variables": { "agent_name": "Priya", "brand_name": "Demo Store", "customer_name": "Rahul" } }'
```

Save `session.session_id` and `session.revision`.

**3. Reply**

Send what the customer says, with the latest `revision`.

```bash theme={null}
curl -X POST https://app.scalysis.com/api/v1/agent-scripts/2207/chat/sessions/1061566/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Haan bol raha hoon", "revision": 2 }'
```

The last `assistant` message is the agent's reply. Repeat until `is_completed` is `true`, or stop any time.

## Good to know

* No phone call is made, but your wallet must have balance.
* Replies can take a few seconds. Wait for each response before sending the next message.

> [card] [Prepare chat](https://api.scalysis.com/api-reference/agent-chat/prepare.md)

> [card] [Start chat](https://api.scalysis.com/api-reference/agent-chat/start.md)

> [card] [Send message](https://api.scalysis.com/api-reference/agent-chat/send.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.