ビジネス メッセージの作成後 エージェント エージェントの情報を完成させるために、 関連付けられている場所を確認できます。事前にエージェントとビジネス情報の確認を行う必要があります。 彼らは launch。
エージェントの確認ステータス
エージェントのオーナー確認を行うと、ビジネス メッセージによってエージェントの情報の確認が行われます その代理店が代理人を務めるブランドの連絡先担当者と関連付けることができます。ブランドが接触すると エージェントがブランドを代表できること、およびエージェントがそのブランドを代表していることを 情報が正しい場合、エージェントは検証されます。
事前確認チェックリスト
エージェントを確認する前に、次のチェックリストを使用して問題がないか確認してください 表示される場合もあります
| エージェント情報 |
|---|
|
エージェント名
必須。ユーザーに表示されるエージェントの名前。詳しくは、 <ph type="x-smartling-placeholder"></ph> エージェントを作成する。 |
|
エージェントのロゴ
必須。ユーザーに表示されるエージェントのロゴ。詳しくは、 <ph type="x-smartling-placeholder"></ph> エージェントを作成する。 |
|
メッセージの利用可否
必須。ライブ対応のエージェントが対応可能な曜日と時間 開発できます。詳しくは、 <ph type="x-smartling-placeholder"></ph> メッセージ機能の対応状況を設定する |
|
現地の情報ではない
必須: <ph type="x-smartling-placeholder"></ph> 非ローカル エントリ ポイントです。エージェントに関連付けられたドメイン、電話番号 利用可能な地域が表示されます詳しくは、 <ph type="x-smartling-placeholder"></ph> ローカル以外の情報を設定します。 |
|
デフォルトの言語 / 地域
必須。エージェントが通常使用する言語 / 地域。詳しくは、 <ph type="x-smartling-placeholder"></ph> ローカライズとロケール。 |
|
OAuth の構成
省略可。エージェントの他のプロダクトと OAuth の統合に関する詳細。詳しくは、 <ph type="x-smartling-placeholder"></ph> OAuth で認証します。 |
|
許可されるエントリ ポイント
必須。ビジネスでエージェントを作成したかどうかを確認する場合のみ必要です 通信 API。詳しくは、 <ph type="x-smartling-placeholder"></ph> エージェントを作成する。 |
エージェントの確認後に更新できるのは、次の項目のみです。
conversationalSettingscustomAgentIddefaultLocaleprimaryAgentInteractionadditionalAgentInteractionsphone
エージェントの確認後に読み取り専用フィールドを更新する必要がある場合は、 お問い合わせください(事前に署名 ビジネス メッセージの Google アカウントを使用する必要があります。アカウント登録の方法については、以下をご覧ください。 Business に登録 メッセージをご覧ください)。
前提条件
エージェントを確認する前に、いくつかの情報を収集する必要があります。
エージェント
nameエージェントの名前がわからない場合は、エージェントの一覧表 ブランド。
開発マシン上の GCP プロジェクトのサービス アカウント キーのパス
- パートナー名(組織名)
- パートナーのメールアドレス(自分のメールアドレス)
- エージェントが代表を務めるブランドのウェブサイト(一般公開 URL として) 「https://」で始まる
- 担当者の名前とメールアドレス(通常、ブランドのウェブサイトとドメインを共有します) お客様のビジネス関係を確認できる、エージェントが代理を務めるブランド ブランドを代表する権限を有している
エージェントを確認する
エージェントの確認をリクエストすると、ビジネス メッセージからブランドにメールが届きます エージェントの情報を確認します。
ブランド担当者がエージェントの情報とビジネス メッセージの確認を行ったとき エージェントの確認が完了すると、メールが届きます。
エージェントを確認するには、次のコマンドを実行します。変数を値に置き換える 前提条件で特定されていることを確認しておく必要があります。
cURL
# This code requests a verification of a Business Messages agent.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/verify?method=api#verify_an_agent
# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json
curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__:requestVerification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
"agentVerificationContact": {
"partnerName": "Partner name",
"partnerEmailAddress": "partner@email.com",
"brandContactName": "Brand contact name",
"brandContactEmailAddress": "brand-contact@email.com",
"brandWebsiteUrl": "https://www.your-company-website.com"
}
}'
Node.js
/**
* This code snippet requests an agent verification.
* Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/verify?method=api#verify_an_agent
*
* 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 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) {
const agentVerificationContact = {
agentVerificationContact: {
partnerName: 'Partner name',
partnerEmailAddress: 'partner@email.com',
brandContactName: 'Brand contact name',
brandContactEmailAddress: 'brand-contact@email.com',
brandWebsiteUrl: 'https://www.your-company-website.com',
},
};
// Setup the parameters for the API call
const apiParams = {
auth: authClient,
name: agentName,
resource: agentVerificationContact,
};
bcApi.brands.agents.requestVerification(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.Agent;
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";
BusinessCommunications.Brands.Agents.RequestVerification request
= builder.build().brands().agents().requestVerification(agentName,
new RequestAgentVerificationRequest().setAgentVerificationContact(
new AgentVerificationContact()
.setPartnerName("PARTNER_NAME")
.setPartnerEmailAddress("PARTNER_EMAIL")
.setBrandContactName("BRAND_CONTACT_NAME")
.setBrandContactEmailAddress("BRAND_CONTACT_EMAIL")
.setBrandWebsiteUrl("BRAND_WEBSITE_URL")));
System.out.println(request.execute().toPrettyString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
このコードは
Java ビジネス
通信クライアント ライブラリ。Python
"""This code requests a verification of a Business Messages agent.
Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/verify?method=api#verify_an_agent
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 (
BusinesscommunicationsBrandsAgentsRequestVerificationRequest,
RequestAgentVerificationRequest,
AgentVerificationContact
)
# 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
verification_request = agents_service.RequestVerification(BusinesscommunicationsBrandsAgentsRequestVerificationRequest(
name=agent_name,
requestAgentVerificationRequest=RequestAgentVerificationRequest(
agentVerificationContact=AgentVerificationContact(
partnerName='Partner name',
partnerEmailAddress='partner@email.com',
brandContactName='Brand contact name',
brandContactEmailAddress='brand-contact@email.com',
brandWebsiteUrl='https://www.your-company-website.com'
))
))
print(verification_request)
書式設定と値のオプションについては、以下をご覧ください。
brands.agents.requestVerification。
エージェントのオーナー確認ステータスを取得する
エージェントの確認リクエストを行った後、エージェントの 確認できます。
エージェントの確認状態を取得するには、次のコマンドを実行します。置換 変数で識別された値を持つ変数を 前提条件。
cURL
# This code gets the agent verification state. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification # Replace the __BRAND_ID__ and __AGENT_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X GET \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/verification" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/**
* This code snippet gets an agent verification state.
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification
*
* 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 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 + '/verification',
};
bcApi.brands.agents.getVerification(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.Agent;
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/verification";
BusinessCommunications.Brands.Agents.GetVerification request
= builder.build().brands().agents().getVerification(agentName);
System.out.println(request.execute().toPrettyString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
このコードは
Java ビジネス
通信クライアント ライブラリ。Python
"""This code gets the agent verification state.
Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification
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 (
BusinesscommunicationsBrandsAgentsGetVerificationRequest,
)
# 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 + '/verification'
verification_state = agents_service.GetVerification(BusinesscommunicationsBrandsAgentsGetVerificationRequest(
name=agent_name
))
print(verification_state)
書式設定と値のオプションについては、以下をご覧ください。
brands.agents.getVerification。
エージェントの確認リクエストをキャンセルする
エージェントの情報が間違っている場合や、そうでない場合 の確認の準備ができていない場合は、保留中の確認リクエストをキャンセルできます。条件 リクエストをキャンセルすると、ビジネス メッセージがブランドの連絡先に通知され、 確認プロセスを再開するには、新しい確認リクエストを作成する必要があります。
エージェントの確認リクエストをキャンセルするには、次のコマンドを実行します。置換 変数で識別された値を持つ変数を 前提条件。
cURL
# This code updates the verification state of an agent.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateVerification
# Replace the __BRAND_ID__ and __AGENT_ID__
# 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__/verification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
"verificationState": "VERIFICATION_STATE_UNVERIFIED"
}'
Node.js
/**
* This code snippet updates the state of an agent verification.
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateVerification
*
* 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 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 + '/verification',
updateMask: 'verificationState',
resource: {
name: agentName,
verificationState: 'VERIFICATION_STATE_UNVERIFIED',
}
};
bcApi.brands.agents.updateVerification(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.Agent;
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/verification";
BusinessCommunications.Brands.Agents.UpdateVerification request
= builder.build().brands().agents().updateVerification(agentName,
new AgentVerification().setVerificationState("VERIFICATION_STATE_UNVERIFIED"));
System.out.println(request.execute().toPrettyString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
このコードは
Java ビジネス
通信クライアント ライブラリ。Python
"""This code updates the verification state of an agent.
Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateVerification
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 (
AgentVerification,
BusinesscommunicationsBrandsAgentsUpdateVerificationRequest,
)
# 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 + '/verification'
update_request = agents_service.UpdateVerification(
BusinesscommunicationsBrandsAgentsUpdateVerificationRequest(
name=agent_name,
updateMask='verificationState',
agentVerification=AgentVerification(verificationState=AgentVerification.VerificationStateValueValuesEnum.VERIFICATION_STATE_UNVERIFIED)
)
)
print(update_request)
書式設定と値のオプションについては、以下をご覧ください。
brands.agents.updateVerification。
地域の確認
エージェントのオーナー確認が完了すると、そのエージェントに関連付けられているビジネスのオーナー確認を行うことができます。 ビジネスのオーナー確認が完了して、関連付けられているエージェントが起動すると、 エージェントで使用するロケーションを指定します。
ブランドがチェーンに属する場合は、そのチェーンの拠点をすべて追加する必要があります。 メッセージ機能を有効にする権限があります。追加したすべてのビジネス情報のオーナー確認を行うには、 特定のビジネス情報のオーナー確認をリクエストできます。場所の確認が完了すると 追加した他の関連するビジネス情報のオーナー確認が自動的に行われます。
オーナー確認後、さらに場所を追加する場合は、リクエストする必要があります。 もう一度ご確認ください。オーナー確認が自動的に行われないビジネス情報がある場合、 Google にお問い合わせください。 追加することもできます
事前確認チェックリスト
ビジネスのオーナー確認を行う前に、次のチェックリストを使用して問題がないか確認してください 表示される場合もあります
| エージェント情報 |
|---|
|
エージェントによる確認
必須。エージェントの情報が正確であることの確認 エージェントがそのブランドを代表できることを 証明します詳しくは、 <ph type="x-smartling-placeholder"></ph> エージェントとビジネス情報を確認する |
| 位置情報 |
|---|
|
場所 ID
必須。Google 検索におけるビジネスの一意の識別子 Google マップ上に表示されます。詳しくは、 <ph type="x-smartling-placeholder"></ph> ビジネス情報を管理するをご覧ください。 |
|
許可されるエントリ ポイント
必須。エージェントを作成したかどうかの確認にのみ必要です。 Business Communications API です。詳しくは、 <ph type="x-smartling-placeholder"></ph> ビジネス情報を管理するをご覧ください。 |
前提条件
エージェントを確認する前に、いくつかの情報を収集する必要があります。
地域
nameエージェントの名前がわからない場合は、エージェントの名前 ブランド。
開発マシン上の GCP プロジェクトのサービス アカウント キーのパス
ビジネスのオーナー確認
ビジネス情報のオーナー確認をリクエストすると、 ビジネスが、関連付けられているエージェントが代表するブランドと一致している。通知を受け取ります。 通知が届きます。
ビジネスのオーナー確認が完了した後は、そのビジネス情報を更新することはできません。更新方法 オーナー確認済みのビジネス情報への お問い合わせください(事前に署名 ビジネス メッセージの Google アカウントを使用する必要があります。アカウント登録の方法については、以下をご覧ください。 Business に登録 メッセージをご覧ください)。
ロケーションを確認するには、次のコマンドを実行します。変数を値に置き換える 前提条件で特定されていることを確認しておく必要があります。
cURL
# This code requests a verification of a location. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/requestVerification # Replace the __BRAND_ID__ and __LOCATION_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X POST \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__:requestVerification" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/**
* This code snippet requests a verification for a location.
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/requestVerification
*
* 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 LOCATION_ID = 'EDIT_HERE';
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 locationName = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID;
if (authClient) {
// Setup the parameters for the API call
const apiParams = {
auth: authClient,
name: locationName,
};
bcApi.brands.locations.requestVerification(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.Agent;
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 locationName = "brands/BRAND_ID/locations/LOCATION_ID/verification";
BusinessCommunications.Brands.Locations.RequestVerification request
= builder.build().brands().locations().requestVerification(locationName,
new RequestLocationVerificationRequest());
System.out.println(request.execute().toPrettyString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
このコードは
Java ビジネス
通信クライアント ライブラリ。Python
"""This code requests a verification of a location.
Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/requestVerification
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 (
BusinesscommunicationsBrandsLocationsRequestVerificationRequest,
RequestLocationVerificationRequest
)
# Edit the values below:
BRAND_ID = 'EDIT_HERE'
LOCATION_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)
locations_service = BusinesscommunicationsV1.BrandsLocationsService(client)
location_name = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID
verification_request = locations_service.RequestVerification(BusinesscommunicationsBrandsLocationsRequestVerificationRequest(
name=location_name,
requestLocationVerificationRequest=RequestLocationVerificationRequest()
))
print(verification_request)
書式設定と値のオプションについては、以下をご覧ください。
brands.locations.requestVerification。
ビジネスのオーナー確認のステータスを取得する
オーナー確認のリクエストを行った後、ビジネス情報の 確認できます。
ビジネスのオーナー確認のステータスを取得するには、次のコマンドを実行します。置換 変数で識別された値を持つ変数を 前提条件。
cURL
# This code gets the verification state of a location. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification # Replace the __BRAND_ID__ and __LOCATION_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X GET \ "https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__/verification" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
Node.js
/**
* This code snippet gets the verification state of a location.
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification?hl=en
*
* 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 LOCATION_ID = 'EDIT_HERE';
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 locationName = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID;
if (authClient) {
// Setup the parameters for the API call
const apiParams = {
auth: authClient,
name: locationName + '/verification',
};
bcApi.brands.locations.getVerification(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.Agent;
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 locationName = "brands/BRAND_ID/locations/LOCATION_ID/verification";
BusinessCommunications.Brands.Locations.GetVerification request
= builder.build().brands().locations().getVerification(locationName);
System.out.println(request.execute().toPrettyString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
このコードは
Java ビジネス
通信クライアント ライブラリ。Python
"""This code gets the verification state of a location.
Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification
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 (
BusinesscommunicationsBrandsLocationsGetVerificationRequest,
)
# Edit the values below:
BRAND_ID = 'EDIT_HERE'
LOCATION_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)
locations_service = BusinesscommunicationsV1.BrandsLocationsService(client)
location_name = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID + '/verification'
verification_state = locations_service.GetVerification(BusinesscommunicationsBrandsLocationsGetVerificationRequest(
name=location_name
))
print(verification_state)
書式設定と値のオプションについては、以下をご覧ください。
brands.locations.getVerification。
次のステップ
エージェントと関連付けられているビジネスのオーナー確認が済んだら、 起動 ユーザーとやり取りできるようになります