设置消息功能可用性

您需要先在 Business Messages 中设置代理的消息功能可用性,然后用户才能开始与代理对话。

如果用户在代理服务时段向代理发送消息,代理会用欢迎辞和对话开场白来问候用户。如果对话是在非代理服务时段发起的,用户会看到代理的离线消息。如需详细了解这些消息,请参阅发起对话

聊天机器人和人工服务时间

您可以为聊天机器人和人工代表指定不同的服务时间。

如果您为代理设置了某种自动化消息撰写机制,无论该自动化机制是一种可告知用户其在队列中位置的自动回复程序、一种可动态访问用户详细信息的复杂自然语言理解代理,还是任何介于两者间的程序,您都要指定聊天机器人消息功能可用性。

如果您希望在由 Google 管理的入口点(包括基于位置的入口点非本地入口点(Google Ads 除外))上发布代理,则必须提供人工服务。对于人工服务时间,请仅指定人工客服可在一周中的哪几天和哪些时段为用户解答问题。

如果聊天机器人代表全天 24 小时提供服务,但人工代表从早上 8 点至晚上 8 点提供服务,那么您可以单独指定这些人员。

此外,如果您同时指定聊天机器人和人工客服的服务时间,则可以发送人工客服请求建议,在聊天机器人代表无法满足用户需求时提示用户请求人工客服。

更新消息功能可用性

如需更新消息功能可用性,您可以使用 Business Communications API 发出 PATCH 请求,以更新代理的 primaryAgentInteractionadditionalAgentInteractions 字段。

更新这些字段时,您必须在 SupportedAgentInteraction 对象中包含所有字段的值。更新请求会覆盖您修改的所有字段的内容,包括所有子字段。例如,如果您发出将实例添加到 hours 的请求,则还需要包含之前的所有 hours 实例,否则您的更新会覆盖这些实例。

前提条件

在更新消息功能可用性之前,您需要掌握以下信息:

  • 开发机器上的 GCP 项目的服务帐号密钥的路径
  • 代理 name(例如“brands/12345/agents/67890”)

    如果您不知道代理的 name,请参阅列出品牌的所有代理

  • 聊天机器人可在哪些时区、一周中哪几天和哪些时段提供服务

  • 人工可在哪些时区、一周中哪几天和哪些时段提供服务

如果您不知道当前的 primaryAgentInteractionadditionalAgentInteractions 值,请参阅获取代理信息

发送更新请求

如需更新代理,请运行以下命令。将变量替换为您在前提条件中确定的值。

如果您同时提供聊天机器人和人工消息功能,请在 primaryAgentInteraction 中指定聊天机器人服务时间,并在 additionalAgentInteractions 的某个实例中指定人工服务时间。

聊天机器人和人工


# This code updates the agent interaction of a bot and human representatives.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__?updateMask=businessMessagesAgent.primaryAgentInteraction,businessMessagesAgent.additionalAgentInteractions" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "businessMessagesAgent": {
    "primaryAgentInteraction": {
      "interactionType": "BOT",
      "botRepresentative": {
        "botMessagingAvailability": {
          "hours": [
            {
              "startTime": {
                "hours": 20,
                "minutes": 0
              },
              "endTime": {
                "hours": 8,
                "minutes": 0
              },
              "timeZone": "America/Los_Angeles",
              "startDay": "MONDAY",
              "endDay": "SUNDAY"
            }
          ]
        }
      }
    },
    "additionalAgentInteractions": [
      {
        "interactionType": "HUMAN",
        "humanRepresentative": {
          "humanMessagingAvailability": {
            "hours": [
              {
                "startTime": {
                  "hours": 8,
                  "minutes": 0
                },
                "endTime": {
                  "hours": 20,
                  "minutes": 0
                },
                "timeZone": "America/Los_Angeles",
                "startDay": "MONDAY",
                "endDay": "SUNDAY"
              }
            ]
          }
        }
      }
    ]
  }
}'

仅聊天机器人


# This code updates the primary agent interaction of a bot representative
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__?updateMask=businessMessagesAgent.primaryAgentInteraction" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "businessMessagesAgent": {
    "primaryAgentInteraction": {
      "interactionType": "BOT",
      "botRepresentative": {
        "botMessagingAvailability": {
          "hours": [
            {
              "startTime": {
                "hours": 20,
                "minutes": 0
              },
              "endTime": {
                "hours": 8,
                "minutes": 0
              },
              "timeZone": "America/Los_Angeles",
              "startDay": "MONDAY",
              "endDay": "SUNDAY"
            }
          ]
        }
      }
    }
  }
}'

仅人工


# This code updates the primary agent interaction of a human representative
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__?updateMask=businessMessagesAgent.primaryAgentInteraction" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "businessMessagesAgent": {
    "primaryAgentInteraction": {
      "interactionType": "HUMAN",
      "humanRepresentative": {
        "humanMessagingAvailability": {
          "hours": [
            {
              "startTime": {
                "hours": 20,
                "minutes": 0
              },
              "endTime": {
                "hours": 8,
                "minutes": 0
              },
              "timeZone": "America/Los_Angeles",
              "startDay": "MONDAY",
              "endDay": "SUNDAY"
            }
          ]
        }
      }
    }
  }
}'

如需了解格式设置和值选项,请参阅 brands.agents.patchSupportedAgentInteraction