Después de crear una cuenta de Business Messages para un que administras y finalizas la información del agente, puedes verificar y las ubicaciones asociadas. Debes verificar los agentes y las ubicaciones antes pueden lanzamiento.
Verificación del agente
Cuando verificas a un agente, Business Messages confirma su información con un contacto de la marca a la que representa el agente. Cuando el contacto de la marca confirma que puedes representar la marca con el agente y que este si la información es correcta, se verificó el agente.
Lista de tareas previas a la verificación
Antes de verificar al agente, usa la siguiente lista de tareas para detectar problemas que pueden aparecer durante el proceso de verificación.
Información del agente |
---|
Nombre del agente
Obligatorio. El nombre del agente, como lo ven los usuarios. Consulta Crea un agente. |
Logotipo del agente
Obligatorio. El logotipo del agente, como lo ven los usuarios. Consulta Crea un agente. |
Disponibilidad de mensajes
Obligatorio. Los días y horarios en que están disponibles los agentes humanos responder a los usuarios. Consulta Configura la disponibilidad de los mensajes. |
Información no local
Obligatorio para puntos de entrada no locales. Los dominios asociados con el agente, el número de teléfono números y regiones de lanzamiento disponibles. Consulta Establece información no local. |
Configuración regional predeterminada
Obligatorio. La configuración regional con la que se comunica el agente en general. Consulta Localización y configuración regional. |
Configuración de OAuth
Opcional. Detalles sobre la integración de OAuth del agente con otros productos. Consulta Autentica con OAuth. |
Puntos de entrada permitidos
Obligatorio. Solo es necesario verificar si creaste el agente con la cuenta de Business la API de Comunicaciones de Google. Consulta Crea un agente. |
Después de verificar tu agente, solo puedes actualizar los siguientes elementos:
conversationalSettings
customAgentId
defaultLocale
primaryAgentInteraction
additionalAgentInteractions
phone
Si necesitas actualizar los campos de solo lectura después de verificar tu agente, comunícate con nosotros. (Primero debes firmar con una Cuenta de Google de Business Messages. Si quieres registrarte para obtener una cuenta, consulta Registrarse en Business Mensajes).
Requisitos previos
Antes de verificar tu agente, debes recopilar cierta información:
Agente
name
Si no conoces el nombre de un agente, consulta Enumerar todos los agentes de un brand [marca].
Ruta de acceso a la clave de la cuenta de servicio del proyecto de GCP en la máquina de desarrollo
- Nombre del socio (el nombre de tu organización)
- Correo electrónico del socio (tu correo electrónico)
- Sitio web de la marca que representa el agente, como una URL disponible públicamente que comienza con "https://"
- Nombre y correo electrónico de contacto (suele compartir un dominio con el sitio web de la marca) de La marca a la que representa el agente y que puede verificar tu relación comercial con la marca y tu autoridad para representarla
Verifica un agente
Cuando solicitas la verificación para un agente, Business Messages envía un correo electrónico a la marca el contacto que especifiques para confirmar la información de tu agente.
Cuando el contacto de marca verifica la información de tu agente y Business Messages verificará tu agente, recibirás un correo electrónico.
Para verificar un agente, ejecuta el siguiente comando. Reemplaza variables por valores identificados en Requisitos previos.
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(); } } }Este código se basa en el Java Business Biblioteca cliente de comunicaciones.
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)
Para ver las opciones de formato y valor, consulta
brands.agents.requestVerification
Obtén el estado de verificación de un agente
Después de realizar una solicitud de verificación de agente, puedes consultar estado de verificación.
Para obtener el estado de verificación de un agente, ejecuta el siguiente comando. Reemplazar variables con valores identificados en Requisitos previos.
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(); } } }Este código se basa en el Java Business Biblioteca cliente de comunicaciones.
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)
Para ver las opciones de formato y valor, consulta
brands.agents.getVerification
Cancela una solicitud de verificación de agente
Si descubres que la información del agente es incorrecta o que el agente no está listo para la verificación, puedes cancelar las solicitudes de verificación pendientes. Si Si cancelas una solicitud, Business Messages notifica a tu contacto de la marca, y tú debes realizar una nueva solicitud de verificación para reiniciar el proceso.
Para cancelar una solicitud de verificación de agente, ejecuta el siguiente comando. Reemplazar variables con valores identificados en Requisitos previos.
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(); } } }Este código se basa en el Java Business Biblioteca cliente de comunicaciones.
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)
Para ver las opciones de formato y valor, consulta
brands.agents.updateVerification
Verificación de la ubicación
Una vez que verifiques un agente, podrás verificar las ubicaciones asociadas con él. Una vez que se verifique una ubicación y se lance el agente asociado, podrás realizar el lanzamiento la ubicación para usarla con el agente.
Si la marca es parte de una cadena, debes agregar todas las ubicaciones de esa cadena en las que tienes permiso para habilitar la mensajería. Para verificar todas las ubicaciones que agregaste, solicitar la verificación de una sola ubicación. Una vez que verifiquemos esa ubicación, verificará automáticamente las otras ubicaciones asociadas que hayas agregado.
Después de la verificación, si agregas ubicaciones adicionales, deberás solicitar volver a verificar la ubicación. Si alguna ubicación no se verifica automáticamente, por favor comunícate con nosotros con los detalles de la empresa y las ubicaciones.
Lista de tareas previas a la verificación
Antes de verificar tu ubicación, usa la siguiente lista de tareas para detectar problemas que pueden aparecer durante el proceso de verificación.
Información del agente |
---|
Verificación del agente
Obligatorio. Verificación de que la información del agente sea correcta y que el agente pueda representar a la marca asociada. Consulta Verifica los agentes y las ubicaciones. |
Información de ubicación |
---|
ID de lugar
Obligatorio. Es el identificador único de una ubicación en la en la base de datos de Places y en Google Maps. Consulta Administrar ubicaciones |
Puntos de entrada permitidos
Obligatorio. Solo es necesario verificar si creaste el agente con la API de Business Communications. Consulta Administrar ubicaciones |
Requisitos previos
Antes de verificar tu agente, debes recopilar cierta información:
Ubicación:
name
Si no conoces el nombre de un agente, consulta Enumerar todas las ubicaciones para un brand [marca].
Ruta de acceso a la clave de la cuenta de servicio del proyecto de GCP en la máquina de desarrollo
Verifica una ubicación
Cuando solicitas la verificación de una ubicación, Business Messages confirma lo siguiente: que la ubicación coincida con la marca que representa el agente asociado. Recibes un correo electrónico cuando se complete la verificación de la ubicación.
Una vez que verifiques una ubicación, no podrás actualizarla. Para realizar actualizaciones a una ubicación después de verificarla comunícate con nosotros. (Primero debes firmar con una Cuenta de Google de Business Messages. Si quieres registrarte para obtener una cuenta, consulta Registrarse en Business Mensajes).
Para verificar una ubicación, ejecuta el siguiente comando. Reemplaza variables por valores identificados en Requisitos previos.
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(); } } }Este código se basa en el Java Business Biblioteca cliente de comunicaciones.
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)
Para ver las opciones de formato y valor, consulta
brands.locations.requestVerification
Cómo obtener el estado de verificación de una ubicación
Después de realizar una solicitud de verificación de ubicación, puedes consultar el nombre de la ubicación estado de verificación.
Para obtener el estado de verificación de una ubicación, ejecuta el siguiente comando. Reemplazar variables con valores identificados en Requisitos previos.
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(); } } }Este código se basa en el Java Business Biblioteca cliente de comunicaciones.
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)
Para ver las opciones de formato y valor, consulta
brands.locations.getVerification
Próximos pasos
Una vez que se verifiquen tu agente y las ubicaciones asociadas, estarás listo para lanzarlos para que puedan comunicarse con los usuarios.