# Quickstart

Make a sandbox key, open a conversation with Texa AI, send a message and read its reply.


This takes about five minutes. You need a Texa Desk account (sign up at
[texadesk.com](https://texadesk.com)) where you are an administrator, and a terminal.

## 1. Make a sandbox key

In Texa Desk, open **Texa AI → Developers → API keys** and choose **New key**:

- **Environment:** Sandbox. A sandbox key (`texa_test_…`) reaches the same agent, knowledge and
  approved procedures as live, but nothing reaches a real customer and actions are answered by
  [fixtures](/guides/sandbox) you set.
- **Name:** something you'll recognise in the request log, such as "Laptop".

The key is shown **once**. Copy it into your shell:

```bash
export TEXA_API_KEY=texa_test_...
```

Keep keys on your server. Never put one in an app or a web page: anyone with it can act as your
business. (For apps and pages there are [widget sessions](/guides/website-and-app).)

## 2. Check the key

```bash
curl https://api.texadesk.com/v1/me -H "Authorization: Bearer $TEXA_API_KEY"
```

The answer names your account and says `"environment": "test"`.

## 3. Open a conversation

<!-- tabs -->
```bash cURL
curl https://api.texadesk.com/v1/conversations \
  -H "Authorization: Bearer $TEXA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-user-1842" \
  -d '{"channel": "web", "customer_ref": "user-1842", "first_name": "Tolu"}'
```
```python Python
# pip install texa
from texa import Client

texa = Client()            # reads TEXA_API_KEY
convo = texa.open_conversation(channel="web", customer_ref="user-1842",
                               first_name="Tolu", idempotency_key="quickstart-user-1842")
print(convo["conversation_id"])
```
```js JavaScript
// npm install @texadesk/sdk
import { TexaClient } from "@texadesk/sdk";

const texa = new TexaClient({ key: process.env.TEXA_API_KEY! });
const convo = await texa.openConversation(
  { channel: "web", customer_ref: "user-1842", first_name: "Tolu" }, "quickstart-user-1842");
console.log(convo.conversation_id);
```
<!-- /tabs -->

```json
{"conversation_id": "cnv_8a7f0c...", "state": "active", "events": []}
```

`customer_ref` is **your** id for the customer. Texa AI remembers a customer across conversations by
it, so use the same one every time.

## 4. Send the customer's message

<!-- tabs -->
```bash cURL
curl https://api.texadesk.com/v1/conversations/cnv_8a7f0c.../messages \
  -H "Authorization: Bearer $TEXA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message_id": "msg-1", "text": "Hello, what are your opening hours?"}'
```
```python Python
out = texa.send_message(convo["conversation_id"], "Hello, what are your opening hours?",
                        message_id="msg-1")
for e in out["events"]:
    if e["type"] == "reply":
        print(e["text"])
```
```js JavaScript
const out = await texa.sendMessage(convo.conversation_id,
  { text: "Hello, what are your opening hours?", message_id: "msg-1" });
for (const e of out.events) if (e.type === "reply") console.log(e.text);
```
<!-- /tabs -->

```json
{
  "conversation_id": "cnv_8a7f0c...",
  "state": "active",
  "events": [
    {"type": "reply", "reply_id": "rpl_...", "format": "chat",
     "text": "We're open Monday to Friday, 8:00 to 18:00, and Saturday 9:00 to 14:00."}
  ]
}
```

Texa AI answers from the knowledge your team approved in Texa Desk (**Texa AI → Knowledge**). If it
has no knowledge yet, it says it doesn't know rather than making something up.

`message_id` is your own id for the message. Send the same one again (after a timeout, say) and you
get the first answer back, marked `"replayed": true`: nothing runs twice.

## 5. Read the events

Every answer carries `events`, in order. Show each `reply` to the customer. The others tell you what
else happened:

| Event | What to do |
|---|---|
| `reply` | Show `text` to the customer |
| `action_request` | Texa AI needs something from your systems. See [actions](/guides/actions) |
| `handover` | People take over now; Texa AI stops replying. See [handing over](/guides/handover) |
| `close` | The conversation is over |

## 6. Look at it in Texa Desk

Open **Texa AI → Developers → Request log** to see each request you made, its status and its
request id. With handover to Texa Desk switched on (the default), conversations that need a person
appear in your **App conversations** inbox.

## Next

<ul class="rows">
<li><a href="/concepts"><b>Concepts</b><span>Conversations, customers, procedures, actions, the sandbox and credits.</span></a></li>
<li><a href="/guides/webhooks"><b>Webhooks</b><span>Replies that come later, handovers and your team's answers, pushed to your server.</span></a></li>
<li><a href="/guides/actions"><b>Actions</b><span>Let Texa AI check an order or a transfer in your systems.</span></a></li>
<li><a href="/guides/website-and-app"><b>Your website and app</b><span>The same Texa AI as a chat your customers use directly.</span></a></li>
</ul>
