# Knowledge Management Permissions (Query Metadata) Overview

## Feature Description

When implementing an AI dialogue system, detailed control over the available scope of "Knowledge Base / AI Assistant / Chat Platform" is usually needed due to different user permissions and usage requirements.

In MaiAgent, you can use Query Metadata attached to different conversation/identity levels to determine "what content this person/conversation can reference".

### What is Query Metadata?

Query Metadata is a set of dynamic conditions that limit the query scope, specifying what "Knowledge Base, FAQ, documents matching tag conditions" and other data content users can query under a certain chat platform.

It doesn't replace roles or contacts, but rather makes these identities "work conditionally", implementing conversation-level least privilege control.

> **Roles/Contacts/Conversations are containers, Query Metadata is the actual condition settings that control visible scope**

{% hint style="info" %}
Learn more through these articles:

* [**Contact Integration Steps**](https://docs.maiagent.ai/tech/maiagent-tech-en/authorization-integration/contacts)
* [**Differences between Roles and Contacts**](https://docs.maiagent.ai/tech/maiagent-tech-en/authorization-integration/role-vs-contact)
  {% endhint %}

## Permission Level Concept

Before service construction, Agent confirms all available knowledge bases through Query Metadata at different levels, with permission levels referenced in the following order:

```
AI Assistant > Chat Platform > User (Message/Contact/Role) > query_metadata > Query Permissions
```

You can specify permissions at each level using either graphical interface or JSON format

> Reference these documents for operation:
>
> 1. [Graphical Interface Operation Guide (Contact, Internal Q\&A Settings)](https://docs.maiagent.ai/tech/maiagent-tech-en/authorization-integration/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/graphical-interface)
> 2. [JSON Interface Configuration Guide (Contact, Web Chat Embedding Settings)](https://docs.maiagent.ai/tech/maiagent-tech-en/authorization-integration/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/json-interfaces)

{% @mermaid/diagram content="flowchart TB
subgraph Identity Layer
Message --> Identity\[Identity Information]
Contact --> Identity
Role --> Identity
end

subgraph Query Condition Layer
Identity --> QM\[query\_metadata conditions]
QM --> KB\[Knowledge Base]
QM --> Chatbot\_file\[File Documents]
QM --> FAQ\[FAQ]
QM --> Label\[Tags]

```
KB --> Filter1[Filter Available Knowledge Bases]
Chatbot_file --> Filter2[Filter Available File Documents]
FAQ --> Filter3[Filter Available FAQs]
Label --> Filter4[Filter Tag Conditions]
```

end

subgraph Response Layer
Filter1 --> Chatbot\[AI Assistant Response Content]
Filter2 --> Chatbot
Filter3 --> Chatbot
Filter4 --> Chatbot
end" %}

* Contact/Role are identity containers
* Message corresponds to controlling which knowledge bases to use during internal conversations through filtering
* `query_metadata` is the "filter condition set" actually executed during conversations

### Document Filter Condition Decision Levels

The open filtering logic is:

{% @mermaid/diagram content="flowchart TB
%% Knowledge Base Level
KB\["Knowledge Base"]

```
%% Document Level
Docs["Documents under Knowledge Base"]

%% Tag Filtering Level
Tags["Filter available documents from opened documents by tags"]

%% Final Result
Result["Final Available Documents"]

%% Connections
KB --> Docs
Docs --> Tags
Tags --> Result

%% Style Settings
classDef kbBox fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#000000
classDef docBox fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#000000
classDef tagBox fill:#e8f5e8,stroke:#388e3c,stroke-width:2px,color:#000000
classDef resultBox fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000000

class KB kbBox
class Docs docBox
class Tags tagBox
class Result resultBox" %}
```

Through layer-by-layer transmission, Query Metadata becomes the actual decision basis for AI response logic

## Practical Application Scenarios

<table><thead><tr><th width="162.5028076171875">Identity</th><th>Input Conditions (query_metadata)</th><th>Response Result</th></tr></thead><tbody><tr><td>Visitor</td><td>Knowledge Base: <code>General</code><br>File Documents: None<br>Tags: <code>Visitor</code><br>FAQ: <code>1</code>, <code>2</code></td><td>Get documents with <code>Visitor</code> tag from <code>General</code> knowledge base and FAQ <code>1</code>, FAQ <code>2</code></td></tr><tr><td>Regular Member</td><td>Knowledge Base: <code>General</code><br>File Documents: <code>A</code>, <code>B</code>, <code>C</code><br>Tags: None<br>FAQ: None</td><td>Get documents <code>A</code>, <code>B</code>, <code>C</code> from <code>General</code> knowledge base and all FAQs</td></tr><tr><td>Customer Service</td><td>Knowledge Base: <code>Employee</code><br>File Documents: None<br>Tags: <code>CS</code><br>FAQ: None</td><td>Get documents tagged as <code>CS</code> from <code>Employee</code> knowledge base and all FAQs</td></tr><tr><td>Internal Employee</td><td>Knowledge Base: <code>Employee</code><br>File Documents: <code>A</code>, <code>B</code><br>Tags: None<br>FAQ: None</td><td>Get documents <code>A</code>, <code>B</code> from <code>Employee</code> knowledge base and all FAQs</td></tr><tr><td>Administrator</td><td>Knowledge Base: <code>Employee</code>, <code>General</code><br>File Documents: None<br>Tags: None<br>FAQ: None</td><td>Get all document content and FAQs from <code>Employee</code> and <code>General</code> knowledge bases</td></tr></tbody></table>

***

## Summary: The Value of query\_metadata for Enterprises

🎯 **Multi-dimensional Identity Cross-Control** (Role + Region + Product Line)

🎯 **Real-time Query Control**: No need to copy assistants, just change conditions to adapt to different scenarios

🎯 **Flexible Large Knowledge Base Management**: Tags and knowledge bases can be split and authorized according to scenarios

> **It is recommended to incorporate query\_metadata into the core product architecture, allowing enterprises to achieve maximum authorization flexibility with minimum settings,**\
> **ensuring knowledge security while improving conversation experience and operational efficiency.**
