หลังจากสร้าง Business Messages แล้ว Agent สำหรับ ที่คุณจัดการและกรอกข้อมูลของตัวแทนให้เสร็จสิ้น คุณจะสามารถตรวจสอบ ตัวแทนและสถานที่ตั้งที่เกี่ยวข้อง คุณต้องยืนยันตัวแทนและสถานที่ตั้งก่อน พวกเขาสามารถ เปิด
การยืนยันตัวแทน
Business Messages จะยืนยันข้อมูลของตัวแทนเมื่อคุณยืนยันตัวแทน ด้วยรายชื่อติดต่อจากแบรนด์ที่ตัวแทนเป็นตัวแทน เมื่อรายชื่อติดต่อของแบรนด์ ยืนยันว่าคุณสามารถนำเสนอแบรนด์กับตัวแทน และตัวแทน ข้อมูลถูกต้อง ตัวแทนได้รับการยืนยันแล้ว
รายการตรวจสอบก่อนการยืนยัน
ก่อนยืนยันตัวแทน ให้ใช้รายการตรวจสอบต่อไปนี้เพื่อตรวจจับปัญหา ซึ่งอาจปรากฏขึ้นในระหว่างกระบวนการยืนยันตัวตน
| ข้อมูลของตัวแทน |
|---|
|
ชื่อตัวแทน
ต้องระบุ ชื่อตัวแทนตามที่ปรากฏต่อผู้ใช้ โปรดดู สร้างตัวแทน |
|
โลโก้ตัวแทน
ต้องระบุ โลโก้ของตัวแทนตามที่ปรากฏต่อผู้ใช้ โปรดดู สร้างตัวแทน |
|
ความพร้อมใช้งานของการรับส่งข้อความ
ต้องระบุ วันและเวลาที่ตัวแทนแบบเรียลไทม์พร้อมให้บริการ โต้ตอบกับผู้ใช้ โปรดดู ตั้งค่าความพร้อมใช้งานของการรับส่งข้อความ |
|
ข้อมูลที่ไม่ใช่ข้อมูลท้องถิ่น
ต้องระบุสำหรับ จุดแรกเข้านอกพื้นที่ โดเมนที่เชื่อมโยงกับตัวแทน หมายเลขโทรศัพท์ และภูมิภาคที่ให้บริการ โปรดดู ตั้งค่าข้อมูลที่ไม่ใช่ในท้องถิ่น |
|
ภาษาเริ่มต้น
ต้องระบุ สถานที่ที่ตัวแทนมักจะสื่อสาร โปรดดู การแปลและภาษา |
|
การกำหนดค่า OAuth
ไม่บังคับ รายละเอียดเกี่ยวกับการผสานรวม OAuth ของตัวแทนกับผลิตภัณฑ์อื่นๆ โปรดดู ตรวจสอบสิทธิ์ด้วย OAuth |
|
จุดแรกเข้าที่อนุญาต
ต้องระบุ จำเป็นเฉพาะในกรณีที่คุณได้สร้างตัวแทนกับธุรกิจหรือไม่ Communications API โปรดดู สร้างตัวแทน |
หลังจากยืนยันตัวแทนแล้ว คุณจะอัปเดตได้เฉพาะรายการต่อไปนี้เท่านั้น
conversationalSettingscustomAgentIddefaultLocaleprimaryAgentInteractionadditionalAgentInteractionsphone
หากต้องการอัปเดตช่องแบบอ่านอย่างเดียวหลังจากยืนยันตัวแทนแล้ว ติดต่อเรา (คุณต้องลงนามก่อน ใน ด้วยบัญชี Google ใน Business Messages หากต้องการลงทะเบียนบัญชี โปรดดู ลงทะเบียนกับธุรกิจ ข้อความ)
ข้อกำหนดเบื้องต้น
คุณต้องรวบรวมข้อมูลบางอย่างต่อไปนี้ก่อนจึงจะยืนยันตัวแทนได้
ตัวแทน
nameหากไม่ทราบชื่อตัวแทน โปรดดูที่แสดงตัวแทนทั้งหมดสำหรับ แบรนด์
เส้นทางไปยังคีย์บัญชีบริการของโปรเจ็กต์ GCP ในเครื่องพัฒนา
- ชื่อพาร์ทเนอร์ (ชื่อองค์กรของคุณ)
- อีเมลของพาร์ทเนอร์ (อีเมลของคุณ)
- เว็บไซต์ของแบรนด์ที่ตัวแทนเป็นตัวแทน เป็น URL ที่เผยแพร่ต่อสาธารณะ ขึ้นต้นด้วย "https://"
- ชื่อและอีเมลสำหรับติดต่อ (โดยทั่วไปจะใช้โดเมนร่วมกับเว็บไซต์ของแบรนด์) ของ แบรนด์ที่ตัวแทนเป็นตัวแทนที่สามารถยืนยันความสัมพันธ์ทางธุรกิจของคุณได้ กับแบรนด์และอำนาจของคุณในการนำเสนอแบรนด์
ยืนยันตัวแทน
Business Messages จะส่งอีเมลถึงแบรนด์เมื่อคุณขอการยืนยันสำหรับตัวแทน ผู้ติดต่อที่คุณระบุเพื่อยืนยันข้อมูลตัวแทนของคุณ
เมื่อผู้ติดต่อของแบรนด์ยืนยันข้อมูลตัวแทนและ Business Messages จากนั้น คุณจะได้รับอีเมล
หากต้องการยืนยันตัวแทน ให้เรียกใช้คำสั่งต่อไปนี้ แทนที่ตัวแปรด้วยค่า ที่ระบุไว้ในข้อกำหนดเบื้องต้น
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
ยกเลิกคำขอการยืนยันตัวแทน
หากคุณพบว่าข้อมูลตัวแทนไม่ถูกต้องหรือตัวแทนดังกล่าว ยังไม่พร้อมสำหรับการยืนยัน คุณยกเลิกคำขอการยืนยันที่รอดำเนินการได้ ถ้า เมื่อยกเลิกคำขอแล้ว Business Messages จะแจ้งเตือนผู้ติดต่อแบรนด์ของคุณ และจะ ต้องส่งคำขอการยืนยันใหม่เพื่อเริ่มต้นกระบวนการยืนยันอีกครั้ง
หากต้องการยกเลิกคำขอการยืนยันตัวแทน ให้เรียกใช้คำสั่งต่อไปนี้ แทนที่ ตัวแปรที่มีค่าที่ระบุใน สิ่งที่ต้องมีก่อน
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 ฐานข้อมูลสถานที่และใน Google Maps โปรดดู จัดการสถานที่ |
|
จุดแรกเข้าที่อนุญาต
ต้องระบุ จำเป็นเฉพาะในกรณีที่คุณได้สร้างตัวแทนด้วย Business Communications API โปรดดู จัดการสถานที่ |
ข้อกำหนดเบื้องต้น
คุณต้องรวบรวมข้อมูลบางอย่างต่อไปนี้ก่อนจึงจะยืนยันตัวแทนได้
สถานที่ตั้ง
nameหากคุณไม่ทราบชื่อตัวแทน โปรดดูที่แสดงสถานที่ตั้งทั้งหมดสำหรับ แบรนด์
เส้นทางไปยังคีย์บัญชีบริการของโปรเจ็กต์ GCP ในเครื่องพัฒนา
ยืนยันสถานที่
เมื่อคุณขอรับการยืนยันสำหรับสถานที่ Business Messages จะยืนยันว่า สถานที่ตั้งตรงกับแบรนด์ที่ตัวแทนที่เกี่ยวข้องเป็นตัวแทน คุณจะได้รับ เมื่อการยืนยันตำแหน่งเสร็จสมบูรณ์
หลังจากยืนยันสถานที่แล้ว คุณจะอัปเดตสถานที่ดังกล่าวไม่ได้ เพื่อทำการอัปเดต ไปยังสถานที่หลังจากได้รับการยืนยันแล้ว ติดต่อเรา (คุณต้องลงนามก่อน ใน ด้วยบัญชี Google ใน Business Messages หากต้องการลงทะเบียนบัญชี โปรดดู ลงทะเบียนกับธุรกิจ ข้อความ)
หากต้องการยืนยันตำแหน่ง ให้เรียกใช้คำสั่งต่อไปนี้ แทนที่ตัวแปรด้วยค่า ที่ระบุไว้ในข้อกำหนดเบื้องต้น
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
ขั้นตอนถัดไป
เมื่อตัวแทนของคุณและสถานที่ตั้งที่เกี่ยวข้องได้รับการยืนยัน คุณก็พร้อมที่จะ เปิดตัว เพื่อให้สามารถสื่อสารกับผู้ใช้ได้