本頁面提供生成式知識輔助 UI 模組 (也稱為 Knowledge Assist V2) 的 API 說明文件。服務專員可使用這個模組查詢公司知識庫,並取得 AI 生成的答案。
用量
使用下列程式碼,在 HTML 頁面中匯入模組:
<script src="https://www.gstatic.com/agent-assist-ui-modules/v2/knowledge_assist.js"></script>
使用下列標記嵌入模組:
<agent-assist-knowledge-assist-v2>
屬性
屬性名稱 | 類型 | 註解 |
---|---|---|
session-id | 字串 | 非對話式使用情況的選用工作階段 ID。 |
parent | 字串 | 用於非對話用途的父項專案位置名稱。例如:「projects/foo/locations/global」 |
用量
屬性是基於字串的元件屬性,可透過下列方式設定:
直接從 HTML 範本:
<element-selector property-name="value">
在 JavaScript 程式碼中:
var el = document.querySelector('element-selector');
el.setAttribute('property-name', 'value');
輸入內容
屬性名稱 | 類型 | 註解 |
---|---|---|
config | KnowledgeAssistV2Config | Knowledge Assist V2 模組的選用設定。 |
用量
輸入內容通常是 JavaScript 物件或其他複雜的屬性類型,必須直接在元素例項上指派:
const el = document.querySelector('element-selector');
el.propertyName = value;
類型
如要瞭解元件使用的自訂類型,請參閱下節。
KnowledgeAssistV2Config
interface KnowledgeAssistV2Config {
articleLinkConfig: {
/**
* Whether to open the article in a new tab, or as a popup. Defaults to new
* tab.
*/
target?: "blank" | "popup";
/**
* Options to configure the popup's size and location. See
* https://developer.mozilla.org/en-US/docs/Web/API/Window/open#window_features.
*/
popupWindowOptions?: string;
/**
* The field name on the document metadata if a separate article link source
* is provided.
*/
linkMetadataKey?: string;
};
showCopyAnswer: boolean;
showPasteAnswer: boolean;
}