實作 UI 模組和連接器

Agent Assist 提供一組預建的可自訂 UI 元件模組,可用於將 Agent Assist 功能整合至 UI。您可以在任何網頁應用程式中嵌入模組,向服務專員顯示 Agent Assist 建議。如需將模組整合至 LivePerson 的具體操作說明,請參閱 LivePerson 教學課程

Agent Assist 功能

以下是可做為 UI 模組元件實作的 Agent Assist 功能。

事前準備

實作 UI 模組前,請先設定對話設定檔

實作 UI 模組

如要將 Agent Assist 模組整合至 UI,主要有兩種方法。受管理容器方法會將所有選取的 Agent Assist 功能整合在單一面板中。或者,您也可以個別匯入功能,以便在介面中自訂設定。UI 元件和服務專員桌面之間的通訊,是由 UI 模組連接器負責。所有通訊都是透過傳送自訂事件進行。

容器方法和個別元件都可搭配任何系統使用,但 Agent Assist 只提供 UI 模組連接器,可與 Genesys CloudLivePersonTwilioSalesforce 搭配使用。如要將 UI 模組與任何其他代理程式系統整合,您必須自行建立連接器。詳情請參閱自訂 UI 模組連接器說明文件

檔案版本

如要擷取最新版本的 gstatic 檔案,請指定最新版本:

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

如要擷取特定穩定版本的 gstatic 檔案,請指定確切版本:

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

最新版本:

      Container: v1.12
      Container: v2.0
      Common: v1.6
      Knowledge assist: v1.1
      Generative knowledge assist: v2.9
      Smart reply: v1.4
      Summarization: v1.3
      Transcript: v1.3

代管容器

代管容器方法會整合單一元件,在統一面板中顯示所選的 Agent Assist 功能。這個面板也會處理所有共用模組問題,包括載入連接器和任何錯誤訊息。如果您要將模組整合至第三方服務專員桌面 (例如 LivePerson),或是希望盡量減少/不自訂 Agent Assist 功能在 UI 中的顯示方式,建議採用這種做法。

初始化容器元件後,系統會載入所有必要依附元件。無論使用多少 Agent Assist 功能,初始化容器時都只需要單一匯入作業。

初始化容器元件:

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

元素標記名稱:

    <agent-assist-ui-modules>

初始化範例:

    const uiModulesEl = document.createElement('agent-assist-ui-modules');
    uiModulesEl.setAttribute('features', 'SMART_REPLY,ARTICLE_SUGGESTION');
    uiModulesEl.setAttribute('conversation-profile', 'projects/my-project/locations/global/conversationProfiles/123');
    uiModulesEl.setAttribute('auth-token', authToken);
    uiModulesEl.setAttribute('channel', 'chat');
    uiModulesEl.setAttribute('custom-api-endpoint', 'https://my-dialogflow-proxy-service.com');
    uiModulesEl.setAttribute('dark-mode-background', '#000000');
    hostElement.appendChild(uiModulesEl);

詳情請參閱元件 API 說明文件頁面

個別元件

您可以選擇個別整合 Agent Assist UI 模組,而非整合至單一容器。只有在您使用自訂應用程式,且可能需要在網頁的不同區段中算繪模組,或是需要大幅自訂時,才建議採用這種做法。

在這種情況下,您需要個別匯入每個功能專屬的 UI 模組。此外,您還需要匯入及初始化 UI 模組連接器。

實作 UI 模組連接器

除非您使用第 1 版容器,否則必須導入 UI 模組連接器,才能使用 UI 模組。將下列程式碼新增至應用程式,公開可供例項化及初始化的全域 UiModulesConnector 類別:

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

方法:

    constructor(): void;
    init(config: ConnectorConfig): void;
    disconnect(): void;
    setAuthToken(token: string): void;

以下是連接器設定物件的完整 TypeScript 介面範例。如果您已建立自訂 UI 模組連接器,以便搭配不支援的系統使用,請將 agentDesktop 設為 Custom。以下範例列出支援的服務專員桌面系統。

interface ConnectorConfig {
  /** Communication mode for the UI modules application. */
  channel: 'chat'|'voice';

  /** Agent desktop to use. */
  agentDesktop: 'LivePerson' | 'GenesysCloud' | 'SalesForce' | 'GenesysEngageWwe' | 'Custom';

  /** Conversation profile name to use. */
  conversationProfileName: string;

  /** API Connector config. */
  apiConfig: {
    /**
     * Authentication token to attach to outgoing requests. Should be a valid
     * OAuth token for Dialogflow API, or any other token for custom API
     * endpoints.
     */
    authToken: string;

    /**
     * Specifies a custom proxy server to call instead of calling the Dialogflow
     * API directly.
     */
    customApiEndpoint?: string;

    /** API key to use. */
    apiKey?: string;

    /**
     * Additional HTTP headers to include in the Dialogflow/proxy server API
     * request.
     */
    headers?: Array;
  }

  /** Event-based connector config. Set this for voice conversations. */
  eventBasedConfig?: {
    /**
     * Transport protocol to use for updates. Defaults to 'websocket' if none is
     * specified.
     */
    transport?: 'websocket'|'polling';

    /** Event-based library to use (i.e., Socket.io). */
    library?: 'SocketIo';

    /** Endpoint to which the connection will be established. */
    notifierServerEndpoint: string;
  }
}

例項化範例:

const connector = new UiModulesConnector();

connector.init({
  channel: 'chat',
  agentDesktop: 'Custom',
  conversationProfileName: 'projects/my-project/locations/global/conversationProfiles/123',
  apiConfig: {
    authToken: 'abc123',
    customApiEndpoint: 'https://my-dialogflow-proxy-server.com',
  }
});

價格免責事項

如果您使用 UI 模組,就必須支付基礎服務的相關費用,包括: