ビジネス メッセージ エージェントとの会話では、ウェルカム メッセージによってやり取りのトーンが決まります。また、エージェントが何ができるかをユーザーに知らせるため、ユーザーの質問や期待値が形作られます。
エージェントは、ユーザーが会話を開くたびにウェルカム メッセージを送信します。また、エージェントは会話の開始条件を表示して、よく知られているパス、またはよく使われるパスにユーザーを誘導することもできます。
ユーザーがエージェントの対応時間外に会話を開始しようとすると、エージェントは、別のチャネルの共有や次のステップの提案に使用できるオフライン メッセージを表示します。これらの設定を利用することで、エージェントの信頼性とユーザビリティを高めることができます。
エージェント レベルと地域レベルの設定
エージェント レベルまたはロケーション レベルで会話の設定を指定できます。
エージェント レベル: この会話設定は、すべてのエントリ ポイントでエージェントとのすべての会話に適用されます。
エージェント レベルのウェルカム メッセージは、「Bridgepoint Runner にお問い合わせいただきありがとうございます」のように表示されることがあります。会話のきっかけは、会社全体の行動や情報に焦点を絞ることができます。
ロケーション レベル: これらの設定はエージェント レベルの設定をオーバーライドし、
PLACESHEET
とMAPS
のエントリ ポイントを介したそのロケーションとの会話にのみ適用されます。場所レベルのウェルカム メッセージとして、「ありがとうございます。Bridgepoint Runners on Amphitheatre Pkwy...」のように表示されることがあります。会話のきっかけは位置情報ベースのタスクや情報に 焦点を当てることができますオフライン メッセージに、そのビジネスが次に開店するタイミングが記載されていることもあります。
言語 / 地域
エージェントとロケーションは、サポートするロケールごとに別々の設定を指定できます。たとえば、エージェントが「en」ロケールでは英語のウェルカム メッセージを指定し、「es」ロケールではスペイン語で同じウェルカム メッセージを使用します。ビジネス メッセージは、ユーザー デバイスで報告される言語 / 地域と、エージェントまたは場所が会話の設定を行っている言語 / 地域との間の一致を解決します。
この言語 / 地域の一致は、各メッセージの resolvedLocale
フィールドで報告されます。エージェントまたはロケーションの defaultLocale
を指定できます。これにより、解決される言語 / 地域の一致の重み付けが行われます。ローカライズとロケールをご覧ください。
ビジネス メッセージは、解決された言語 / 地域を使用して、適用する会話設定を決定します。
ウェルカム メッセージ
エージェントとユーザーの会話の最初のメッセージが、エージェントのウェルカム メッセージです。ウェルカム メッセージは、ユーザーが新しい会話を開始すると自動的に表示されます。適切なウェルカム メッセージは、エージェントとのやり取りについてユーザーが期待するものを明確にします。ウェルカム メッセージを編集するには、会話の設定を更新するをご覧ください。
お客様との会話のきっかけ
適切なウェルカム メッセージはエージェントの機能を大まかに説明するものであり、自由に回答できるものですが、会話のきっかけとして適切なものは、よく寄せられる質問や既知の機能にユーザーを案内します。
会話の冒頭部分は、ウェルカム メッセージのすぐ後に縦に積み重ねられた返信文の候補として表示されます。ユーザーが会話の開始条件をタップすると、エージェントは、開始条件を指定したときに設定した事前定義済みのコンテンツとポストバック データを受け取ります。
エージェントが特定のリクエストに対して自動化機能をサポートしている場合、会話開始条件をそれらのリクエストにマッピングすることで、既知の入力を自動化に利用して、ユーザーの質問に答えるライブ対応のエージェントに自由形式の質問を送信できます。
エージェントには最大 5 つの会話開始条件を設定でき、各開始条件には最大 35 文字を使用できます。
会話のきっかけを追加または編集するには、会話の設定を更新するをご覧ください。
オフライン メッセージ
ユーザーがエージェントの対応時間外(MessagingAvailability
で定義)にエージェントとの会話を開始すると、ユーザーはエージェントのオフライン メッセージを受信します。オフライン メッセージをトリガーする際は、人間の代表的な可用性のみが考慮されます。bot 担当者しかいないエージェントは、常にウェルカム メッセージを送信します。効果的なオフライン メッセージ
- エージェントが対応できない理由を説明している
- 適切な次のステップや別のお問い合わせ方法をお客様に説明している
- ウェルカム メッセージと会話のきっかけに合ったトーンを使用している
不適切なオフライン メッセージ
「申し訳ありませんが、閉店しています。」
良いオフライン メッセージ
「ただいまの時間は営業時間外となっております。明日の午前 8 時からご視聴いただけますと幸いです。緊急のサポートが必要な場合は、サポート(+12223334444)または support@gtb.com までご連絡ください。」
オフライン メッセージを編集するには、会話の設定を更新するをご覧ください。
会話の設定を更新する
ウェルカム メッセージまたは会話のきっかけを管理するには、Business Communications API を使用して PATCH リクエストを行い、エージェントまたはロケーションの conversationalSettings
フィールドを更新します。
conversationalSettings
フィールドを更新する場合は、ConversationalSetting
オブジェクト内のすべてのフィールドに値を含める必要があります。更新リクエストによって、編集したすべてのフィールドの内容(子フィールドを含む)が上書きされます。たとえば、ウェルカム メッセージを変更するリクエストを行ったものの、会話開始条件が含まれていない場合、そのリクエストにより、以前の会話開始条件がすべて削除されます。
前提条件
会話の設定を更新する前に、次のものが必要です。
- 開発マシン上の GCP プロジェクトのサービス アカウント キーのパス
- 設定を更新する言語 / 地域
エージェント レベルの設定の場合、エージェント
name
(例: 「brands/12345/agents/67890」)エージェントの
name
がわからない場合は、ブランドのすべてのエージェントを一覧表示するをご覧ください。地域単位で設定する場合は、地域
name
を使用します(例: 「brands/12345/locations/67890」)。ビジネスの
name
がわからない場合は、ブランドのすべての地域を一覧表示するをご覧ください。更新する言語 / 地域(2 文字の ISO 639-1 言語コード)。
新しいウェルカム メッセージ
プライバシー ポリシーの URL
(省略可)会話の冒頭部分のテキスト
(省略可)会話の冒頭のポストバック データ
(省略可)新しいオフライン メッセージ
現在の conversationalSettings
値が不明な場合は、エージェント情報を取得すると位置情報を取得するをご覧ください。
更新リクエストを送信する
エージェントまたはロケーションを更新するには、次のコマンドを実行します。変数は、前提条件で確認した値に置き換えます。
会話の開始条件を使用しない場合は、conversationStarters
とそのすべての子フィールドを省略します。
エージェント レベルの設定
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(); } } }このコードは、Java Business Communications クライアント ライブラリに基づいています。
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)
地域単位の設定
# 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" } } } ] } } }'
形式と値については、brands.agents.patch
、brands.locations.patch
、ConversationalSetting
をご覧ください。
例
エージェント レベルの設定
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', }, }, }, ], }, }, }, }"
地域単位の設定
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', }, }, }, }, ], }, }, }"