Setelah membuat Business Messages agen untuk merek yang Anda kelola dan melengkapi informasi agen, Anda dapat memverifikasi dan semua lokasi terkait. Anda harus memverifikasi agen dan lokasi sebelum mereka bisa peluncuran.
Verifikasi agen
Saat Anda memverifikasi agen, Business Messages akan mengonfirmasi informasi agen dengan kontak dari merek yang diwakili oleh agen. Setelah brand menghubungi mengonfirmasi bahwa Anda dapat mewakili brand dengan agen dan bahwa agen informasi tersebut benar, agen telah diverifikasi.
Checklist pra-verifikasi
Sebelum memverifikasi agen, gunakan checklist berikut untuk menemukan masalah yang mungkin muncul selama proses verifikasi.
Informasi agen |
---|
Nama agen
Wajib. Nama agen, seperti yang ditampilkan kepada pengguna. Lihat Buat agen. |
Logo agen
Wajib. Logo agen, seperti yang ditampilkan kepada pengguna. Lihat Buat agen. |
Ketersediaan fitur pesan
Wajib. Hari dan waktu agen langsung tersedia menanggapi pengguna. Lihat Menyetel ketersediaan fitur pesan. |
Informasi non-lokal
Wajib untuk titik entri non-lokal. Domain terkait agen, nomor telepon nomor telepon, dan wilayah peluncuran yang tersedia. Lihat Menyetel informasi non-lokal. |
Lokalitas default
Wajib. Lokal yang biasanya berkomunikasi dengan agen. Lihat Pelokalan dan lokalitas. |
Konfigurasi OAuth
Opsional. Detail tentang integrasi OAuth agen dengan produk lain. Lihat Autentikasi dengan OAuth. |
Titik entri yang diizinkan
Wajib. Hanya perlu memeriksa apakah Anda membuat agen dengan Bisnis API Komunikasi. Lihat Buat agen. |
Setelah memverifikasi agen, Anda hanya dapat memperbarui item berikut:
conversationalSettings
customAgentId
defaultLocale
primaryAgentInteraction
additionalAgentInteractions
phone
Jika Anda perlu memperbarui kolom hanya baca setelah memverifikasi agen, hubungi kami. (Anda harus terlebih dahulu menandatangani dengan Akun Google Business Messages. Untuk mendaftarkan akun, lihat Daftar ke Business Message.)
Prasyarat
Sebelum dapat memverifikasi agen, Anda perlu mengumpulkan beberapa informasi:
Agen
name
Jika Anda tidak mengetahui nama agen, lihat Mencantumkan semua agen untuk brand Anda.
Jalur ke kunci akun layanan project GCP Anda di mesin pengembangan
- Nama partner (nama organisasi Anda)
- Email partner (email Anda)
- Situs brand yang diwakili agen, sebagai URL yang tersedia secara publik diawali dengan "https://"
- Nama kontak dan email (biasanya berbagi domain dengan situs brand) untuk merek yang diwakili agen yang dapat memverifikasi hubungan bisnis Anda dengan merek dan otoritas Anda untuk mewakili merek
Verifikasi agen
Saat Anda meminta verifikasi untuk agen, Business Messages akan mengirimkan email kepada brand kontak yang Anda tentukan untuk mengonfirmasi informasi agen.
Saat kontak brand memverifikasi informasi agen dan Business Messages Anda memverifikasi agen, Anda akan menerima email.
Untuk memverifikasi agen, jalankan perintah berikut. Mengganti variabel dengan nilai yang diidentifikasi dalam Prasyarat.
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(); } } }Kode ini didasarkan pada Bisnis Java Library klien komunikasi.
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)
Untuk opsi pemformatan dan nilai, lihat
brands.agents.requestVerification
Mendapatkan status verifikasi agen
Setelah membuat permintaan verifikasi agen, Anda dapat memeriksa status verifikasi.
Untuk mendapatkan status verifikasi agen, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi dalam Prasyarat.
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(); } } }Kode ini didasarkan pada Bisnis Java Library klien komunikasi.
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)
Untuk opsi pemformatan dan nilai, lihat
brands.agents.getVerification
Membatalkan permintaan verifikasi agen
Jika Anda menemukan bahwa informasi agen salah atau agen dinyatakan tidak belum siap diverifikasi, Anda dapat membatalkan permintaan verifikasi yang tertunda. Jika Anda membatalkan permintaan, Business Messages akan memberi tahu kontak brand, dan Anda harus membuat permintaan verifikasi baru untuk memulai ulang proses verifikasi.
Untuk membatalkan permintaan verifikasi agen, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi dalam Prasyarat.
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(); } } }Kode ini didasarkan pada Bisnis Java Library klien komunikasi.
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)
Untuk opsi pemformatan dan nilai, lihat
brands.agents.updateVerification
Verifikasi lokasi
Setelah memverifikasi agen, Anda dapat memverifikasi lokasi yang terkait dengan agen tersebut. Setelah lokasi diverifikasi dan agen terkait diluncurkan, Anda dapat meluncurkan lokasi untuk digunakan dengan agen.
Jika brand merupakan bagian dari jaringan bisnis, Anda harus menambahkan semua lokasi untuk jaringan bisnis tersebut Anda memiliki izin untuk mengaktifkan pesan. Untuk memverifikasi semua lokasi yang Anda tambahkan, meminta verifikasi hanya untuk satu lokasi. Setelah memverifikasi lokasi tersebut, kami akan memverifikasi secara otomatis lokasi terkait lainnya yang telah Anda tambahkan.
Setelah verifikasi, jika Anda menambahkan lokasi lain, Anda harus meminta verifikasi lokasi lagi. Jika ada lokasi yang tidak diverifikasi secara otomatis, memohon hubungi kami dengan detail bisnis dan lokasi.
Checklist pra-verifikasi
Sebelum memverifikasi lokasi Anda, gunakan checklist berikut untuk menemukan masalah yang mungkin muncul selama proses verifikasi.
Informasi agen |
---|
Verifikasi agen
Wajib. Verifikasi bahwa informasi agen sudah akurat dan agen dapat mewakili brand terkait. Lihat Verifikasi agen dan lokasi. |
Informasi lokasi |
---|
ID Tempat
Wajib. ID unik untuk lokasi di Google Database Tempat dan di Google Maps. Lihat Kelola lokasi. |
Titik entri yang diizinkan
Wajib. Hanya perlu untuk memeriksa apakah Anda membuat agen dengan Business Communications API. Lihat Kelola lokasi. |
Prasyarat
Sebelum dapat memverifikasi agen, Anda perlu mengumpulkan beberapa informasi:
Lokasi
name
Jika tidak tahu nama agen, lihat Mencantumkan semua lokasi untuk brand Anda.
Jalur ke kunci akun layanan project GCP Anda di mesin pengembangan
Verifikasi lokasi
Saat Anda meminta verifikasi lokasi, Business Messages akan mengonfirmasi bahwa lokasi cocok dengan brand yang diwakili agen terkait. Anda menerima email ketika verifikasi lokasi selesai.
Setelah memverifikasi lokasi, Anda tidak dapat memperbarui lokasi tersebut. Untuk melakukan pembaruan ke suatu lokasi setelah diverifikasi, hubungi kami. (Anda harus terlebih dahulu menandatangani dengan Akun Google Business Messages. Untuk mendaftarkan akun, lihat Daftar ke Business Message.)
Untuk memverifikasi lokasi, jalankan perintah berikut. Mengganti variabel dengan nilai yang diidentifikasi dalam Prasyarat.
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(); } } }Kode ini didasarkan pada Bisnis Java Library klien komunikasi.
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)
Untuk opsi pemformatan dan nilai, lihat
brands.locations.requestVerification
Mendapatkan status verifikasi lokasi
Setelah membuat permintaan verifikasi lokasi, Anda dapat memeriksa status verifikasi.
Untuk mendapatkan status verifikasi lokasi, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi dalam Prasyarat.
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(); } } }Kode ini didasarkan pada Bisnis Java Library klien komunikasi.
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)
Untuk opsi pemformatan dan nilai, lihat
brands.locations.getVerification
Langkah berikutnya
Setelah agen dan lokasi terkait diverifikasi, Anda siap untuk luncurkan mereka sehingga mereka dapat berkomunikasi dengan pengguna.