שליחת סקרים כדי לבדוק את שביעות הרצון של המשתמשים

סקר מותאם אישית בשיחה ב-Business Messages.

כדי לוודא שהאינטראקציות עם הנציג משביעות את רצון המשתמשים, Google שולחת סקרים למשתמשים אחרי שהם סיימו את השיחות עם הנציג. אם רוצים לאסוף נתונים בתזמון שונה, למשל בסוף השיחה, אפשר לשלוח סקרים בהקשר של שיחה. הסקרים מוצגים בשיחה ומאפשרים למשתמשים לתת משוב עם מגוון אפשרויות, בהתאם לשאלה.

התזמון של סקרים שהופעלו על ידי Google תלוי בזמינות ההודעות של הסוכן:

זמינות תזמון הסקר
בוטים בלבד 30 דקות אחרי ההודעה האחרונה
לבני אדם בלבד 24 שעות אחרי ההודעה האחרונה
רובוט אנושי 24 שעות אחרי ההודעה האחרונה

אם יהיו פחות מ-24 שעות פעילות ב-7 הימים הקרובים, נשתמש ב-24 שעות במקום זאת.

אפשר לשלוח סקר אחד לכל שיחה בכל 24 שעות. אם שולחים סקר בשיחה לפני Google, Google לא שולחת סקר בשיחה הזו. אם הנציג שולח כמה סקרים באותה שיחה תוך 24 שעות, מערכת Business Messages תנסה לשלוח למשתמש רק את הסקר הראשון.

בפעם הבאה שמשתמש מתחיל שיחה עם הנציג אחרי מילוי סקר, הוא מציג הודעת greeting. אם משתמש לא עונה על סקר, התוקף של הסקר פג אחרי 7 ימים, והמשתמש רואה את הודעת הפתיחה בשיחה הבאה שלו אחרי שפג התוקף של הסקר.

אם משתמש שולח הודעה שלא קשורה לסקר בזמן שהסקר פעיל בשיחה, אפליקציית Business Messages מבטלת את הסקר ושולחת את ההודעה של המשתמש ל-webhook של הנציג.

גם אם לא שולחים סקרים למשתמשים, הנציג עדיין מקבל את תוצאות הסקרים של Google ב-webhook, והוא צריך לאשר ולעבד אותן בהתאם.

שאלות

הסקרים יכולים לכלול עד חמש שאלות, בחלוקה לשלוש קטגוריות: חובה, תבנית ובהתאמה אישית. סקר תמיד כולל את שאלת החובה, ולאחר מכן מציג עד שתי שאלות בתבנית ובשלב הבא מוצגות עד שתי שאלות מותאמות אישית.

שאלה נדרשת

השאלה הנדרשת מותאמת לשוק המקומי בכל הלוקאלים שנתמכים על ידי Business Messages. המשתמשים יכולים להגיב באמצעות לייק או דיסלייק.

השאלה הנדרשת: "האם שירות ההודעות הזה נתן מענה לצרכים שלך בעזרת AGENT_NAME?"

שאלות על תבניות

שאלות לגבי תבניות הן אופציונליות בהגדרת Google שמותאמות לשוק המקומי בכל הלוקאלים שנתמכים על ידי Business Messages. אפשר לכלול בסקר עד שתי שאלות תבנית. הפורמטים של תגובת המשתמשים משתנים בהתאם לשאלה.

יש שאלות לגבי תבניות

  • איך הייתה חוויית שליחת ההודעות אל AGENT_NAME?
  • מה הסיכוי שחברים שלך יקבלו ממך המלצה על AGENT_NAME?
  • מה הסבירות שבפעם הבאה שתיצרו קשר עם AGENT_NAME היא תרצו לשלוח הודעות?
  • באופן כללי, עד כמה היה לך קל לתקשר עם AGENT_NAME?
  • עד כמה המשפט הבא נכון בעיניך: AGENT_NAME עזר לי לפתור את הבעיה שלי בקלות.
  • מה רמת שביעות הרצון הכללית שלך מנציג התמיכה?
  • האם הצ'אט עזר לך להימנע משיחה אל AGENT_NAME?

כדי לראות רשימה של כל השאלות הזמינות לגבי תבניות ולקבל מזהי תבניות,

  1. פותחים את Business Communications Developer Console ונכנסים באמצעות חשבון Google של Business Messages.
  2. צריך לבחור נציג.
  3. בחלונית הניווט הימנית, לוחצים על סקר.

שאלות מותאמות אישית

סקר יכול לכלול עד שתי שאלות מותאמות אישית. אם בוחרים שאלה בהתאמה אישית, צריך לכלול גרסאות שלה לכל לוקאל שהנציג תומך בהן. עליכם לציין גרסה של כל שאלה בלוקאל ברירת המחדל. אם משתמש מקבל סקר אבל נמצא בלוקאל שלא צוינה בו גרסה של שאלה בהתאמה אישית, השאלה תוצג כפי שהיא מוגדרת בלוקאל ברירת המחדל של הנציג.

התשובות לשאלות בהתאמה אישית תומכות בנתונים נפרדים לטקסט ולדיווח חוזר על המרה, בדומה להצעות לתשובות.

התאמה אישית של סקר

כדי להתאים אישית את הסקר לנציג תמיכה:

  1. פותחים את Business Communications Developer Console ונכנסים באמצעות חשבון Google של Business Messages.
  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"
  }
}

למידע על אפשרויות העיצוב והערך, ראו UserMessage ו-SurveyResponse.