Após criar um Business Messages agente para um marca que você gerencia e finalizar as informações do agente, poderá verificar e os locais associados. Verifique agentes e locais antes eles podem iniciar.
Verificação do agente
Quando você verifica um agente, o recurso Business Messages confirma as informações dele com um contato da marca que o agente representa. Depois que o contato da marca confirma que você pode representar a marca com o agente e que ele as informações estejam corretas, o agente foi verificado.
Lista de verificação pré-verificação
Antes de verificar seu agente, use a lista de verificação a seguir para detectar problemas. que podem aparecer durante o processo de verificação.
Informações do agente |
---|
Nome do agente
Obrigatório. O nome do agente, como aparece para os usuários. Consulte Criar um agente. |
Logotipo do agente
Obrigatório. O logotipo do agente, como aparece para os usuários. Consulte Criar um agente. |
Disponibilidade de mensagens
Obrigatório. Os dias e horários em que os atendentes estão disponíveis responder aos usuários. Consulte Definir a disponibilidade de mensagens |
Informações não locais
Obrigatório para pontos de entrada não locais. Os domínios associados, o telefone e regiões de lançamento disponíveis. Consulte Definir informações não locais |
Localidade padrão
Obrigatório. A localidade em que o agente geralmente se comunica. Consulte Localização e localidades. |
Configuração do OAuth
Opcional. Detalhes sobre a integração OAuth do agente com outros produtos. Consulte Autentique com o OAuth. |
Pontos de entrada permitidos
Obrigatório. Só é necessário verificar se você criou o agente com o API Communications. Consulte Criar um agente. |
Após a verificação do agente, você só poderá atualizar os seguintes itens:
conversationalSettings
customAgentId
defaultLocale
primaryAgentInteraction
additionalAgentInteractions
phone
Se for necessário atualizar os campos somente leitura após a verificação do agente, entre em contato com nossa equipe. (É necessário primeiro assinar login com uma Conta do Google no Business Messages. Para registrar uma conta, consulte Cadastre-se no Perfil da Empresa Mensagens.
Pré-requisitos
Antes de verificar seu agente, você precisa reunir algumas informações:
Agente
name
Se você não souber o nome de um agente, consulte Listar todos os agentes de um marca.
Caminho para a chave da conta de serviço do projeto do GCP na máquina de desenvolvimento
- Nome do parceiro (nome da sua organização)
- E-mail do parceiro (seu e-mail)
- Site da marca que o agente representa, como um URL disponível publicamente começando com "https://"
- Nome e e-mail do contato (geralmente compartilha um domínio com o site da marca) para a marca que o agente representa e que pode verificar sua relação comercial com a marca e sua autoridade para representá-la
Verificar um agente
Quando você solicita a verificação de um agente, o recurso Business Messages envia um e-mail para a marca contato especificado para confirmar as informações do seu agente.
Quando o contato da marca verifica as informações do seu agente e o Business Messages confirmar seu agente, você receberá um e-mail.
Para verificar um agente, execute o comando a seguir. Substituir variáveis por valores identificados em Pré-requisitos.
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(); } } }Esse código é baseado no Java Business Biblioteca de cliente do 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)
Para opções de formatação e valor, consulte
brands.agents.requestVerification
Acessar o estado de verificação de um agente
Depois de fazer uma solicitação de verificação, consulte a conta do o estado de verificação.
Para saber o estado de verificação de um agente, execute o comando a seguir. Substituir variáveis com valores identificados em Pré-requisitos.
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(); } } }Esse código é baseado no Java Business Biblioteca de cliente do 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)
Para opções de formatação e valor, consulte
brands.agents.getVerification
Cancelar uma solicitação de verificação de agente
Se você descobrir que as informações do agente estão incorretas ou que, de outra forma, o agente não estiver pronto para verificação, cancele as solicitações de verificação pendentes. Se você cancelar um pedido, o recurso Business Messages vai notificar o contato da sua marca e você precisará fazer uma nova solicitação de verificação para reiniciar o processo.
Para cancelar uma solicitação de verificação de agente, execute o comando a seguir. Substituir variáveis com valores identificados em Pré-requisitos.
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(); } } }Esse código é baseado no Java Business Biblioteca de cliente do 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)
Para opções de formatação e valor, consulte
brands.agents.updateVerification
Verificação de local
Após verificar um agente, você poderá verificar os locais associados a ele. Depois que um local for verificado e o agente associado for lançado, você poderá iniciar o local para uso com o agente.
Se a marca faz parte de uma rede, você precisa adicionar todos os locais dela em que você tem permissão para ativar as mensagens. Para verificar todos os locais adicionados, solicitar a verificação de apenas um local. Depois de verificar o local, verificará automaticamente os outros locais associados que você adicionou.
Após a verificação, se você adicionar outros locais, precisará solicitar a verificação do local novamente. Se algum local não for verificado automaticamente, por favor entre em contato conosco com os detalhes e locais da empresa.
Lista de verificação pré-verificação
Antes de verificar sua localização, use a lista de verificação a seguir para detectar problemas. que podem aparecer durante o processo de verificação.
Informações do agente |
---|
Verificação de agente
Obrigatório. Verificação de que as informações do agente são precisas e que o agente pode representar a marca associada. Consulte Verifique agentes e locais. |
Informações do local |
---|
ID de lugar
Obrigatório. O identificador exclusivo de um local no Google no banco de dados do Places e no Google Maps. Consulte Gerenciar locais |
Pontos de entrada permitidos
Obrigatório. Só é necessário verificar se você criou o agente com a API Business Communications. Consulte Gerenciar locais |
Pré-requisitos
Antes de verificar seu agente, você precisa reunir algumas informações:
Local:
name
Se você não souber o nome de um agente, consulte Listar todos os locais de um marca.
Caminho para a chave da conta de serviço do projeto do GCP na máquina de desenvolvimento
Verificar um local
Quando você solicita a verificação de um local, o recurso Business Messages confirma que: o local corresponde à marca que o agente associado representa. Você recebe um quando a verificação de local for concluída.
Depois de verificar um local, não é possível atualizá-lo. Para fazer atualizações para um local após a verificação, entre em contato com nossa equipe. (É necessário primeiro assinar login com uma Conta do Google no Business Messages. Para registrar uma conta, consulte Cadastre-se no Perfil da Empresa Mensagens.
Para verificar um local, execute o comando a seguir. Substituir variáveis por valores identificados em Pré-requisitos.
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(); } } }Esse código é baseado no Java Business Biblioteca de cliente do 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)
Para opções de formatação e valor, consulte
brands.locations.requestVerification
Conferir o estado de verificação de um local
Depois de fazer a solicitação, você poderá consultar o endereço o estado de verificação.
Para conferir o estado de verificação de um local, execute o comando a seguir. Substituir variáveis com valores identificados em Pré-requisitos.
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(); } } }Esse código é baseado no Java Business Biblioteca de cliente do 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)
Para opções de formatação e valor, consulte
brands.locations.getVerification
Próximas etapas
Depois que seu agente e os locais associados forem verificados, você vai poder iniciar eles para que possam se comunicar com os usuários.