Wysyłaj ankiety do śledzenia zadowolenia użytkowników

Spersonalizowana ankieta w rozmowie w Business Messages.

Aby zapewnić satysfakcję użytkowników z Twojego agenta, Google wysyła do nich ankiety po zakończeniu rozmów. Jeśli chcesz zbierać dane w różnym czasie, np. pod koniec rozmowy, możesz wysyłać ankiety w kontekście rozmowy. Ankiety są wyświetlane w rozmowie i pozwalają użytkownikom przekazywać opinie z różnymi opcjami w zależności od pytania.

Czas wysyłania ankiet wywoływanych przez Google zależy od dostępności komunikatów agenta:

Dostępność Czas trwania ankiety
Tylko bot 30 minut po ostatniej wiadomości,
Tylko człowiek 24 godziny robocze od ostatniej wiadomości
Robot i człowiek 24 godziny robocze od ostatniej wiadomości

Jeśli w ciągu następnych 7 dni minęło mniej niż 24 godziny robocze, zamiast tego użyjemy 24 godzin.

Możesz wysłać jedną ankietę na rozmowę co 24 godziny. Jeśli wyślesz ankietę w rozmowie przed Google, nie wyślesz ankiety do tej rozmowy. Jeśli agent wyśle wiele ankiet w ramach tej samej rozmowy w ciągu 24 godzin, Business Messages spróbuje wysłać do użytkownika tylko pierwszą ankietę.

Gdy następnym razem użytkownik rozpocznie rozmowę z agentem po wypełnieniu ankiety, agent wyświetli greeting. Jeśli użytkownik nie odpowie na ankietę, ankieta wygaśnie po 7 dniach, a po zakończeniu ankiety zobaczy powitanie w następnej rozmowie.

Jeśli w czasie, gdy ankieta jest aktywna, użytkownik wyśle wiadomość niezwiązaną z ankietą, Business Messages anuluje ankietę i wyśle wiadomość do webhooka agenta.

Jeśli nie wyślesz ankiet użytkownikom, agent nadal otrzyma na webhooku wyniki ankiet Google i powinna je zaakceptować i przetworzyć.

Pytania

Ankiety mogą zawierać maksymalnie 5 pytań podzielonych na 3 kategorie: wymagane, szablon i niestandardowe. Ankieta zawsze zawiera wymagane pytanie, następnie wyświetla maksymalnie 2 szablony pytań i maksymalnie 2 pytania niestandardowe.

Pytanie wymagane

Wymagane pytanie jest przetłumaczone na wszystkie języki obsługiwane przez Business Messages. Użytkownicy mogą odpowiadać kciukiem w górę lub w dół.

Wymagane pytanie: „Czy ta usługa do przesyłania wiadomości zaspokaja Twoje potrzeby związane z kontaktem z firmą AGENT_NAME?”

Szablony pytań

Pytania z szablonów to opcjonalne, zdefiniowane przez Google pytania, które są przetłumaczone na wszystkie języki obsługiwane przez Business Messages. Ankieta może zawierać maksymalnie 2 szablony pytań. Formaty odpowiedzi użytkowników różnią się w zależności od pytania.

Szablony pytań obejmują

  • Jak oceniasz rozmowę z firmą AGENT_NAME?
  • Jak bardzo prawdopodobne jest, że polecisz usługę AGENT_NAME znajomym?
  • Gdy następnym razem będziesz kontaktować się z firmą AGENT_NAME, jak bardzo prawdopodobne jest, że wybierzesz opcję wiadomości?
  • Jak ogólnie oceniasz łatwość interakcji z firmą AGENT_NAME?
  • W jakim stopniu zgadzasz się z tym stwierdzeniem: Usługa AGENT_NAME ułatwiła mi rozwiązanie problemu.
  • Jaki jest Twój ogólny poziom zadowolenia z pracy zespołu pomocy?
  • Czy ta sesja czatu pomogła Ci uniknąć połączenia z numerem AGENT_NAME?

Aby zobaczyć listę wszystkich dostępnych pytań i uzyskać identyfikatory szablonów:

  1. Otwórz konsolę programisty Business Communications i zaloguj się na konto Google Business Messages.
  2. Wybierz agenta.
  3. W panelu nawigacyjnym po lewej stronie kliknij Ankieta.

Pytania niestandardowe

Ankieta może zawierać maksymalnie 2 pytania niestandardowe. Jeśli określisz pytanie niestandardowe, dodaj jego wersje dla każdego obsługiwanego języka, który obsługuje Twój agent. Musisz określić wersję każdego pytania dla swojego domyślnego języka. Jeśli użytkownik otrzyma ankietę, ale przebywa w regionie, w którym nie ma określonej wersji niestandardowego pytania, pytanie wyświetla się zgodnie z definicją w domyślnym języku agenta.

Odpowiedzi na niestandardowe pytania zawierają oddzielny tekst i dane wywołania zwrotnego, podobnie jak w przypadku sugerowanych odpowiedzi.

Dostosowywanie ankiety

Aby dostosować ankietę do pracownika obsługi klienta:

  1. Otwórz konsolę programisty Business Communications i zaloguj się na konto Google Business Messages.
  2. Wybierz agenta.
  3. W panelu nawigacyjnym po lewej stronie kliknij Ankieta.
  4. Dodaj do ankiety maksymalnie 2 dostępne szablony pytań.
  5. Kliknij Utwórz niestandardowe pytanie, aby dodać do ankiety niestandardowe pytania.

Opcje formatowania i wartości znajdziesz w sekcji surveyConfig.

Wyślij ankietę

Ankieta

Aby wysłać ankietę, uruchom następujące polecenie. Zastąp CONVERSATION_ID identyfikatorem rozmowy, w której chcesz wysłać ankietę, a SURVEY_ID unikalnym identyfikatorem ankiety.

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)

Opcje formatowania i wartości znajdziesz w sekcji conversations.surveys.

Otrzymuj odpowiedzi na pytania z ankiety

Gdy użytkownik odpowie na pytanie w ankiecie, agent otrzyma tę odpowiedź przez webhooka. Odbieraj i przetwarzaj odpowiedzi na pytania z ankiety tak samo jak otrzymujesz wiadomości.

Wszystkie pytania w ankiecie mają tę samą wartość surveyResponse.survey. Jeśli ankieta zawiera wiele pytań, sprawdź, czy Twoja infrastruktura akceptuje wiele odpowiedzi z tą samą wartością surveyResponse.survey i identyfikuje poszczególne pytania za pomocą pola surveyResponse.surveyQuestionId.

Wartości tekstowe odpowiedzi na ankietę znajdują się tutaj: surveyResponse.questionResponseText. W przypadku wymaganych i szablonowych pytań Business Messages wyświetla kciuk w górę jako VERY_SATISFIED i kciuk w dół jako VERY_DISSATISFIED. Jeśli odpowiedź na niestandardowe pytanie zawiera emotikon, lepiej polegać na parametrze surveyResponse.questionResponsePostbackData zamiast analizować wartość Unicode.

Odpowiedzi w ankiecie mają następujący format:

{
  "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"
  }
}

Informacje o opcjach formatowania i wartości znajdziesz w sekcjach UserMessage i SurveyResponse.