使用者指南:真人服務專員的服務專員助理

真人服務專員可透過主管輔助功能,監控使用者與真人服務專員之間的對話。您可以定義規則,決定何時要將對話提報給真人主管。接著,當對話符合其中一項規則時,主管輔助功能就會自動提醒人工主管。

對話中每個使用者回合都會顯示情緒分數和轉錄稿。您的規則可以使用這些情緒分數或 AI 教練,判斷何時要向人工主管發出快訊。

事前準備

如要使用主管輔助功能,您需要 Agent Assist 對話設定檔和下列 Identity and Access Management (IAM) 角色。

  • dialogflow.virtualAgentMonitoringSupervisor
  • dialogflow.processor

步驟 1:設定對話設定檔

對話設定檔會設定一組參數,控管對話期間向服務專員提供的建議。下列步驟會建立 ConversationProfile 物件,其中包含 HumanAgentAssistantConfig 物件。如果您不想直接呼叫 API,也可以使用 Agent Assist 控制台執行這些動作。

建立對話設定檔

如要建立對話設定檔,請呼叫 ConversationProfile 資源的 create 方法。請提供知識庫 ID、文件 ID、專案 ID 和模型 ID。回覆內容會包含新的對話設定檔 ID。

以下是 JSON 範例:

{
  "displayName": "smart_compose_assist",
  "humanAgentAssistantConfig": {
    "humanAgentSuggestionConfig": {
      "featureConfigs": [
        {
          "suggestionFeature": {
            "type": "SMART_COMPOSE"
          },
          "queryConfig": {
            "documentQuerySource": {
              "documents": "projects/project-id/knowledgeBases/knowledge-base-id/documents/document-id"
            },
           "maxResults": "1"
          },
         "conversationModelConfig": {
           "model": "projects/project-id/conversationModels/model-id"
         }
        }
      ]
    }
  }
}

步驟 2:選擇情緒或 AI 教練

選擇使用情緒分析、AI 教練或兩者,監控對話。您的升級規則也會反映這項選擇。

情緒

如要分析使用者在整個對話過程中的情緒,請在對話設定檔中新增情緒分析。

AI 教練

如要使用 AI 教練分析對話,請按照操作說明建立 AI 教練生成器。每個對話設定檔一次只能建立一個 AI 教練生成器。你可以為 AI 教練生成器新增無限數量的指令,但每個指令都必須至少包含顯示名稱條件

建立生成器後,請複製新的生成器 ID,並新增至對話設定檔。

步驟 3:設定規則來監控對話

