> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/database/link-chatbots-groups.md).

# Link AI Assistants & Group Permissions

After creating a database and configuring the data tables, you need to **link the database to an AI Assistant** so the AI Assistant can use the Text to SQL feature to query data.

## Link AI Assistants <a href="#link-ai-agent" id="link-ai-agent"></a>

### Steps <a href="#steps" id="steps"></a>

1. Go to the database settings page and switch to the "<mark style="color:blue;">Link AI Assistants</mark>" tab
2. The left side of the page shows available AI Assistants, and the right side shows linked AI Assistants
3. Select the AI Assistants you want to link from the left side and click the arrow button to move them to the right side
4. Click "<mark style="color:blue;">Save</mark>" when finished

{% hint style="info" %}
You can use the search field to quickly find a specific AI Assistant. When there are many AI Assistants, the list is displayed with pagination.
{% endhint %}

{% hint style="warning" %}
Make sure the AI Assistant's response mode is switched to **Agent Mode**, otherwise the Text to SQL feature cannot be used.

For details on response modes, see: [Create AI Assistant](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/tree/main/en/build/setup.md)
{% endhint %}

### Multi-Database Query <a href="#multi-database-query" id="multi-database-query"></a>

An AI Assistant can be linked to multiple databases. When a user asks a question, the AI Assistant automatically determines which database to query based on the question content:

```
User: "What were the sales last month?"
→ AI Assistant automatically queries the "Sales Database"

User: "How many employees are currently in the Marketing department?"
→ AI Assistant automatically queries the "HR Database"
```

{% hint style="info" %}
To help the AI Assistant accurately distinguish between different databases, give each database a name that clearly describes its purpose, and provide detailed descriptions and field descriptions.
{% endhint %}

## Group Permission Management <a href="#group-permission-management" id="group-permission-management"></a>

Group permissions let you control database access scope for different teams in your organization, ensuring each team can only see databases relevant to them.

### Configure Group Permissions <a href="#configure-group-permission" id="configure-group-permission"></a>

1. Go to the database settings page and switch to the "<mark style="color:blue;">Group Permissions</mark>" tab
2. Use the transfer component to move the groups you want to authorize from the left side to the right side
3. Click "<mark style="color:blue;">Save</mark>" when finished

{% hint style="info" %}
Group permissions and "Link AI Assistants" are independent settings. Even if a database is linked to a specific AI Assistant, if the user's group does not have access to that database, the user still cannot query it.
{% endhint %}

### Permission Levels <a href="#permission-levels" id="permission-levels"></a>

Database access is determined by the following conditions together:

```
Can a user query the database through an AI Assistant?

✅ Database is enabled
  └── ✅ Database is linked to the AI Assistant
       └── ✅ User's group has access to the database
            └── ✅ Query allowed
```

* **Database owner** (creator) can access all databases they created, not restricted by group permissions
* **Non-owners** need group permissions to access databases


---

# 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.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/database/link-chatbots-groups.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.
