发送调查问卷以跟踪用户满意度

<ph type="x-smartling-placeholder">

Business Messages 对话中的自定义调查问卷。

为了确保用户与代理的互动令人满意,Google 当用户与您的代理对话结束后,系统就会向用户发送调查问卷。如果 您希望在不同的时间点(例如在最后一天)收集数据 对话时,您可以在对话中发送调查问卷 对话。调查问卷会显示在对话中,并允许用户提供 根据问题提供各种选项来提供反馈。

Google 触发调查问卷的时间取决于客服人员的消息内容 库存状况

可用性 问卷调查时间
仅聊天机器人 最后一条消息的 30 分钟后
仅人工 距上次发送消息后的 24 个工时
聊天机器人和人工 距上次发送消息后的 24 个工时

如果存在 <而是 24 小时。

您可以每 24 小时为每个对话发送一份调查问卷。如果您在以下国家/地区发送调查问卷: 那么 Google 不会向该对话发送调查问卷。 如果客服人员在 24 小时内在同一对话中发送了多份调查问卷, Business Messages 仅会尝试向用户发送第一份调查问卷。

当用户在完成 则代理会显示一条问候语。 如果用户没有回复调查问卷,则调查问卷将在 7 天后过期,并且 调查问卷过期后,用户在下一个对话中看到问候语。

如果用户在问卷调查处于活跃状态时发送了与调查问卷无关的消息, Business Messages 取消调查问卷并向用户发送消息 添加到代理的 webhook 中

如果您不向用户发送调查问卷,您的代理仍会收到 在您的网络钩子中接收 Google 的调查问卷结果,且应接受并处理 进行相应更改

问题

调查问卷最多可包含五个问题,并分为以下三类: requiredtemplatecustom。调查问卷 始终包含必填的问题,则最多显示两个模板 问题,并且最多显示两个自定义问题。

必填的问题

必须回答的问题已针对 Business Messages 的所有语言区域进行了本地化 支持。用户可以“我喜欢”或“不喜欢”回复。

问题解答:“此消息传递服务能否满足 AGENT_NAME?”

模板问题

模板问题是可选问题,由 Google 定义且已本地化 Business Messages 支持的所有语言区域。一份调查问卷最多可包含 两个模板问题。用户响应格式因问题而异。

模板问题包括

  • AGENT_NAME发送消息的体验如何?
  • 你向朋友推荐AGENT_NAME的可能性有多大?
  • 下次与AGENT_NAME联系时,您再次联系此人的可能性有多大 选择消息功能?
  • 总体而言,与“AGENT_NAME”互动的难易程度如何?
  • 您是否赞同以下说法: AGENT_NAME让我可以轻松处理我的问题。
  • 请评价您对支持人员的总体满意度。
  • 此聊天会话是否有助于您避免向 AGENT_NAME 拨打电话?

要查看所有可用模板问题的列表并获取模板 ID,请执行以下操作:

  1. 打开 Business Communications Developer(商业通信开发者) 控制台 并使用您的 Business Messages Google 账号登录。
  2. 选择您的代理。
  3. 在左侧导航栏中,点击问卷调查

自定义问题

一份调查问卷最多可包含两个自定义问题。如果您指定自定义 为每个问题添加问题版本 语言区域 支持的节点数量您必须为自己的 默认语言区域。如果用户收到调查问卷,但所在的语言区域尚未设置 指定版本的自定义问题,则系统会按照定义的方式显示问题 代理的默认语言区域。

对自定义问题的响应支持单独的文本和回传数据, 到建议 回复

自定义调查问卷

如需为客服人员自定义调查问卷,请按以下步骤操作:

  1. 打开 Business Communications Developer(商业通信开发者) 控制台 并使用您的 Business Messages Google 账号登录。
  2. 选择您的代理。
  3. 在左侧导航栏中,点击问卷调查
  4. 在调查问卷中添加最多两个可用的模板问题。
  5. 点击创建自定义问题,为您的调查问卷添加自定义问题。

如需了解格式设置和值选项,请参阅 surveyConfig

发送调查问卷

调查问卷

如需发送调查问卷,请运行以下命令。替换 CONVERSATION_ID 其中包含您要向其发送调查问卷的对话的标识符,以及 将 SURVEY_ID 替换为调查问卷的唯一标识符。

cURL

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     https://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This code sends a survey to the user:
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/message/surveys?hl=en

# Replace the __CONVERSATION_ID__ with a conversation id that you can send messages to
# Make sure a service account key file exists at ./service_account_key.json

curl -X POST "https://businessmessages.googleapis.com/v1/conversations/__CONVERSATION_ID__/surveys?surveyId=f4bd7576-6c2e-4674-9db4-d697166f63ce" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-messages" \
-H "$(oauth2l header --json ./service_account_key.json businessmessages)"

Node.js

/**
 * This code sends a survey to the user:
 * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/message/surveys?hl=en
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businessmessages Node.js
 * Business Messages client library.
 */

/**
 * Edit the values below:
 */
const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';
const CONVERSATION_ID = 'EDIT_HERE';

const businessmessages = require('businessmessages');
const uuidv4 = require('uuid').v4;
const {google} = require('googleapis');

// Initialize the Business Messages API
const bmApi = new businessmessages.businessmessages_v1.Businessmessages({});

// Set the scope that we need for the Business Messages API
const scopes = [
  'https://www.googleapis.com/auth/businessmessages',
];

// Set the private key to the service account file
const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

/**
 * Posts a survey to the Business Messages API.
 *
 * @param {string} conversationId The unique id for this user and agent.
 */