更新對話設定檔,啟用並設定客戶服務對話的監控規則,這些對話會使用情緒或 AI 教練。請選擇下列其中一個選項,透過 API 更新對話個人資料:

  • 呼叫 ConversationProfile 資源的 update 方法。
  • 使用 UpdateConversationProfile 方法設定互動監控設定。設定互動監控設定的要求應如下列範例所示。

    conversation_profile {
      name: "projects/agent-assist-console-demo/locations/global/conversationProfiles/your_new_conv_profile_id"
      interaction_monitoring_config {
        event_notification_config = {
        notification_config = { # If you want to enable notifications on your custom pub/sub topic, add it here.
        topic = 'ADD_YOUR_CUSTOM_PUBSUB_TOPIC'
            message_format = 'JSON'
          }
      # Optional: Leave both empty for *Default Mode*.
      # Other supported configurations:
      # 1. **Default Mode:** Always publish alert events when they are triggered and publish metric events only when an alert is triggered,
      #   - Metric event: `METRIC_EVENT_PUBLISH_IF_ALERT_TRIGGERED`
      #   - Alert event: `ALERT_EVENT_ALWAYS_PUBLISH`
      # 2. **Pure Monitoring Mode:** Publish all metric events, but never publish alert events.
      #   - Metric event: `METRIC_EVENT_ALWAYS_PUBLISH`
      #   - Alert event: `ALERT_EVENT_NEVER_PUBLISH`
      # 3. **Publish All Events:** Always publish both metric and alert     events.
      #   - Metric event: `METRIC_EVENT_ALWAYS_PUBLISH`
      #   - Alert event: `ALERT_EVENT_ALWAYS_PUBLISH`
      # Note: Avoid setting `metric_event_notification_mode` to `METRIC_EVENT_PUBLISH_IF_ALERT_TRIGGERED` while `alert_event_notification_mode` is `ALERT_EVENT_NEVER_PUBLISH`, as this combination will result in no events being published.
    metric_event_notification_mode = 'ADD'
    alert_event_notification_mode = 'ADD'
        }
        alerting_config {
          # Required.
          rules {
            alert_rule_id: "rule_1"
            description: "rule_1_description"
            trigger_condition {
            ...
            }
      rules {
            alert_rule_id: "rule_2"
            description: "rule_2_description"
            trigger_condition {
            ...
            }
          }
          # Optional Tool config to retrieve customer name. If not    required, skip setting the metadata_config
          metadata_config = {
            tool_configs = [
        {
          display_name = 'Customer Name'
          toolset_tool = {
            toolset = 'ADD_CUSTOM_TOOLSET'
            operation_id = 'load_profile'
          }
          response_key_path = 'sessionInfo.customerProfile.customerName'
        },
            ]
          }
    
        }
      }
    }
    update_mask {
      paths: "interaction_monitoring_config"
    }
    }

如需進一步協助,請與 Google Cloud 代表聯絡。

設定範例

下列範例說明各種監控規則組合的對話設定檔設定。

範例 1:符合 AI 教練規則

    conversation_profile     {
      name: "projects/agent-assist-console-demo/locations/global/conversationProfiles/your_new_conv_profile_id"
      interaction_monitoring_config {
        event_notification_config = {
            ...
        }
        alerting_config {
          rules {
            alert_rule_id: "agent coaching alert trigger rule(s) matched"
            description: "agent coaching alert trigger rule(s) matched"
            trigger_condition {
              metric_condition {
                metric_type: AGENT_COACHING_INSTRUCTIONS
                agent_coaching_config {
                  generator_name:    "projects/agent-assist-console-demo/locations/global/generators/newly_created_generator_id"
                }
                display_name: "agent coaching alert trigger rule(s) matched"
              }
            }
          }
          # Optional Tool config to retrieve customer name. If not required, skip setting the metadata_config.
          metadata_config = {
            ...
          }
        }
      }
    }
    update_mask {
      paths: "interaction_monitoring_config"
    }
    

範例 2:情緒分數 < -0.01

    conversation_profile     {
      name: "projects/agent-assist-console-demo/locations/global/conversationProfiles/your_new_conv_profile_id"
      interaction_monitoring_config {
        event_notification_config = {
            ...
        }
        alerting_config {
          rules {
            alert_rule_id: "customer sentiment negative"
            description: "negative sentiment"
            trigger_condition {
              metric_condition {
                metric_type: SENTIMENT
                value_range {
                  max_threshold: -0.01
                }
                display_name: "negative sentiment"
              }
            }
          }
          # Optional Tool config to retrieve customer name. If not required, skip setting the metadata_config.
          metadata_config = {
            ...
          }
        }
      }
    }
    update_mask {
      paths: "interaction_monitoring_config"
    }
    

