Verifikasi agen atau lokasi

Setelah membuat agen Business Messages untuk merek yang Anda kelola dan menyelesaikan informasi agen, Anda dapat memverifikasi agen dan lokasi terkait. Anda harus memverifikasi agen dan lokasi sebelum dapat meluncurkan.

Verifikasi agen

Saat Anda memverifikasi agen, Business Messages mengonfirmasi informasi agen dengan kontak dari merek yang diwakili oleh agen. Setelah kontak merek mengonfirmasi bahwa Anda dapat mewakili merek dengan agen, dan informasi agen tersebut benar, agen akan 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 terlihat oleh pengguna. Lihat Membuat agen.

Logo agen

Wajib. Logo agen, seperti yang terlihat kepada pengguna. Lihat Membuat agen.

Ketersediaan fitur pesan

Wajib. Hari dan waktu yang disediakan oleh agen langsung untuk merespons pengguna. Lihat Menyetel ketersediaan fitur pesan.

Informasi non-lokal

Wajib untuk titik entri non-lokal. Domain, nomor telepon, dan wilayah peluncuran yang tersedia milik agen. Lihat Menetapkan informasi non-lokal.

Lokal default

Wajib. Lokalitas yang biasanya digunakan oleh agen untuk berkomunikasi. Lihat Pelokalan dan lokal.

Konfigurasi OAuth

Opsional. Detail tentang integrasi OAuth agen dengan produk lain. Baca bagian Mengautentikasi dengan OAuth.

Titik entri yang diizinkan

Wajib. Hanya diperlukan untuk memeriksa apakah Anda membuat agen dengan Business Communications API. Lihat Membuat 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 login terlebih dahulu dengan akun Google Business Messages. Untuk mendaftar guna mendapatkan akun, lihat Mendaftar dengan Business Messages.)

Prasyarat

Sebelum dapat memverifikasi agen, Anda perlu mengumpulkan beberapa informasi:

  • Agen name

    Jika tidak mengetahui nama agen, lihat Mencantumkan semua agen untuk merek.

  • Jalur ke kunci akun layanan project GCP Anda di mesin pengembangan

  • Nama partner (nama organisasi Anda)
  • Email partner (email Anda)
  • Situs brand yang diwakili oleh agen, sebagai URL yang tersedia untuk publik yang dimulai dengan "https://"
  • Nama kontak dan email (biasanya berbagi domain dengan situs merek) untuk merek yang diwakili oleh 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 ke kontak merek yang Anda tentukan untuk mengonfirmasi informasi agen Anda.

Saat kontak merek memverifikasi informasi agen Anda dan Business Messages memverifikasi agen Anda, Anda akan menerima email.

Untuk memverifikasi agen, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi di 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 library klien Java Business Communications.

Python


"""This code requests a verification of a Business Messages agent.

Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/verify?method=api#verify_an_agent

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsAgentsRequestVerificationRequest,
    RequestAgentVerificationRequest,
    AgentVerificationContact
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

agents_service = BusinesscommunicationsV1.BrandsAgentsService(client)

agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID

verification_request = agents_service.RequestVerification(BusinesscommunicationsBrandsAgentsRequestVerificationRequest(
        name=agent_name,
        requestAgentVerificationRequest=RequestAgentVerificationRequest(
            agentVerificationContact=AgentVerificationContact(
                partnerName='Partner name',
                partnerEmailAddress='partner@email.com',
                brandContactName='Brand contact name',
                brandContactEmailAddress='brand-contact@email.com',
                brandWebsiteUrl='https://www.your-company-website.com'
           ))
    ))

print(verification_request)

Untuk opsi pemformatan dan nilai, lihat brands.agents.requestVerification.

Mendapatkan status verifikasi agen

Setelah membuat permintaan verifikasi agen, Anda dapat memeriksa status verifikasi agen.

Untuk mendapatkan status verifikasi agen, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi di 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 library klien Java Business Communications.

Python


"""This code gets the agent verification state.

Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsAgentsGetVerificationRequest,
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

agents_service = BusinesscommunicationsV1.BrandsAgentsService(client)

agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/verification'

verification_state = agents_service.GetVerification(BusinesscommunicationsBrandsAgentsGetVerificationRequest(
        name=agent_name
    ))

print(verification_state)

Untuk opsi pemformatan dan nilai, lihat brands.agents.getVerification.

Membatalkan permintaan verifikasi agen

Jika ternyata informasi agen salah atau agen belum siap diverifikasi, Anda dapat membatalkan permintaan verifikasi yang tertunda. Jika Anda membatalkan permintaan, Business Messages akan memberi tahu kontak brand Anda, dan Anda perlu membuat permintaan verifikasi baru untuk memulai ulang proses verifikasi.

Untuk membatalkan permintaan verifikasi agen, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi di 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 library klien Java Business Communications.

Python


