Trong các cuộc trò chuyện với nhân viên hỗ trợ Business Messages, tin nhắn chào mừng sẽ đặt giọng điệu tương tác. API này cũng cho người dùng biết những việc mà nhân viên hỗ trợ có thể làm, định hình câu hỏi và kỳ vọng của người dùng.
Nhân viên hỗ trợ gửi tin nhắn chào mừng mỗi khi người dùng mở cuộc trò chuyện. Chiến lược phát hành đĩa đơn tác nhân cũng có thể hiển thị đoạn bắt đầu cuộc trò chuyện để hướng dẫn người dùng theo dõi các đường dẫn đã biết hoặc thường xuyên.
Nếu người dùng cố gắng bắt đầu cuộc trò chuyện ngoài giờ làm việc của một nhân viên hỗ trợ, nhân viên hỗ trợ sẽ hiển thị thông báo ngoại tuyến bạn có thể dùng để chia sẻ các kênh thay thế hoặc đề xuất các bước tiếp theo. Bằng cách tận dụng các chế độ cài đặt này, bạn có thể tăng độ tin cậy và khả năng hữu dụng của nhân viên hỗ trợ.
Chế độ cài đặt ở cấp nhân viên hỗ trợ và cấp vị trí
Bạn có thể chỉ định chế độ cài đặt trò chuyện ở cấp độ nhân viên hỗ trợ hoặc vị trí.
Cấp nhân viên hỗ trợ: Các chế độ cài đặt trò chuyện này áp dụng cho tất cả các cuộc trò chuyện có trên tất cả các điểm truy cập.
Tin nhắn chào mừng ở cấp nhân viên hỗ trợ có thể bắt đầu "Cảm ơn bạn đã liên hệ với Người chạy ở cầu nối..." Câu mở đầu cuộc trò chuyện có thể tập trung vào hành động hoặc thông tin trên toàn công ty.
Cấp vị trí: Các chế độ cài đặt này sẽ ghi đè chế độ cài đặt ở cấp nhân viên hỗ trợ và chỉ áp dụng cho các cuộc trò chuyện có vị trí đó trong
PLACESHEET
vàMAPS
điểm truy cập.Thông báo chào mừng ở cấp vị trí có thể bắt đầu "Cảm ơn bạn đã liên hệ Nhà hát Bridgepoint Runners ở Amphitheatre Pkwy..." Câu mở đầu cuộc trò chuyện có thể tập trung dựa trên các nhiệm vụ hoặc thông tin dựa trên vị trí. Tin nhắn ngoại tuyến có thể đề cập đến khi vị trí đó sẽ mở cửa lần tới.
Ngôn ngữ
Nhân viên hỗ trợ và địa điểm có thể chỉ định các chế độ cài đặt riêng cho bất kỳ ngôn ngữ nào mà họ của Google. Ví dụ: nhân viên hỗ trợ có thể chỉ định tin nhắn chào mừng bằng tiếng Anh cho chữ "vi" ngôn ngữ và có cùng thông điệp chào mừng bằng tiếng Tây Ban Nha cho chữ "es" ngôn ngữ. Business Messages giải quyết trường hợp trùng khớp giữa ngôn ngữ được báo cáo của thiết bị của người dùng và ngôn ngữ mà nhân viên hỗ trợ hoặc vị trí hỗ trợ bất kỳ chế độ cài đặt trò chuyện nào.
Khớp ngôn ngữ này được báo cáo trong mỗi thông báo Trường resolvedLocale
. Bạn
có thể chỉ định defaultLocale
của tác nhân hoặc vị trí mà trọng số đã được phân giải
khớp ngôn ngữ. Xem phần Bản địa hoá và
ngôn ngữ.
Business Messages sử dụng ngôn ngữ đã phân giải để xác định xem cuộc trò chuyện nào để áp dụng.
Tin nhắn chào mừng
Tin nhắn đầu tiên trong một cuộc trò chuyện giữa một nhân viên hỗ trợ và người dùng là tin nhắn của nhân viên hỗ trợ tin nhắn chào mừng. Thông báo chào mừng tự động xuất hiện sau khi người dùng bắt đầu cuộc trò chuyện mới. Thư chào mừng đặt ra kỳ vọng của người dùng khi tương tác với nhân viên hỗ trợ. Để chỉnh sửa lời chào mừng hãy xem Cập nhật chế độ cài đặt trò chuyện.
Dẫn dắt cuộc trò chuyện
Mặc dù một tin nhắn chào mừng phù hợp lại bao hàm chức năng tổng thể của nhân viên hỗ trợ và là những câu mở đầu hay để bắt đầu cuộc trò chuyện hướng dẫn người dùng đến các câu hỏi thường gặp hoặc chức năng đã biết.
Câu bắt đầu cuộc trò chuyện sẽ xuất hiện dưới dạng cụm từ đề xuất được xếp chồng theo chiều dọc trả lời và trực tiếp theo dõi tin nhắn chào mừng. Khi người dùng nhấn vào một cuộc trò chuyện điều kiện khởi động, tác nhân sẽ nhận nội dung được xác định trước và dữ liệu đăng lại mà bạn đã đặt khi bạn chỉ định điều kiện khởi động.
Nếu một nhân viên hỗ trợ hỗ trợ chức năng tự động cho một số yêu cầu nhất định, câu mở đầu cuộc trò chuyện có thể liên kết với những yêu cầu đó, cho phép bạn dựa vào thông tin đã biết đầu vào cho quá trình tự động hoá và gửi câu hỏi dạng tự do của người dùng cho các nhân viên hỗ trợ sẵn sàng .
Một nhân viên hỗ trợ có thể có tối đa 5 câu mở đầu cuộc trò chuyện và mỗi người khởi động có thể có tối đa 35 ký tự.
Để thêm hoặc chỉnh sửa câu mở đầu cuộc trò chuyện, hãy xem phần Cập nhật câu lệnh trò chuyện cài đặt.
Tin nhắn ngoại tuyến
Khi người dùng bắt đầu cuộc trò chuyện với một nhân viên hỗ trợ bên ngoài phạm vi hoạt động của nhân viên hỗ trợ đó
giờ (như được xác định bởi
MessagingAvailability
),
người dùng sẽ nhận được thông báo ngoại tuyến của nhân viên hỗ trợ. Chỉ có người đại diện
tình trạng còn hàng sẽ được xem xét khi kích hoạt thông báo ngoại tuyến. Nhân viên hỗ trợ chỉ
yêu cầu người đại diện của bot luôn gửi tin nhắn chào mừng. Tin nhắn ngoại tuyến tốt
- Chia sẻ lý do nhân viên hỗ trợ không có mặt
- Hướng dẫn người dùng các bước tiếp theo thích hợp hoặc các kênh liên hệ thay thế
- Khớp với giọng điệu của tin nhắn chào mừng và câu mở đầu cuộc trò chuyện
Thông báo lỗi khi không có mạng
"Rất tiếc, chúng tôi đã đóng cửa."
Thông báo ngoại tuyến tốt
"Chúng tôi hiện đã đóng cửa nhưng sẽ có lại vào 8 giờ sáng mai. Nếu bạn cần hỗ trợ khẩn cấp, hãy liên hệ với Nhóm hỗ trợ theo số +12223334444 hoặc support@gtb.com."
Để chỉnh sửa một tin nhắn khi không có mạng, hãy xem phần Cập nhật chế độ cài đặt cuộc trò chuyện.
Cập nhật chế độ cài đặt trò chuyện
Để quản lý tin nhắn chào mừng hoặc câu lệnh bắt đầu cuộc trò chuyện, bạn cần tạo một yêu cầu PATCH
với kênh Business Communications
API
để cập nhật trường conversationalSettings
của nhân viên hỗ trợ hoặc vị trí.
Khi cập nhật trường conversationalSettings
, bạn phải thêm các giá trị cho
tất cả các trường trong
ConversationalSetting
. Yêu cầu cập nhật sẽ ghi đè nội dung của tất cả các trường bạn chỉnh sửa, bao gồm
bất kỳ trường con nào. Ví dụ: nếu bạn yêu cầu sửa đổi tin nhắn chào mừng
nhưng không chứa đoạn mở đầu cuộc trò chuyện, thì yêu cầu này sẽ xoá mọi câu lệnh trước đó
câu mở đầu cuộc trò chuyện.
Điều kiện tiên quyết
Trước khi cập nhật chế độ cài đặt trò chuyện, bạn cần có:
- Đường dẫn đến khoá tài khoản dịch vụ của dự án GCP trên máy phát triển
- Ngôn ngữ mà bạn muốn cập nhật chế độ cài đặt
Đối với chế độ cài đặt cấp nhân viên hỗ trợ, nhân viên hỗ trợ
name
(ví dụ: "brands/12345/agents/67890")Nếu bạn không biết
name
của nhân viên hỗ trợ, hãy xem phần Liệt kê tất cả nhân viên hỗ trợ cho một thương hiệu.Đối với chế độ cài đặt cấp vị trí, vị trí
name
(ví dụ: "brands/12345/locations/67890")Nếu bạn không biết
name
của vị trí, hãy xem Liệt kê tất cả các vị trí cho một thương hiệu.Ngôn ngữ cần cập nhật, dưới dạng ngôn ngữ ISO 639-1 gồm hai ký tự mã
Tin nhắn chào mừng mới
URL chính sách quyền riêng tư
(Không bắt buộc) Văn bản dành cho câu mở đầu cuộc trò chuyện
(Không bắt buộc) Dữ liệu đăng lại cho câu mở đầu cuộc trò chuyện
(Không bắt buộc) Thư ngoại tuyến mới
Nếu bạn không biết các giá trị conversationalSettings
hiện tại, hãy xem phần Lấy nhân viên hỗ trợ
của bạn
và Nhận thông tin vị trí
.
Gửi yêu cầu cập nhật
Để cập nhật nhân viên hỗ trợ hoặc vị trí, hãy chạy lệnh sau. Thay thế biến bằng các giá trị bạn đã xác định trong Điều kiện tiên quyết.
Nếu bạn không muốn dùng để bắt đầu cuộc trò chuyện, hãy bỏ qua conversationStarters
và tất cả
trường con.
Chế độ cài đặt ở cấp nhân viên hỗ trợ
cURL
# This code updates the conversational settings of a Business Messages agent. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch # Replace the __BRAND_ID__, __AGENT_ID__ and __LOCALE__ # Make sure a service account key file exists at ./service_account_key.json curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__?updateMask=businessMessagesAgent.conversationalSettings.__LOCALE__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "businessMessagesAgent": { "conversationalSettings": { "__LOCALE__": { "welcomeMessage": { "text": "My first welcome message" }, "offlineMessage": { "text": "My first offline message" }, "privacyPolicy": { "url": "https://www.your-company-website.com/privacy" }, "conversationStarters": [ { "suggestion": { "reply": { "text": "Suggestion 1", "postbackData": "post_back_suggestion_1" } } } ] } } } }'
Node.js
/** * This code snippet updates the conversationalSettings of a Business Messages agent. * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch * * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js * Business Communications client library. */ /** * Edit the values below: */ const BRAND_ID = 'EDIT_HERE'; const AGENT_ID = 'EDIT_HERE'; const LOCALE = 'en'; const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json'; const businesscommunications = require('businesscommunications'); const {google} = require('googleapis'); // Initialize the Business Communications API const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({}); // Set the scope that we need for the Business Communications API const scopes = [ 'https://www.googleapis.com/auth/businesscommunications', ]; // Set the private key to the service account file const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY); async function main() { const authClient = await initCredentials(); const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID; if (authClient) { // Setup the parameters for the API call const apiParams = { auth: authClient, name: agentName, updateMask: 'businessMessagesAgent.conversationalSettings.' + LOCALE, resource: { businessMessagesAgent: { conversationalSettings: { [LOCALE]: { privacyPolicy: { url: 'https://www.your-company-website.com/privacy' }, welcomeMessage: { text: 'My updated welcome message' }, offlineMessage: { text: 'My updated offline message' }, conversationStarters: [ { suggestion: { reply: { 'text': 'Suggestion 2', 'postbackData': 'post_back_suggestion_2', }, }, } ], }, } } } }; bcApi.brands.agents.patch(apiParams, {}, (err, response) => { if (err !== undefined && err !== null) { console.dir(err); } else { // Agent found console.log(response.data); } }); } else { console.log('Authentication failure.'); } } /** * 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); } }); }); } main();
Java
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.services.businesscommunications.v1.BusinessCommunications; import com.google.api.services.businesscommunications.v1.model.*; import com.google.common.collect.ImmutableMap; import java.io.FileInputStream; import java.util.Arrays; class Main { /** * Initializes credentials used by the Business Communications API. */ private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() { BusinessCommunications.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/businesscommunications")); credential.refreshToken(); HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance(); // Create instance of the Business Communications API builder = new BusinessCommunications .Builder(httpTransport, jsonFactory, null) .setApplicationName(credential.getServiceAccountProjectId()); // Set the API credentials and endpoint builder.setHttpRequestInitializer(credential); } catch (Exception e) { e.printStackTrace(); } return builder; } public static void main(String args[]) { try { // Create client library reference BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder(); String agentName = "brands/BRAND_ID/agents/AGENT_ID"; Agent agent = new Agent().setBusinessMessagesAgent( new BusinessMessagesAgent().setConversationalSettings(ImmutableMap.of("LOCALE", new ConversationalSetting() .setPrivacyPolicy(new PrivacyPolicy().setUrl("PRIVACY_POLICY_URL")) .setWelcomeMessage(new WelcomeMessage().setText("WELCOME_MESSAGE")) .setOfflineMessage(new OfflineMessage().setText("OFFLINE_MESSAGE")) .setConversationStarters(Arrays.asList( new ConversationStarters().setSuggestion(new Suggestion() .setReply(new SuggestedReply() .setText("REPLY_TEXT") .setPostbackData("POSTBACK_DATA"))), ))))); BusinessCommunications.Brands.Agents.Patch request = builder .build().brands().agents().patch(agentName, agent); request.setUpdateMask("businessMessagesAgent.conversationalSettings.LOCALE"); Agent updatedAgent = request.execute(); System.out.println(updatedAgent.toPrettyString()); } catch (Exception e) { e.printStackTrace(); } } }
Python
"""This code updates the conversational settings of a Business Messages agent. Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/patch This code is based on the https://github.com/google-business-communications/python-businessmessages Python Business Messages client library. """ from oauth2client.service_account import ServiceAccountCredentials from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1 from businesscommunications.businesscommunications_v1_messages import ( Agent, BusinessMessagesAgent, ConversationStarters, ConversationalSetting, OfflineMessage, PrivacyPolicy, WelcomeMessage, NegativeBotFeedbackMessage, BusinesscommunicationsBrandsAgentsPatchRequest, ) # Edit the values below: BRAND_ID = 'EDIT_HERE' AGENT_ID = 'EDIT_HERE' SCOPES = ['https://www.googleapis.com/auth/businesscommunications'] SERVICE_ACCOUNT_FILE = './service_account_key.json' credentials = ServiceAccountCredentials.from_json_keyfile_name( SERVICE_ACCOUNT_FILE, scopes=SCOPES) client = BusinesscommunicationsV1(credentials=credentials) agents_service = BusinesscommunicationsV1.BrandsAgentsService(client) agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID agent=Agent( businessMessagesAgent=BusinessMessagesAgent( conversationalSettings=BusinessMessagesAgent.ConversationalSettingsValue( additionalProperties=[BusinessMessagesAgent.ConversationalSettingsValue.AdditionalProperty( key='en', value=ConversationalSetting( privacyPolicy=PrivacyPolicy(url='https://www.your-company-website.com/privacy'), welcomeMessage=WelcomeMessage(text='Welcome to Business Messages'), offlineMessage=OfflineMessage(text='This is an offline message'), conversationStarters=[ ConversationStarters( suggestion=Suggestion( reply=SuggestedReply(text='Option 1', postbackData='option_1') ) )] ) ) ] ) ) ) updated_agent = agents_service.Patch( BusinesscommunicationsBrandsAgentsPatchRequest( agent=agent, name=agent_name, updateMask='businessMessagesAgent.conversationalSettings.en' ) ) print(updated_agent)
Cài đặt cấp vị trí
# This code updates the agent interaction of a bot and human representatives. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/patch # Replace the __BRAND_ID__, __AGENT_ID__, __LOCATION_ID__, __LOCALE__ # Make sure a service account key file exists at ./service_account_key.json curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__?updateMask=conversationalSettings.__LOCALE__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "conversationalSettings": { "__LOCALE__": { "welcomeMessage": { "text": "My second welcome message" }, "offlineMessage": { "text": "My second offline message" }, "privacyPolicy": { "url": "https://www.your-company-website.com/privacy" }, "conversationStarters": [ { "suggestion": { "reply": { "text": "Suggestion 2", "postbackData": "post_back_suggestion_2" } } } ] } } }'
Để biết thông tin về định dạng và giá trị, hãy xem
brands.agents.patch
!
brands.locations.patch
,
và
ConversationalSetting
.
Ví dụ
Chế độ cài đặt ở cấp nhân viên hỗ trợ
curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID?updateMask=businessMessagesAgent.conversationalSettings.en" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \ -d "{ 'businessMessagesAgent': { 'conversationalSettings': { 'en': { 'welcomeMessage': { 'text': 'Thanks for contacting Growing Tree Bank. What can I help with today?', }, 'offlineMessage': { 'text': 'We\'re closed for the night. Please reach out to us again tomorrow.', }, 'privacyPolicy': { 'url': 'https://www.growingtreebank.com/privacy', }, 'conversationStarters': [ { 'suggestion': { 'reply': { 'text': 'Set up an account', 'postbackData': 'new-account', }, }, }, { 'suggestion': { 'reply': { 'text': 'Look up account information', 'postbackData': 'account-lookup', }, }, }, ], }, }, }, }"
Cài đặt cấp vị trí
curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/12345/locations/67890?updateMask=conversationalSettings.en" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json /path/to/service/account/key businesscommunications)" \ -d "{ 'conversationalSettings': { 'en': { 'welcomeMessage': { 'text': 'Thanks for contacting Growing Tree Bank on Amphitheatre Pkwy. What can I help with today?', }, 'offlineMessage': { 'text': 'We\'re closed for the night. Please reach out to us again tomorrow.', }, 'privacyPolicy': { 'url': 'https://www.growingtreebank.com/privacy', }, 'conversationStarters': [ { 'suggestion': { 'reply': { 'text': 'What are your hours?', 'postbackData': 'hours', }, }, }, { 'suggestion': { 'reply': { 'text': 'Set up an account', 'postbackData': 'new-account', }, }, }, { 'suggestion': { 'reply': { 'text': 'Look up account information', 'postbackData': 'account-lookup', }, }, }, { 'suggestion': { 'action': { 'text': 'Call us', 'postbackData': 'call', 'dialAction': { 'phoneNumber': '+12223334444', }, }, }, }, ], }, }, }"