Google, लोगों को आपके एजेंट से बातचीत करने के बाद सर्वे भेजता है. इससे यह पक्का किया जाता है कि लोग आपके एजेंट से संतुष्ट हैं. अगर आपको अलग-अलग समय पर डेटा इकट्ठा करना है, जैसे कि बातचीत के खत्म होने पर, तो उस बातचीत के दौरान सर्वे भेजे जा सकते हैं. सर्वे, बातचीत में दिखते हैं. इनकी मदद से, उपयोगकर्ता सवाल के हिसाब से कई विकल्पों के साथ सुझाव दे सकते हैं.
Google की ओर से ट्रिगर किए जाने वाले सर्वे का समय, एजेंट की मैसेज सेवा के हिसाब से तय होता है:
उपलब्धता | सर्वे का समय |
---|---|
सिर्फ़ बॉट | पिछले मैसेज के 30 मिनट बाद |
सिर्फ़ इंसानों के लिए | पिछले मैसेज के 24 कामकाजी घंटों के बाद |
बॉट और इंसान | पिछले मैसेज के 24 कामकाजी घंटों के बाद |
अगर अगले सात दिनों में 24 से कम कामकाजी घंटे हैं, तो हम इसके लिए 24 घंटे का इस्तेमाल करेंगे.
हर 24 घंटे में हर बातचीत के लिए एक सर्वे भेजा जा सकता है. अगर आपने Google से पहले किसी बातचीत में सर्वे भेजा है, तो Google उस बातचीत को सर्वे नहीं भेजेगा. अगर आपका एजेंट 24 घंटे के अंदर एक ही बातचीत में कई सर्वे भेजता है, तो Business Messages उपयोगकर्ता को सिर्फ़ पहला सर्वे भेजने की कोशिश करता है.
जब कोई उपयोगकर्ता अगली बार सर्वे पूरा करने के बाद आपके एजेंट से बातचीत शुरू करता है, तो एजेंट greeting मैसेज दिखाता है. अगर कोई उपयोगकर्ता सर्वे का जवाब नहीं देता है, तो सर्वे सात दिनों के बाद खत्म हो जाता है. साथ ही, सर्वे की समयसीमा खत्म होने के बाद, उपयोगकर्ता को अगली बातचीत में वेलकम मैसेज दिखता है.
अगर कोई उपयोगकर्ता, सर्वे के दौरान ऐसा मैसेज भेजता है जो सर्वे से नहीं जुड़ा हुआ है, तो Business Messages उस सर्वे को रद्द कर देता है और उपयोगकर्ता का मैसेज, एजेंट के वेबहुक पर भेज देता है.
अगर लोगों को सर्वे नहीं भेजा जाता है, तब भी आपके एजेंट को आपके वेबहुक पर Google के सर्वे के नतीजे मिलते हैं. साथ ही, उन्हें उसी हिसाब से सर्वे के नतीजे स्वीकार और प्रोसेस करने चाहिए.
सवाल
सर्वे में ज़्यादा से ज़्यादा पांच सवाल हो सकते हैं और इन्हें तीन कैटगरी में बांटा जा सकता है: ज़रूरी, टेंप्लेट, और कस्टम. सर्वे में हमेशा ज़रूरी सवाल शामिल होता है, फिर ज़्यादा से ज़्यादा दो टेंप्लेट सवाल दिखाए जाते हैं और फिर ज़्यादा से ज़्यादा दो कस्टम सवाल दिखाए जाते हैं.
ज़रूरी सवाल
ज़रूरी सवाल उन सभी भाषाओं में उपलब्ध है जो Business Messages में इस्तेमाल किए जा सकते हैं. उपयोगकर्ता, पसंद या नापसंद का आइकॉन क्लिक करके जवाब दे सकते हैं.
ज़रूरी सवाल: "क्या इस मैसेज सेवा ने AGENT_NAME से जुड़ी आपकी ज़रूरतों को पूरा किया है?"
टेंप्लेट से जुड़े सवाल
टेंप्लेट में पूछे जाने वाले सवालों के लिए Google के तय किए गए सवाल इस्तेमाल करना ज़रूरी नहीं है. इन्हें उन सभी जगहों के लिए स्थानीय भाषा में बनाया गया है जहां Business Messages काम करता है. एक सर्वे में ज़्यादा से ज़्यादा दो टेंप्लेट सवाल शामिल हो सकते हैं. उपयोगकर्ता के जवाब का फ़ॉर्मैट, सवाल के हिसाब से अलग-अलग होता है.
टेंप्लेट से जुड़े सवालों में ये शामिल हैं
- AGENT_NAME को मैसेज भेजने का आपका अनुभव कैसा रहा?
- इस बात की कितनी संभावना है कि आप किसी दोस्त को AGENT_NAME का सुझाव दें?
- इस बात की कितनी संभावना है कि अगली बार आप AGENT_NAME से संपर्क करें और मैसेज सेवा का इस्तेमाल करें?
- कुल मिलाकर, AGENT_NAME के साथ इंटरैक्ट करना कितना आसान था?
- आप इस बात से किस हद तक सहमत या असहमत हैं: AGENT_NAME ने मेरी समस्या को हल करने में मेरी मदद की.
- कृपया बताएं कि सहायता असोसिएट से आप किस हद तक संतुष्ट हैं.
- क्या इस चैट सेशन में, आपको AGENT_NAME पर कॉल करने से रोका गया?
सभी उपलब्ध टेंप्लेट सवालों की सूची देखने और टेंप्लेट आईडी पाने के लिए,
- Business Communications डेवलपर कंसोल खोलें और अपने Business Messages Google खाते से साइन इन करें.
- अपना एजेंट चुनें.
- बाईं ओर मौजूद नेविगेशन में, सर्वे पर क्लिक करें.
मनमुताबिक सवाल
एक सर्वे में ज़्यादा से ज़्यादा दो कस्टम सवाल शामिल हो सकते हैं. अगर आपने अपनी पसंद के मुताबिक कोई सवाल पूछा है, तो हर उस इलाके के लिए सवाल के वर्शन शामिल करें जिसका इस्तेमाल आपका एजेंट करता है. आपको अपनी डिफ़ॉल्ट भाषा के लिए हर सवाल का एक वर्शन तय करना होगा. अगर किसी उपयोगकर्ता को सर्वे मिलता है, लेकिन वह ऐसी जगह या भाषा में है जिसमें पसंद के मुताबिक बनाए गए सवाल का कोई तय वर्शन नहीं होता, तो सवाल वही दिखता है जो एजेंट की डिफ़ॉल्ट स्थान-भाषा में बताया गया होता है.
पसंद के मुताबिक सवालों के जवाबों के लिए, अलग टेक्स्ट और पोस्टबैक डेटा का इस्तेमाल किया जा सकता है. यह डेटा, सुझाए गए जवाबों की तरह ही काम करता है.
सर्वे को पसंद के मुताबिक बनाना
अगर आपको एजेंट के लिए, सर्वे को पसंद के मुताबिक बनाना है, तो
- Business Communications डेवलपर कंसोल खोलें और अपने Business Messages Google खाते से साइन इन करें.
- अपना एजेंट चुनें.
- बाईं ओर मौजूद नेविगेशन में, सर्वे पर क्लिक करें.
- सर्वे में, टेंप्लेट से जुड़े ज़्यादा से ज़्यादा दो उपलब्ध सवाल जोड़ें.
- अपने सर्वे में पसंद के मुताबिक सवाल जोड़ने के लिए, पसंद के मुताबिक सवाल बनाएं पर क्लिक करें.
फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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
देखें.
सर्वे के जवाब पाएं
जब कोई उपयोगकर्ता सर्वे में सवाल का जवाब देता है, तो आपके एजेंट को अपने वेबहुक पर जवाब मिलता है. सर्वे के जवाबों को उसी तरह पाएं और प्रोसेस करें जिस तरह आपको मैसेज मिलते हैं.
सर्वे के सभी सवालों के लिए, surveyResponse.survey
की एक ही वैल्यू दी जाती है. अगर आपके सर्वे में कई सवाल शामिल हैं, तो पक्का करें कि आपका इन्फ़्रास्ट्रक्चर एक ही surveyResponse.survey
वैल्यू वाले कई जवाब स्वीकार करता हो और surveyResponse.surveyQuestionId
फ़ील्ड की मदद से अलग-अलग सवालों की पहचान करता हो.
सर्वे के जवाबों के लिए टेक्स्ट वैल्यू,
surveyResponse.questionResponseText
में दिखती हैं. ज़रूरी और टेंप्लेट से जुड़े सवालों के लिए,
Business Messages, पसंद करने के जवाब में VERY_SATISFIED
और नापसंद का जवाब VERY_DISSATISFIED
के तौर पर दिखाता है. अगर पसंद के मुताबिक सवाल के जवाब में कोई इमोजी शामिल है, तो यूनिकोड की वैल्यू को पार्स करने के बजाय, surveyResponse.questionResponsePostbackData
पर भरोसा करना सबसे सही तरीका है.
सर्वे के जवाबों का फ़ॉर्मैट नीचे दिया गया है.
{ "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
देखें.