"""This code updates the verification state of an agent.

Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateVerification

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    AgentVerification,
    BusinesscommunicationsBrandsAgentsUpdateVerificationRequest,
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

agents_service = BusinesscommunicationsV1.BrandsAgentsService(client)

agent_name = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID + '/verification'

update_request = agents_service.UpdateVerification(
        BusinesscommunicationsBrandsAgentsUpdateVerificationRequest(
            name=agent_name,
            updateMask='verificationState',
            agentVerification=AgentVerification(verificationState=AgentVerification.VerificationStateValueValuesEnum.VERIFICATION_STATE_UNVERIFIED)
        )
    )

print(update_request)

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 tersebut.

Jika merek adalah bagian dari jaringan, Anda harus menambahkan semua lokasi untuk jaringan gerai tempat Anda memiliki izin untuk mengaktifkan fitur pesan. Untuk memverifikasi semua lokasi yang Anda tambahkan, minta verifikasi hanya untuk satu lokasi. Setelah memverifikasi lokasi tersebut, kami akan otomatis memverifikasi lokasi terkait lainnya yang telah Anda tambahkan.

Setelah verifikasi, jika Anda menambahkan lokasi tambahan, Anda perlu meminta verifikasi lokasi lagi. Jika lokasi apa pun tidak otomatis diverifikasi, hubungi kami dengan detail bisnis dan lokasi.

Checklist pra-verifikasi

Sebelum Anda memverifikasi lokasi, gunakan checklist berikut untuk menemukan masalah yang mungkin muncul selama proses verifikasi.

Informasi agen
Verifikasi agen

Wajib. Verifikasi bahwa informasi agen akurat dan agen dapat mewakili merek terkait. Lihat Memverifikasi agen dan lokasi.

Informasi lokasi
ID Tempat

Wajib. ID unik untuk lokasi di database Google Places dan Google Maps. Lihat Mengelola lokasi.

Titik entri yang diizinkan

Wajib. Hanya diperlukan untuk memeriksa apakah Anda membuat agen dengan Business Communications API. Lihat Mengelola lokasi.

Prasyarat

Sebelum dapat memverifikasi agen, Anda perlu mengumpulkan beberapa informasi:

Memverifikasi lokasi

Saat Anda meminta verifikasi untuk lokasi, Business Messages mengonfirmasi bahwa lokasi tersebut cocok dengan merek yang diwakili oleh agen terkait. Anda akan menerima email saat verifikasi lokasi selesai.

Setelah memverifikasi lokasi, Anda tidak dapat membuat pembaruan apa pun pada lokasi tersebut. Untuk memperbarui lokasi setelah diverifikasi, hubungi kami. (Anda harus login terlebih dahulu dengan akun Google Business Messages. Untuk mendaftar guna mendapatkan akun, lihat Mendaftar dengan Business Messages.)

Untuk memverifikasi lokasi, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi di 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 library klien Java Business Communications.

Python


"""This code requests a verification of a location.

Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/requestVerification

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsLocationsRequestVerificationRequest,
    RequestLocationVerificationRequest
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
LOCATION_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

locations_service = BusinesscommunicationsV1.BrandsLocationsService(client)

location_name = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID

verification_request = locations_service.RequestVerification(BusinesscommunicationsBrandsLocationsRequestVerificationRequest(
        name=location_name,
        requestLocationVerificationRequest=RequestLocationVerificationRequest()
    ))

print(verification_request)

Untuk opsi pemformatan dan nilai, lihat brands.locations.requestVerification.

Mendapatkan status verifikasi lokasi

Setelah membuat permintaan verifikasi lokasi, Anda dapat memeriksa status verifikasi lokasi.

Untuk mendapatkan status verifikasi lokasi, jalankan perintah berikut. Ganti variabel dengan nilai yang diidentifikasi di 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 library klien Java Business Communications.

Python


"""This code gets the verification state of a location.

Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification

This code is based on the https://github.com/google-business-communications/python-businessmessages
Python Business Messages client library.
"""

from oauth2client.service_account import ServiceAccountCredentials
from businesscommunications.businesscommunications_v1_client import BusinesscommunicationsV1
from businesscommunications.businesscommunications_v1_messages import (
    BusinesscommunicationsBrandsLocationsGetVerificationRequest,
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
LOCATION_ID = 'EDIT_HERE'
SCOPES = ['https://www.googleapis.com/auth/businesscommunications']
SERVICE_ACCOUNT_FILE = './service_account_key.json'

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)

client = BusinesscommunicationsV1(credentials=credentials)

locations_service = BusinesscommunicationsV1.BrandsLocationsService(client)

location_name = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID + '/verification'

verification_state = locations_service.GetVerification(BusinesscommunicationsBrandsLocationsGetVerificationRequest(
        name=location_name
    ))

print(verification_state)

Untuk opsi pemformatan dan nilai, lihat brands.locations.getVerification.

Langkah berikutnya

Setelah agen dan lokasi terkait diverifikasi, Anda siap meluncurkannya agar dapat berkomunikasi dengan pengguna.