# Build your first AI agent

> A complete walkthrough: create an agent, train it on your store's data, test it in the playground, and deploy it to your website — in about ten minutes.

This guide takes you from an empty workspace to a deployed, store-grounded agent in about ten minutes. By the end you'll have an agent answering real questions on your website.

> **PREREQUISITES:** A free Bookbag account and a public URL for your store or help center. That's it — new workspaces include free credits so you can build and test right away.

## Step 1 — Create and train your agent

### Create the agent

From the dashboard, click **New agent**. You can either start blank or describe your agent in plain language and let the builder draft it for you:

```text
Support agent for Acme — a Shopify store selling outdoor gear.
Handles order status, returns within 30 days, and shipping questions.
Friendly, concise, never makes up policy.
```

The builder turns this into a system prompt, sets a sensible default model, and creates the agent.

### Add training data

Open the agent and go to **Data sources**. Add knowledge in whichever form you have it:

#### Website

Enter your URL and Bookbag crawls your pages, extracts the readable text, and indexes it. Great for help centers and policy pages.

> **TIP:** Point the crawler at your help center or FAQ first — it's the highest-signal content for support.

#### Files

Upload PDFs, docs, or spreadsheets — product catalogs, policy documents, manuals. Bookbag extracts and chunks the text.

#### Text

Paste a snippet directly — perfect for a policy that isn't written down anywhere yet.

#### Q&A

Write an exact question and the answer you want returned. Q&A pairs take priority, so use them to pin down high-stakes answers like refund windows.

> **CHECK:** When a source finishes training its status turns to **Trained**. Your agent can now answer from it.

## Step 2 — Test and optimize

Open the **Playground** and start chatting. Ask the questions your customers actually ask:

- "How long do I have to return something?"
- "Where is my order?"
- "Do you ship to Canada?"

For each answer, expand the **sources** to see exactly which chunks the agent used, and use **Inspect prompt** to see the full prompt sent to the model. If an answer is wrong or vague, the fix is almost always in the data — add a Q&A pair or a clearer source.

> **TIGHTEN HIGH-STAKES ANSWERS:** For anything involving money or policy (refunds, warranties), add an explicit Q&A pair. It pins the answer so the model can't paraphrase it incorrectly.

## Step 3 — Deploy

Go to **Deploy** to put your agent in front of customers. The fastest path is the website widget:

1. **Copy the embed snippet** — Deploy → Website widget gives you a one-line script tag.
2. **Paste it before </body>** — Add it to your store's theme. On Shopify, that's your theme.liquid layout.
3. **Connect more channels** — Add email and messaging channels so the same agent answers everywhere.

```html
<script
  src="https://app.bookbag.ai/widget/embed"
  data-agent-id="YOUR_AGENT_ID"
  defer
></script>
```

> **CHECK:** Reload your store — the chat bubble appears in the corner and answers from your data.

## Congratulations

You have a deployed agent grounded in your store's data. From here, make it resolve more on its own and route the rest to your team.

- [Best practices](/docs/getting-started/best-practices) — Get accurate, on-brand answers consistently.
- [Actions](/docs/actions/overview) — Let the agent collect leads, escalate, and call your APIs.
- [Help Desk](/docs/help-desk/overview) — Handle the conversations that need a human.
- [Analytics](/docs/agents/analytics) — See resolution rate, volume, and where to improve.