async function sendSurvey(conversationId) {
  const authClient = await initCredentials();

  // Create the payload for creating a new survey
  const apiParams = {
    auth: authClient,
    parent: 'conversations/' + conversationId,
    surveyId: uuidv4(),
    resource: {}
  };

  // Call the message create function using the
  // Business Messages client library
  bmApi.conversations.surveys.create(apiParams,
    {auth: authClient}, (err, response) => {
    console.log(err);
    console.log(response);
  });
}

/**
 * Initializes the Google credentials for calling the
 * Business Messages API.
 */
 async function initCredentials() {
  // configure a JWT auth client
  const authClient = new google.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    scopes,
  );

  return new Promise(function(resolve, reject) {
    // authenticate request
    authClient.authorize(function(err, tokens) {
      if (err) {
        reject(false);
      } else {
        resolve(authClient);
      }
    });
  });
}

sendSurvey(CONVERSATION_ID);

Java

import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.ExponentialBackOff;
import com.google.api.services.businessmessages.v1.Businessmessages;
import com.google.api.services.businessmessages.v1.model.*;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.UUID;

class SendSurveySnippet {
  /**
   * Initializes credentials used by the Business Messages API.
   */
  private static Businessmessages.Builder getBusinessMessagesBuilder() {
    Businessmessages.Builder builder = null;
    try {
      GoogleCredential credential = GoogleCredential
            .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY"));

      credential = credential.createScoped(Arrays.asList(
            "https://www.googleapis.com/auth/businessmessages"));

      credential.refreshToken();

      HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

      // Create instance of the Business Messages API
      builder = new Businessmessages
        .Builder(httpTransport, jsonFactory, null)
        .setApplicationName("Sample Application");

      // Set the API credentials and endpoint
      builder.setHttpRequestInitializer(credential);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return builder;
  }

  public static void main(String args[]) {
    try {
      String conversationId = "CONVERSATION_ID";

      // Create client library reference
      Businessmessages.Builder builder = getBusinessMessagesBuilder();

      // Create a new survey to send to the user associated with the conversationId
      Businessmessages.Conversations.Surveys.Create request
          = bmBuilder.build().conversations().surveys()
          .create("conversations/" + conversationId,
              new BusinessMessagesSurvey());

      request.setSurveyId(UUID.randomUUID().toString());

      // Setup retries with exponential backoff
      HttpRequest httpRequest =
          ((AbstractGoogleClientRequest) request).buildHttpRequest();

      httpRequest.setUnsuccessfulResponseHandler(new
          HttpBackOffUnsuccessfulResponseHandler(
          new ExponentialBackOff()));

      // Execute request
      httpRequest.execute();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Python

"""This code sends a survey to the user.

Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/message/surveys?hl=en

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

import uuid

from businessmessages import businessmessages_v1_client as bm_client
from businessmessages.businessmessages_v1_messages import BusinessmessagesConversationsSurveysCreateRequest
from businessmessages.businessmessages_v1_messages import BusinessMessagesSurvey
from oauth2client.service_account import ServiceAccountCredentials

# Edit the values below:
path_to_service_account_key = './service_account_key.json'
conversation_id = 'EDIT_HERE'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    path_to_service_account_key,
    scopes=['https://www.googleapis.com/auth/businessmessages'])

client = bm_client.BusinessmessagesV1(credentials=credentials)

# Create the survey request
survey_request = BusinessmessagesConversationsSurveysCreateRequest(
    surveyId=str(uuid.uuid4().int),
    parent='conversations/' + conversation_id,
    businessMessagesSurvey=BusinessMessagesSurvey())

# Send the survey
bm_client.BusinessmessagesV1.ConversationsSurveysService(
    client=client).Create(request=survey_request)

如需了解格式设置和值选项,请参阅 conversations.surveys

接收调查问卷回复

当用户回答调查问卷中的问题时,您的代理会收到相应回复 调用其 webhook。以您接收和处理调查问卷回复的方式 消息

调查问卷中的所有问题都具有相同的 surveyResponse.survey 值。如果 您的调查问卷包含多个问题,请确保您的基础架构接受 多个具有相同 surveyResponse.survey 值的响应,并标识出 按 surveyResponse.surveyQuestionId 字段区分各个问题。

调查问卷回复的文字值显示在 surveyResponse.questionResponseText。对于必答题和模板问题, Business Messages 会返回“我喜欢”回复作为 VERY_SATISFIED 和“我喜欢” 作为 VERY_DISSATISFIED 给出的不喜欢响应。如果自定义问题回复包含 使用表情符号,则最好使用 surveyResponse.questionResponsePostbackData,而不是尝试解析 Unicode 值。

调查问卷回复采用以下格式。

{
  "agent": "brands/BRAND_ID/agents/AGENT_ID",
  "sendTime": "SEND_TIME",
  "conversationId": "CONVERSATION_ID",
  "requestId": "REQUEST_ID",
  "surveyResponse": {
    "survey": "conversations/CONVERSATION_ID/surveys/SURVEY_ID",
    "rating": "SURVEY_RATING",
    "createTime": "CREATE_TIME",
    "surveyQuestionId": "QUESTION_ID",
    "questionResponseText": "RESPONSE_TEXT",
    "questionResponsePostbackData": "RESPONSE_POSTBACK_DATA",
    "questionType": "QUESTION_TYPE",
    "questionIndex": QUESTION_INDEX,
    "totalQuestionCount": TOTAL_QUESTION_COUNT,
    "surveyTriggerSource": "TRIGGER_SOURCE"
  }
}

如需了解格式设置和值选项,请参阅 UserMessageSurveyResponse