範例 3:情緒分數 < -0.01,且符合 AI 教練規則

    conversation_profile     {
      name: "projects/agent-assist-console-demo/locations/global/conversationProfiles/your_new_conv_profile_id"
      interaction_monitoring_config {
        event_notification_config = {
            ...
        }
        alerting_config {
          # Required.
          rules {
            alert_rule_id: "sentiment is negative and agent coaching alert trigger rule(s) matched"
            description: "agent coaching alert trigger rule(s) matched and customer is unhappy"
            trigger_condition {
              and_condition {
                alert_conditions {
                  metric_condition {
                    metric_type: SENTIMENT_SCORE
                    value_range {
                      max_threshold: -0.01
                    }
                    display_name: "negative sentiment and agent coaching alert trigger rule(s) matched"
                  }
                }
                alert_conditions {
                  metric_condition {
                    metric_type: AGENT_COACHING_INSTRUCTIONS
                    agent_coaching_config {
                      generator_name: "projects/agent-assist-console-demo/locations/global/generators/newly_created_generator_id"
                    }
                    display_name: "negative sentiment and agent coaching alert trigger rule(s) matched"
                  }
                }
              }
            }
          }
          # Optional Tool config to retrieve customer name. If not required, skip setting the metadata_config.
          metadata_config = {
            ...
          }
        }
      }
    }
    update_mask {
      paths: "interaction_monitoring_config"
    }
    

範例 4:符合 AI 教練規則或情緒分數 < -0.01

    conversation_profile     {
      name: "projects/agent-assist-console-demo/locations/global/conversationProfiles/your_new_conv_profile_id"
      interaction_monitoring_config {
        event_notification_config = {
            ...
        }
        alerting_config {
          rules {
            alert_rule_id: "agent coaching alert trigger rule(s) matched"
            description: "agent coaching alert trigger rule(s) matched"
            trigger_condition {
              metric_condition {
                metric_type: AGENT_COACHING_INSTRUCTIONS
                agent_coaching_config {
                  generator_name:    "projects/agent-assist-console-demo/locations/global/generators/newly_created_generator_id"
                }
                display_name: "agent coaching alert trigger rule(s) matched"
              }
            }
          }
          rules {
            alert_rule_id: "customer sentiment negative"
            description: "negative sentiment"
            trigger_condition {
              metric_condition {
                metric_type: SENTIMENT
                value_range {
                  max_threshold: -0.01
                }
                display_name: "negative sentiment"
              }
            }
          }
          # Optional Tool config to retrieve customer name. If not required, skip setting the metadata_config.
          metadata_config = {
            ...
          }
        }
      }
    }
    update_mask {
      paths: "interaction_monitoring_config"
    }
    

步驟 4:設定主管輔助功能

  1. 建立 Pub/Sub 主題來接收快訊。Agent Assist 會使用這個 Pub/Sub 主題接收快訊和指標。記下主題 ID。
  2. 將專案和 Pub/Sub 主題 ID 提交給 Google,加入允許清單。

人對人監控服務會發布下列事件類型:

  • 情感指標是針對對話中所有使用者回合的匯總情感計算結果。
  • 當情緒超過設定的閾值時,Agent Assist 會產生快訊事件,其中包含規則詳細資料的通知。

監督員輔助功能支援下列標準設定,可因應這兩項事件的不同整合需求。您可以在互動監控設定中加入這些設定。

  • 預設模式:符合條件時,系統會立即發布快訊。只有在啟動快訊後,系統才會發布情緒指標。
  • 純監控模式:系統會持續發布每輪對話的情緒指標。系統會忽略快訊事件。
  • 發布所有模式行為:系統一律會無條件發布這兩種事件。

步驟 5a:測試即時通訊

請按照下列步驟,使用即時通訊模擬器測試主管輔助功能。

  1. 前往監控模擬器:

    https://agentassist.cloud.google.com/projects/project-id/locations/location-id/human-supervisor
    
  2. 依序點選「設定」「設定」「真人服務專員」

  3. 在瀏覽器中開啟另一個分頁,然後使用對話設定檔前往對話模擬器

  4. 在對話模擬工具中發起對話,並注意監控模擬工具會顯示轉錄稿和情緒分數。

步驟 5b:測試語音

