借助面向人工客服的监督员辅助功能,人工监督员可以监控最终用户与人工客服之间的对话。您可以定义规则,以确定何时将对话上报给人工主管。然后,当对话符合您的某条规则时,主管辅助功能会自动提醒人工主管。
对于对话中的每个最终用户回合,您都会看到情感得分和转写内容。您的规则可以使用这些情绪得分或 AI 教练来确定何时向人类监督员发送提醒。
准备工作
如需使用主管辅助功能,您需要 Agent Assist 对话配置文件和以下 Identity and Access Management (IAM) 角色。
dialogflow.virtualAgentMonitoringSupervisordialogflow.processor
第 1 步:配置对话配置文件
对话配置文件可配置一组参数,用于控制对话期间向客服人员提出的建议。以下步骤将使用 HumanAgentAssistantConfig 对象创建 ConversationProfile。如果您不希望直接调用 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 代表联系。
配置示例
以下示例展示了各种监控规则组合的对话配置文件配置。
示例 27: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 步:配置主管辅助功能
- 创建 Pub/Sub 主题以接收提醒。Agent Assist 使用此 Pub/Sub 主题接收提醒和指标。记下您的主题 ID。
- 向 Google 提交您的项目和 Pub/Sub 主题 ID 以将其添加到许可名单中。
人对人监控服务会发布以下事件类型:
- 情感指标是对对话中所有最终用户轮次的情感计算结果的汇总。
- 提醒事件是指当情绪超出配置的阈值时,Agent Assist 生成的包含规则详细信息的通知。
监督员辅助功能支持以下标准配置,以满足这两种事件的不同集成要求。您可以将这些设置纳入互动监控配置中。
- 默认模式:在满足条件时立即发布提醒。只有在启动提醒后,才会发布情感指标。
- 纯监控模式:系统会针对每个对话轮次持续发布情感指标。系统会忽略提醒事件。
- “发布所有”模式行为:始终无条件发布这两种类型的事件。
第 5a 步:测试聊天
请按照以下步骤操作,通过聊天模拟器测试主管辅助功能。
前往监控模拟器:
https://agentassist.cloud.google.com/projects/project-id/locations/location-id/human-supervisor
依次点击设置设置,然后选择人工客服。
在浏览器中打开另一个标签页,然后使用您的对话配置文件导航到聊天对话模拟器。
在对话模拟器中开始对话,并注意监控模拟器会显示转写内容和情感得分。
第 5b 步:测试语音
请按照以下步骤使用语音模拟器测试主管辅助功能。
前往监控模拟器:
https://agentassist.cloud.google.com/projects/project-id/locations/location-id/human-supervisor
依次点击设置设置,然后选择人工客服和仅监控手机。
在浏览器中打开另一个标签页,然后使用您的对话配置文件导航到语音对话模拟器。
依次点击通话切换到语音。
输入客服人员的手机号码。
使用其他手机拨打屏幕上显示的新号码。
得分地图
主管辅助功能提供以下两个得分:
- 每轮对话的情感分数是一个介于 -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)
(可选)使用以下代码优化映射,以自动确定可最大限度提高映射的预测与客户体验得分之间相关性的阈值。对数据执行一次性优化后,您可以使用生成的数据驱动型边界,而无需手动配置。
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 参考文档
- 应用场景:监控最终用户与人工客服之间的聊天对话。
- 测试方法:
- 控制台模拟器:使用 Agent Assist 控制台聊天模拟器。
- API 集成:发送直接 HTTP 或 RPC 请求(请参阅 [示例代码])。
- 应用场景:监控最终用户与人工客服之间的语音对话。
- 测试方法:
- 控制台模拟器:使用 Agent Assist 控制台语音模拟器。
- API 集成:发送直接 HTTP 或 RPC 请求(请参阅 [代码示例])。
- 检索对话的完整转写列表(包括代理和客户的发言)。
- 最佳实践:此 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