知識輔助

本頁面包含 Knowledge Assist UI 模組的 API 說明文件。這個模組會在對話期間向服務專員顯示實用文章和常見問題建議。

用量

使用下列程式碼,在 HTML 頁面中匯入模組:

<script src="https://www.gstatic.com/agent-assist-ui-modules/v1/knowledge_assist.js"></script>

使用下列標記嵌入模組:

<agent-assist-knowledge-assist>

屬性

屬性名稱 類型 註解
功能 字串 以半形逗號分隔的知識輔助功能清單,應顯示 (ARTICLE_SUGGESTION、FAQ 和 ARTICLE_SEARCH)。

用量

屬性是以字串為基礎的元件屬性,可透過下列方式設定:

直接從 HTML 範本:

<element-selector property-name="value">

從 JavaScript 程式碼:

var el = document.querySelector('element-selector');
el.setAttribute('property-name', 'value');

輸入內容

屬性名稱 類型 註解
config KnowledgeAssistConfig 知識輔助模組的選用設定。

用量

輸入內容通常是 JavaScript 物件或其他複雜的屬性類型,必須直接在元素例項上指派:

const el = document.querySelector('element-selector');
el.propertyName = value;

類型

如要瞭解元件使用的自訂型別,請參閱下節。

KnowledgeAssistConfig

interface KnowledgeAssistConfig {
  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;
  };
}