ส่งแบบสำรวจเพื่อติดตามความพึงพอใจของผู้ใช้

แบบสำรวจที่ปรับแต่งในการสนทนาทาง Business Messages

Google จะส่งแบบสำรวจให้ผู้ใช้หลังจากที่สนทนากับตัวแทนของคุณเสร็จสิ้น เพื่อให้มั่นใจว่าผู้ใช้จะได้รับประสบการณ์การโต้ตอบที่น่าพึงพอใจกับตัวแทนของคุณ หากต้องการรวบรวมข้อมูลในช่วงเวลาที่ต่างกัน เช่น เมื่อสิ้นสุดการสนทนา คุณสามารถส่งแบบสำรวจภายในบริบทของการสนทนาได้ แบบสำรวจจะแสดงในการสนทนาและช่วยให้ผู้ใช้แสดงความคิดเห็นได้ด้วยตัวเลือกต่างๆ โดยขึ้นอยู่กับคำถาม

ช่วงเวลาที่ Google ทริกเกอร์แบบสำรวจจะขึ้นอยู่กับความพร้อมในการรับส่งข้อความของตัวแทน

ความพร้อมใช้งาน เวลาในการทำแบบสำรวจ
บ็อตเท่านั้น 30 นาทีหลังจากข้อความสุดท้าย
เฉพาะมนุษย์ 24 ชั่วโมงทำการหลังจากข้อความสุดท้าย
บ็อตและมนุษย์ 24 ชั่วโมงทำการหลังจากข้อความสุดท้าย

หากมีเวลาทำการน้อยกว่า 24 ชั่วโมงในอีก 7 วันข้างหน้า เราจะใช้ 24 ชั่วโมงแทน

คุณส่งแบบสำรวจได้ 1 รายการต่อการสนทนาทุก 24 ชั่วโมง หากคุณส่งแบบสำรวจใน การสนทนาก่อน Google ระบบจะไม่ส่งแบบสำรวจไปยังการสนทนานั้น หากตัวแทนส่งแบบสำรวจหลายรายการในการสนทนาเดียวกันภายใน 24 ชั่วโมง Business Messages จะพยายามส่งแบบสำรวจแรกให้ผู้ใช้เท่านั้น

ครั้งถัดไปที่ผู้ใช้เริ่มการสนทนากับตัวแทนหลังจากทำแบบสำรวจเสร็จ ตัวแทนจะแสดงคำทักทาย หากผู้ใช้ไม่ตอบแบบสำรวจ แบบสำรวจจะหมดอายุหลังจากผ่านไป 7 วัน และ ผู้ใช้จะเห็นคำทักทายในการสนทนาครั้งถัดไปหลังจากที่แบบสำรวจหมดอายุ

หากผู้ใช้ส่งข้อความที่ไม่เกี่ยวข้องกับแบบสำรวจขณะที่แบบสำรวจใช้งานอยู่ใน การสนทนา ข้อความธุรกิจจะยกเลิกแบบสำรวจและส่งข้อความของผู้ใช้ ไปยัง Webhook ของตัวแทน

หากคุณไม่ได้ส่งแบบสำรวจให้ผู้ใช้ แต่เอเจนต์จะยังได้รับผลลัพธ์ของแบบสำรวจของ Google ที่เว็บบุ๊กของคุณ และควรยอมรับและประมวลผลผลลัพธ์เหล่านั้นตามความเหมาะสม

คำถาม

แบบสำรวจมีคำถามได้สูงสุด 5 ข้อ โดยแบ่งออกเป็น 3 หมวดหมู่ ได้แก่ ต้องระบุ เทมเพลต และกำหนดเอง แบบสำรวจ จะมีคำถามที่จำเป็นเสมอ จากนั้นจะแสดงคำถามจากเทมเพลต สูงสุด 2 ข้อ แล้วจึงแสดงคำถามที่กำหนดเองสูงสุด 2 ข้อ

คำถามที่ต้องตอบ

คำถามที่จำเป็นต้องตอบจะได้รับการแปลเป็นภาษาท้องถิ่นในทุกภาษาที่ Business Messages รองรับ ผู้ใช้สามารถตอบกลับได้โดยใช้ไอคอนชอบหรือไม่ชอบ