請按照下列步驟,使用語音模擬器測試主管輔助功能。

  1. 前往監控模擬器:

    https://agentassist.cloud.google.com/projects/project-id/locations/location-id/human-supervisor
    
  2. 依序點選「設定」和「設定」,然後選取「真人服務專員」和「僅監控電話」

  3. 在瀏覽器中開啟另一個分頁,然後使用對話設定檔前往語音對話模擬器

  4. 依序按一下「通話」「切換為語音通話」。

  5. 輸入服務專員的電話號碼。

  6. 使用其他電話撥打畫面上的新號碼。

評分地圖

主管輔助功能會提供兩項分數:

  • 每輪對話的情緒分數是介於 -1 到 1 的離散浮點值。
  • 即時情緒分數是介於 -1 到 1 之間的連續浮點值。

您可以將連續的即時情緒分數對應至適合不同業務單位的自訂分數。以下範例說明其中一種對應方法。

對應的 JavaScript 程式碼範例:

/**
 * Maps a score to a bucket index (1-10) based on 11 boundary points.
 * * @param {number} score - The input score (between -1 and 1)
 * @param {number[]} boundaries - An array of exactly 11 numbers sorted in ascending order.
 * @return{number} The bucket index (1 to 10).
 */
function getBucketIndex(score, boundaries) {
  // 1. Validation: Ensure we have exactly 11 boundary points
  if (!Array.isArray(boundaries) || boundaries.length !== 11) {
    throw new Error("Boundaries must be an array of exactly 11 points.");
  }

  // 2. Validate Input Score Range 
  if (typeof score !== 'number' || score < -1 || score > 1) {
    throw new Error(`Input score ${score} is out of bounds. Must be between -1 and 1.`)
  }

  // 3. Iterate through boundaries to find the slot
  // We start checking from index 1 (the first upper bound)
  for (let i = 1; i < boundaries.length; i++) {
    // If the score is strictly less than the current boundary,
    // it belongs to the bucket corresponding to this index.
    if (score <= boundaries[i]) {
      return i;
    }
  }

  // Fallback (should be covered by step 2 validation, but ensures integer return)
  return -1;
}


// --- Example Usage ---

// Create 11 boundary points from -1 to 1
// [-1.0, -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
const boundaries = [];
for (let i = 0; i <= 10; i++) {
  // Creating points: -1 + (i * 0.2)
  boundaries.push(parseFloat((-1 + (i * 0.2)).toFixed(1))); 
}

console.log("Boundaries:", boundaries);

// Test Cases
console.log(`Score -0.9 maps to Bucket: ${getBucketIndex(-0.9, boundaries)}`); // Expected: 1
console.log(`Score -0.8 maps to Bucket: ${getBucketIndex(-0.8, boundaries)}`); // Expected: 2 (Inclusive lower)
console.log(`Score 0.0 maps to Bucket: ${getBucketIndex(0.0, boundaries)}`);   // Expected: 6
console.log(`Score 0.95 maps to Bucket: ${getBucketIndex(0.95, boundaries)}`); // Expected: 10
console.log(`Score 1.0 maps to Bucket: ${getBucketIndex(1.0, boundaries)}`);   // Expected: 10 (Inclusive upper)

(選用) 使用下列程式碼自動判斷門檻,盡量提高對應預測值與 CX 分數之間的關聯性,進而最佳化對應。對資料執行這項一次性最佳化作業後,您可以使用產生的以資料為準邊界,不必手動設定。

Pub/Sub 事件通知

情緒指標和快訊都會發布至單一設定的 Pub/Sub 主題。酬載會因事件類型而異。

情緒指標 Pub/Sub 訊息酬載:

