> For the complete documentation index, see [llms.txt](https://docs.toucanai.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.toucanai.cloud/embed/copy-of-embed-an-ai-chat.md).

# Copy of Embed an AI Chat

Self-service AI Chat lets embedded users explore data using natural language, without accessing Toucan AI platform.

The chat is embedded in your product and governed by your data, security, and configuration rules.

<figure><img src="/files/N7je2tTfv7FdrMlQY1zx" alt=""><figcaption></figcaption></figure>

### What the feature does

This feature allows you to:

* Embed an **AI-powered chat** inside your product
* Let **Explorers** ask questions in natural language
* Return **tables and charts** generated from your data
* Restrict answers using **datasets, and RLS**

The embedded AI chat is designed for **data exploration**, not dashboard building.

***

### Prerequisites

Before enabling self-service AI chat, you must have:

* At least one connected database
* At least one generated API key
* At least one generated access token
* (Recommended) Dataset metadata analyzed or enriched
* (Recommended) Row-Level Security configured

***

### How to use it

#### Step 1 – Prepare your data

* Analyze datasets with AI
* Review and adjust column descriptions
* Ensure metric definitions are explicit

Good metadata directly impacts answer quality.

#### Step 2 – Set up security

* Define custom token attributes
* Map attributes to dataset columns using RLS

Always validate with multiple attribute values.

#### Step 3 – Configure embed token

When generating a token:

* Include required attributes
* Set token expiration
* Enable AI chat capability

Tokens fully define what the Explorer can see and do.

#### Step 4 – Embed the AI chat

Embed the chat using Web component. The chat runs fully inside your product UI.

```vue-html

<script type="module" src="https://toucanai.cloud/embed/embed.js"></script>
<link rel="stylesheet" href="https://toucanai.cloud/embed/embed.css" />

<tc-ai-assistant auth-token="your-auth-token"
server-url="https://toucanai.cloud/api" data-theme="light"></tc-ai-assistant>
```

#### Example

**Use case:** HR SaaS with multi-tenant customers

* Attribute: `customer_id`
* Dataset column: `customer_id`
* Explorer question:\
  \&#xNAN;*“How many hires last quarter?”*

Result:

* Query is filtered by `customer_id`
* Explorer only sees their own data
* No configuration or SQL required


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.toucanai.cloud/embed/copy-of-embed-an-ai-chat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
