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