{
  "data": "{\"metric\":{\"metricType\":\"SENTIMENT_SCORE\",\"value\":{\"createTime\":\"2024-01-01T00:00:00.000Z\",\"sentiment\":{\"score\":0.5,\"magnitude\":0.5},\"advancedValues\":{\"exponentialMovingAverageValue\":0.5}},\"conversation\":\"projects/your-project-id/locations/global/conversations/conversation_id\",\"message\":{\"name\":\"projects/your-project-id/locations/global/conversations/conversation_id/messages/message_id\",\"content\":\"ok\",\"languageCode\":\"en-US\",\"participant\":\"projects/your-project-id/locations/global/conversations/conversation_id/participants/participant_id\",\"participantRole\":\"END_USER\",\"sendTime\":\"2024-01-01T00:00:00.000Z\"}}}",
  "attributes": {
    "conversation_id": "conversation_id"
  }
}

變更 Pub/Sub 訊息酬載範例:

{"data": "{\"alert\":{\"name\":\"projects/project_id/locations/location_id/interactionMonitoringAlerts/alert_id\",\"conversation\":\"projects/project_id/locations/location_id/conversations/conversation_id\",\"alertState\":\"CREATED\",\"alertMetadata\":{\"alertTriggerRules\":[{\"alertRuleId\":\"negative-sentiment\",\"description\":\"dummy_description\",\"Strong negative sentiment detected in last 30 seconds\":[{\"metricType\":\"SENTIMENT_SCORE\",\"values\":[{\"createTime\":\"2024-01-01T00:00:00.000Z\",\"sentiment\":{\"score\":0.0,\"magnitude\":0.0}}]}]}],\"channelType\":\"CHAT\"},\"createTime\":\"2024-01-01T00:00:00.000Z\"}}",
  "attributes": {
    "conversation_id": "conversation_id"
  }
}

API 參考資料

AnalyzeContent

  • 使用案例:監控使用者與真人服務專員之間的即時通訊對話。
  • 測試方法:
    • 控制台模擬工具:使用 Agent Assist 控制台的即時通訊模擬工具。
    • API 整合:直接傳送 HTTP 或 RPC 要求 (請參閱 [範例程式碼])。

StreamingAnalyzeContent

  • 使用案例:監控使用者與人類服務專員之間的語音對話。
  • 測試方法:
    • 控制台模擬工具:使用 Agent Assist 控制台的語音模擬工具。
    • API 整合:直接傳送 HTTP 或 RPC 要求 (請參閱 [範例程式碼])。

ListMessages

  • 擷取對話的完整轉錄稿清單 (包括服務專員和顧客的對話)。
  • 最佳做法:這項 API 特別適合用於語音對話,在串流結束後,驗證每個回合的最終修正轉錄稿。

ListInteractionMonitoringMetrics:擷取特定對話計算及匯總的所有情緒指標。

要求酬載範例:

{
  "parent": "projects/{project-id}/locations/{location-id}",
  "conversation":
"projects/{project-id}/locations/{location-id}/conversations/{conversation-id}"
}

回應酬載範例:

{
  "interactionMonitoringMetrics": [{
    "metricType": "SENTIMENT_SCORE",
    "values": {
      "createTime": "2025-12-01T22:20:49.925Z",
      "sentiment": {
        "score": -1.0,
        "magnitude": 1.0
      },
      "advancedValues": {
        "movingAverageValue": -0.4994999999762513
      }
    }, {
      "createTime": "2025-12-01T22:20:21.027Z",
      "sentiment": {
        "score": 0.001,
        "magnitude": 0.001
      },
      "advancedValues": {
        "movingAverageValue": -0.4994999999762513
      }
    },
      "advancedValues": {
      }
    }]
}

ListInteractionMonitoringAlert:擷取產生的快訊。這項功能可套用至整個專案,或篩選出特定對話。

如要查詢專案中的所有快訊:

{
  "parent": "projects/{project-id}/locations/{location-id}"
}

**如要查詢特定對話 ID 的快訊 **

{
  "parent": "projects/{project-id}/locations/{location-id}",
  "filter": "context_id=projects/{project-id}/locations/{location-id}/conversations/{conversation-id}"
}

篩選選項。使用者可以套用其他篩選條件,例如快訊狀態:

alert_state=CREATED,alert_state=ACKNOWLEDGED