> 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/org/querymetadata/query-builder.md).

# 開始建構—使用「查詢構建器」

查詢構建器：以圖形化方式為聯絡人、對話訊息或 Web Chat 載入參數建立查詢元資料，限制 Agent 檢索的知識庫範圍。

## 聯絡人查詢元資料設定 <a href="#contact-query-metadata-setup" id="contact-query-metadata-setup"></a>

您可以使用 MaiAgent 服務中的「查詢構建器」以圖形化方式建立查詢元資料，以建立聯絡人查詢元資料為例：

### 步驟 1：進入 MaiAgent 後台服務中的聯絡人區域 <a href="#step-1-enter-contact-area" id="step-1-enter-contact-area"></a>

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-e1193c589be2e94dd3b408588d7ea9a426bb3d2a%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-07%20165727.png?alt=media" alt=""><figcaption><p>聯絡人區域入口</p></figcaption></figure>

### 步驟 2：對想要設定的聯絡人進行設定 <a href="#step-2-configure-contact" id="step-2-configure-contact"></a>

1. 找到需設定的聯絡人，並點下編輯

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-3e040c93c8149b98cec909c9f006f59876673de0%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-07%20165859.png?alt=media" alt=""><figcaption><p>聯絡人編輯入口</p></figcaption></figure>

2\. 點按後會出現以下畫面

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-ce1f2353f60000f676e26df8cd028b2729a238e1%2Fquery%20metadata%20maker.png?alt=media" alt=""><figcaption><p>查詢構建器入口</p></figcaption></figure>

直接點按查詢構建器進入圖形化介面

### 步驟 3：勾選想要開放的權限 <a href="#step-3-select-permissions" id="step-3-select-permissions"></a>

1. 勾選想要開放的知識庫，也可選擇部分勾選該知識庫下的文件

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-3cb875fe8a74fe9532e04d2d816b04dab3c3f3b3%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-07%20170306.png?alt=media" alt=""><figcaption><p>選擇知識庫與文件</p></figcaption></figure>

2\. 若想針對特定標籤開放文件，可點按「顯示標籤過濾」開啟標籤設定空間

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-4858e1ff92d8efc4cd28216d2ff05c207215aaca%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-07%20170306-1.png?alt=media" alt=""><figcaption><p>標籤過濾設定</p></figcaption></figure>

您可以在此加入標籤並選擇判斷方式：同一組標籤之間選「<mark style="color:blue;">包含所有標籤（AND）</mark>」或「<mark style="color:blue;">包含任一標籤（OR）</mark>」，多組條件之間選「<mark style="color:blue;">每一組都要符合（AND）</mark>」或「<mark style="color:blue;">符合任一組即可（OR）</mark>」（舊版截圖顯示為 AND／OR 按鈕，意思相同），作為已開放知識庫中的文件開放標準。建構器下方的「受影響的檔案」面板會即時顯示哪些檔案可被檢索。

{% hint style="info" %}
若要讓某個 Agent 在所有對話平台都預設套用同一組標籤條件，可改在 Agent 設定頁設定，詳見 [知識庫標籤過濾](/build/agent/label-filter.md)。聯絡人的查詢元資料優先於 Agent 的預設條件。
{% endhint %}

## 對話設定(Message) <a href="#message-settings" id="message-settings"></a>

您也可以使用下圖的右側選單選擇欲開放的知識權限：

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-c197581d7292296d9555671138c8d7ed62ce5a70%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-08%20095028.png?alt=media" alt=""><figcaption><p>內部對話：選擇可用知識權限</p></figcaption></figure>

同樣可使用「顯示標籤過濾」進行標籤過濾條件設定

{% hint style="info" %}
每次傳送不同訊息前，仍可以改動右側權限進行知識管理
{% endhint %}

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-1fd810ec8e5c4b185673a93858d73a36bca5d085%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-08%20124143.png?alt=media" alt=""><figcaption><p>可用文件清單</p></figcaption></figure>

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-e6b0091dcec82fe35f8d8f6f859ed8fd886249a0%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-08%20124344.png?alt=media" alt=""><figcaption><p>已選取文件狀態</p></figcaption></figure>

目前能夠參考 CV、SOP、問卷調查共三個檔案

在下一則訊息取消 CV 的勾選後，再次傳送訊息：

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-9805fef0555d8b09f66eebd0114738a62852f580%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-08%20124830.png?alt=media" alt=""><figcaption><p>取消勾選文件示例</p></figcaption></figure>

Agent 便無法使用 CV 檔案，引用庫亦不顯示 CV 引用：

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-18ee67d0a77a1ce864386d755225372b9f15fd63%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-08%20124958.png?alt=media" alt=""><figcaption><p>引用庫變化：移除 CV 後</p></figcaption></figure>

每次發送訊息前皆可調整權限，影響該輪回答所能引用的內容。

## Web Chat 載入時預先設定 <a href="#webchat-preload-settings" id="webchat-preload-settings"></a>

MaiAgent 提供您在 Web Chat 正式初始化前預先設定查詢元資料的功能，若想要在聯絡人前限制對話內容(如：提供 Web Chat 服務給未註冊聯絡人帳號的客戶時)，可以在嵌入時提供查詢元資料，系統將預設啟動訊息層級的知識庫文件過濾機制。

Web Chat 設定請參考：[技術人員手冊：開始建構—使用 JSON 格式](https://docs.maiagent.ai/tech/identity-and-access/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/json-interfaces#webchat-chu-shi-hua-she-ding)

{% hint style="info" %}
您也可以使用 JSON 格式建構查詢元資料，請參考[技術人員手冊：開始建構](https://docs.maiagent.ai/tech/identity-and-access/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/json-interfaces)[—](https://docs.maiagent.ai/tech/identity-and-access/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/json-interfaces)[使用 JSON 格式](https://docs.maiagent.ai/tech/identity-and-access/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/json-interfaces)
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/org/querymetadata/query-builder.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