คำถามที่จำเป็น: "บริการรับส่งข้อความนี้ช่วยแก้ไขปัญหาความต้องการเกี่ยวกับ AGENT_NAME ของคุณได้หรือไม่"

คำถามเกี่ยวกับเทมเพลต

คำถามในเทมเพลตเป็นคำถามที่ไม่บังคับซึ่ง Google กำหนดไว้และแปลเป็นภาษาท้องถิ่น ในทุกภาษาที่ Business Messages รองรับ แบบสำรวจมีคำถามจากเทมเพลตได้สูงสุด 2 ข้อ รูปแบบคำตอบของผู้ใช้จะแตกต่างกันไปตามคำถาม

คำถามในเทมเพลต ได้แก่

  • ประสบการณ์เกี่ยวกับการรับส่งข้อความกับ AGENT_NAME เป็นอย่างไรบ้าง
  • คุณมีแนวโน้มมากน้อยเพียงใดที่จะแนะนำ AGENT_NAME ให้กับเพื่อน
  • ครั้งต่อไปที่คุณติดต่อ AGENT_NAME คุณมีแนวโน้มมากน้อยเพียงใดที่จะเลือกการส่งข้อความ
  • โดยรวมแล้ว การโต้ตอบกับ AGENT_NAME มีความยากง่ายมากน้อยเพียงใด
  • คุณเห็นด้วยหรือไม่เห็นด้วยกับข้อความต่อไปนี้มากน้อยเพียงใด AGENT_NAME ช่วยให้ฉันจัดการปัญหาได้ง่ายขึ้น
  • โปรดให้คะแนนความพึงพอใจโดยรวมของคุณที่มีต่อพนักงานฝ่ายช่วยเหลือ
  • เซสชันการแชทนี้ช่วยทำให้คุณไม่จำเป็นต้องโทรหา AGENT_NAME หรือไม่

หากต้องการดูรายการคำถามในเทมเพลตทั้งหมดที่ใช้ได้และรับรหัสเทมเพลต ให้ทำดังนี้

  1. เปิดคอนโซลนักพัฒนาแอปการสื่อสารทางธุรกิจ แล้วลงชื่อเข้าใช้ด้วยบัญชี Google ของ Business Messages
  2. เลือกตัวแทน
  3. คลิกแบบสำรวจในการนำทางด้านซ้าย

คำถามที่กำหนดเอง

แบบสำรวจมีคำถามที่กำหนดเองได้สูงสุด 2 ข้อ หากคุณระบุคำถามที่กำหนดเอง ให้ระบุคำถามเวอร์ชันต่างๆ สำหรับแต่ละภาษา ที่ตัวแทนของคุณรองรับ คุณต้องระบุเวอร์ชันของคำถามแต่ละข้อสำหรับภาษาเริ่มต้น หากผู้ใช้ได้รับแบบสำรวจแต่ใช้ภาษาที่ไม่มีคำถามที่กำหนดเองเวอร์ชันที่ระบุ คำถามจะแสดงตามที่กำหนดไว้ในภาษาเริ่มต้นของตัวแทน

คำตอบสำหรับคำถามที่กำหนดเองรองรับข้อความและข้อมูลระบบรายงานผล Conversion แยกกัน ซึ่งคล้ายกับคำตอบที่แนะนำ

ปรับแต่งแบบสำรวจ

หากต้องการปรับแต่งแบบสำรวจสำหรับตัวแทน ให้ทำดังนี้

  1. เปิดคอนโซลนักพัฒนาแอปการสื่อสารทางธุรกิจ แล้วลงชื่อเข้าใช้ด้วยบัญชี Google ของ Business Messages
  2. เลือกตัวแทน
  3. คลิกแบบสำรวจในการนำทางด้านซ้าย
  4. เพิ่มคำถามจากเทมเพลตที่มีอยู่ลงในแบบสำรวจได้สูงสุด 2 ข้อ
  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"
  }
}

ดูตัวเลือกการจัดรูปแบบและค่าได้ที่ UserMessage และ SurveyResponse