Xác minh một nhân viên hỗ trợ hoặc địa điểm

Sau khi tạo một tác nhân Business Messages cho một thương hiệu mà bạn quản lý và hoàn tất thông tin của tác nhân đó, bạn có thể xác minh tác nhân đó và mọi vị trí được liên kết. Bạn phải xác minh nhân viên hỗ trợ và vị trí trước khi họ có thể ra mắt.

Xác minh nhân viên hỗ trợ

Khi bạn xác minh một nhân viên hỗ trợ, Business Messages sẽ xác nhận thông tin của nhân viên hỗ trợ với thông tin liên hệ từ thương hiệu mà nhân viên hỗ trợ đó đại diện. Sau khi người liên hệ của thương hiệu xác nhận rằng bạn có thể đại diện cho thương hiệu với nhân viên hỗ trợ và thông tin nhân viên hỗ trợ là chính xác, thì nhân viên hỗ trợ sẽ được xác minh.

Danh sách kiểm tra trước khi xác minh

Trước khi bạn xác minh nhân viên hỗ trợ của mình, hãy sử dụng danh sách kiểm tra sau đây để phát hiện mọi vấn đề có thể xuất hiện trong quá trình xác minh.

Thông tin của nhân viên hỗ trợ
Tên nhân viên hỗ trợ

Bắt buộc. Tên của nhân viên hỗ trợ như tên hiển thị cho người dùng. Hãy xem phần Tạo nhân viên hỗ trợ.

Biểu tượng của nhân viên hỗ trợ

Bắt buộc. Biểu tượng của nhân viên hỗ trợ, khi hiển thị cho người dùng. Hãy xem phần Tạo nhân viên hỗ trợ.

Khả năng nhắn tin

Bắt buộc. Ngày và giờ mà nhân viên hỗ trợ trực tiếp sẵn sàng để phản hồi người dùng. Xem Đặt khả năng sử dụng tính năng nhắn tin.

Thông tin không phải địa phương

Bắt buộc đối với điểm truy cập không phải tại địa phương. Miền, số điện thoại liên kết của nhân viên hỗ trợ và các khu vực ra mắt hiện có. Hãy xem Đặt thông tin không phải địa phương.

Ngôn ngữ mặc định

Bắt buộc. Ngôn ngữ mà nhân viên hỗ trợ thường giao tiếp. Hãy xem phần Bản địa hoá và bản địa hoá.

Cấu hình OAuth

Không bắt buộc. Thông tin chi tiết về việc tích hợp OAuth của tác nhân với các sản phẩm khác. Xem phần Xác thực bằng OAuth.

Điểm truy cập được phép

Bắt buộc. Chỉ cần thiết để kiểm tra xem bạn đã tạo nhân viên hỗ trợ này bằng API Business Messages hay chưa. Hãy xem phần Tạo nhân viên hỗ trợ.

Sau khi xác minh nhân viên hỗ trợ, bạn chỉ có thể cập nhật các mục sau:

  • conversationalSettings
  • customAgentId
  • defaultLocale
  • primaryAgentInteraction
  • additionalAgentInteractions
  • phone

Nếu bạn cần cập nhật các trường chỉ đọc sau khi xác minh tác nhân, hãy liên hệ với chúng tôi. (Trước tiên, bạn phải đăng nhập bằng Tài khoản Google Business Messages. Để đăng ký tài khoản, hãy xem phần Đăng ký bằng Business Messages.)

Điều kiện tiên quyết

Trước khi có thể xác minh nhân viên hỗ trợ của mình, bạn cần thu thập một số thông tin:

  • Nhân viên hỗ trợ name

    Nếu bạn không biết tên nhân viên hỗ trợ, hãy xem phần Liệt kê tất cả nhân viên hỗ trợ cho một thương hiệu.

  • Đường dẫn đến khóa tài khoản dịch vụ của dự án GCP trên máy phát triển của bạn

  • Tên đối tác (tên của tổ chức bạn)
  • Email đối tác (email của bạn)
  • Trang web của thương hiệu mà tác nhân đại diện, dưới dạng URL có sẵn công khai bắt đầu bằng "https://"
  • Tên và email liên hệ (thường chia sẻ miền với trang web của thương hiệu) cho thương hiệu mà đại lý đại diện, người có thể xác minh mối quan hệ kinh doanh của bạn với thương hiệu và thẩm quyền đại diện cho thương hiệu

Xác minh nhân viên hỗ trợ

Khi bạn yêu cầu xác minh cho một nhân viên hỗ trợ, Business Messages sẽ gửi email cho người liên hệ của thương hiệu mà bạn chỉ định để xác nhận thông tin của nhân viên hỗ trợ.

Khi người liên hệ của thương hiệu xác minh nhân viên hỗ trợ của bạn và Business Messages xác minh nhân viên hỗ trợ của bạn, bạn sẽ nhận được một email.

Để xác minh một nhân viên hỗ trợ, hãy chạy lệnh sau. Thay thế các biến bằng các giá trị được xác định trong Điều kiện tiên quyết.

URL


# This code requests a verification of a Business Messages agent.
# Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/verify?method=api#verify_an_agent

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__:requestVerification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "agentVerificationContact": {
    "partnerName": "Partner name",
    "partnerEmailAddress": "partner@email.com",
    "brandContactName": "Brand contact name",
    "brandContactEmailAddress": "brand-contact@email.com",
    "brandWebsiteUrl": "https://www.your-company-website.com"
  }
}'

Node.js


/**
 * This code snippet requests an agent verification.
 * Read more: https://developers.google.com/business-communications/business-messages/guides/how-to/verify?method=api#verify_an_agent
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
const BRAND_ID = 'EDIT_HERE';
const AGENT_ID = 'EDIT_HERE';
const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

const businesscommunications = require('businesscommunications');
const {google} = require('googleapis');

// Initialize the Business Communications API
const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

// Set the scope that we need for the Business Communications API
const scopes = [
  'https://www.googleapis.com/auth/businesscommunications',
];

// Set the private key to the service account file
const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

async function main() {
  const authClient = await initCredentials();

  const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID;

  if (authClient) {
    const agentVerificationContact = {
      agentVerificationContact: {
        partnerName: 'Partner name',
        partnerEmailAddress: 'partner@email.com',
        brandContactName: 'Brand contact name',
        brandContactEmailAddress: 'brand-contact@email.com',
        brandWebsiteUrl: 'https://www.your-company-website.com',
      },
    };

    // Setup the parameters for the API call
    const apiParams = {
      auth: authClient,
      name: agentName,
      resource: agentVerificationContact,
    };

    bcApi.brands.agents.requestVerification(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Agent found
        console.log(response.data);
      }
    });
  }
  else {
    console.log('Authentication failure.');
  }
}

/**
 * Initializes the Google credentials for calling the
 * Business Messages API.
 */
 async function initCredentials() {
  // Configure a JWT auth client
  const authClient = new google.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    scopes,
  );

  return new Promise(function(resolve, reject) {
    // Authenticate request
    authClient.authorize(function(err, tokens) {
      if (err) {
        reject(false);
      } else {
        resolve(authClient);
      }
    });
  });
}

main();

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.businesscommunications.v1.BusinessCommunications;
import com.google.api.services.businesscommunications.v1.model.Agent;
import java.io.FileInputStream;
import java.util.Arrays;

class Main {
  /**
   * Initializes credentials used by the Business Communications API.
   */
  private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() {
    BusinessCommunications.Builder builder = null;
    try {
      GoogleCredential credential = GoogleCredential
            .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY"));

      credential = credential.createScoped(Arrays.asList(
          "https://www.googleapis.com/auth/businesscommunications"));

      credential.refreshToken();

      HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

      // Create instance of the Business Communications API
      builder = new BusinessCommunications
          .Builder(httpTransport, jsonFactory, null)
          .setApplicationName(credential.getServiceAccountProjectId());

      // Set the API credentials and endpoint
      builder.setHttpRequestInitializer(credential);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return builder;
  }

  public static void main(String args[]) {
    try {
      // Create client library reference
      BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder();

      String agentName = "brands/BRAND_ID/agents/AGENT_ID";

      BusinessCommunications.Brands.Agents.RequestVerification request
          = builder.build().brands().agents().requestVerification(agentName,
          new RequestAgentVerificationRequest().setAgentVerificationContact(
              new AgentVerificationContact()
                  .setPartnerName("PARTNER_NAME")
                  .setPartnerEmailAddress("PARTNER_EMAIL")
                  .setBrandContactName("BRAND_CONTACT_NAME")
                  .setBrandContactEmailAddress("BRAND_CONTACT_EMAIL")
                  .setBrandWebsiteUrl("BRAND_WEBSITE_URL")));

      System.out.println(request.execute().toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Mã này dựa trên thư viện ứng dụng Truyền thông doanh nghiệp của Java.

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)

Để biết các tùy chọn định dạng và giá trị, hãy xem brands.agents.requestVerification.

Nhận trạng thái xác minh của nhân viên hỗ trợ

Sau khi gửi yêu cầu xác minh nhân viên hỗ trợ, bạn có thể kiểm tra trạng thái xác minh của nhân viên hỗ trợ.

Để nhận trạng thái xác minh của nhân viên hỗ trợ, hãy chạy lệnh sau. Thay thế biến bằng các giá trị được xác định trong Điều kiện tiên quyết.

URL


# This code gets the agent verification state.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X GET \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/verification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)"

Node.js


/**
 * This code snippet gets an agent verification state.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
const BRAND_ID = 'EDIT_HERE';
const AGENT_ID = 'EDIT_HERE';
const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

const businesscommunications = require('businesscommunications');
const {google} = require('googleapis');

// Initialize the Business Communications API
const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

// Set the scope that we need for the Business Communications API
const scopes = [
  'https://www.googleapis.com/auth/businesscommunications',
];

// Set the private key to the service account file
const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

async function main() {
  const authClient = await initCredentials();

  const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID;

  if (authClient) {
    // Setup the parameters for the API call
    const apiParams = {
      auth: authClient,
      name: agentName + '/verification',
    };

    bcApi.brands.agents.getVerification(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Agent found
        console.log(response.data);
      }
    });
  }
  else {
    console.log('Authentication failure.');
  }
}

/**
 * Initializes the Google credentials for calling the
 * Business Messages API.
 */
 async function initCredentials() {
  // Configure a JWT auth client
  const authClient = new google.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    scopes,
  );

  return new Promise(function(resolve, reject) {
    // Authenticate request
    authClient.authorize(function(err, tokens) {
      if (err) {
        reject(false);
      } else {
        resolve(authClient);
      }
    });
  });
}

main();

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.businesscommunications.v1.BusinessCommunications;
import com.google.api.services.businesscommunications.v1.model.Agent;
import java.io.FileInputStream;
import java.util.Arrays;

class Main {
  /**
   * Initializes credentials used by the Business Communications API.
   */
  private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() {
    BusinessCommunications.Builder builder = null;
    try {
      GoogleCredential credential = GoogleCredential
            .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY"));

      credential = credential.createScoped(Arrays.asList(
          "https://www.googleapis.com/auth/businesscommunications"));

      credential.refreshToken();

      HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

      // Create instance of the Business Communications API
      builder = new BusinessCommunications
          .Builder(httpTransport, jsonFactory, null)
          .setApplicationName(credential.getServiceAccountProjectId());

      // Set the API credentials and endpoint
      builder.setHttpRequestInitializer(credential);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return builder;
  }

  public static void main(String args[]) {
    try {
      // Create client library reference
      BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder();

      String agentName = "brands/BRAND_ID/agents/AGENT_ID/verification";

      BusinessCommunications.Brands.Agents.GetVerification request
          = builder.build().brands().agents().getVerification(agentName);

      System.out.println(request.execute().toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Mã này dựa trên thư viện ứng dụng Truyền thông doanh nghiệp của Java.

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)

Để biết các tùy chọn định dạng và giá trị, hãy xem brands.agents.getVerification.

Huỷ yêu cầu xác minh nhân viên hỗ trợ

Nếu phát hiện thông tin nhân viên hỗ trợ không chính xác hoặc nhân viên hỗ trợ chưa sẵn sàng xác minh, thì bạn có thể hủy các yêu cầu xác minh đang chờ xử lý. Nếu bạn huỷ một yêu cầu, Business Messages sẽ thông báo cho người liên hệ về thương hiệu của bạn và bạn cần thực hiện một yêu cầu xác minh mới để bắt đầu lại quy trình xác minh.

Để huỷ một yêu cầu xác minh nhân viên hỗ trợ, hãy chạy lệnh sau. Thay thế biến bằng các giá trị được xác định trong Điều kiện tiên quyết.

URL


# This code updates the verification state of an agent.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateVerification

# Replace the __BRAND_ID__ and __AGENT_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/agents/__AGENT_ID__/verification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "verificationState": "VERIFICATION_STATE_UNVERIFIED"
}'

Node.js


/**
 * This code snippet updates the state of an agent verification.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/updateVerification
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
const BRAND_ID = 'EDIT_HERE';
const AGENT_ID = 'EDIT_HERE';
const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

const businesscommunications = require('businesscommunications');
const {google} = require('googleapis');

// Initialize the Business Communications API
const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

// Set the scope that we need for the Business Communications API
const scopes = [
  'https://www.googleapis.com/auth/businesscommunications',
];

// Set the private key to the service account file
const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

async function main() {
  const authClient = await initCredentials();

  const agentName = 'brands/' + BRAND_ID + '/agents/' + AGENT_ID;

  if (authClient) {
    // Setup the parameters for the API call
    const apiParams = {
      auth: authClient,
      name: agentName + '/verification',
      updateMask: 'verificationState',
      resource: {
        name: agentName,
        verificationState: 'VERIFICATION_STATE_UNVERIFIED',
      }
    };

    bcApi.brands.agents.updateVerification(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Agent found
        console.log(response.data);
      }
    });
  }
  else {
    console.log('Authentication failure.');
  }
}

/**
 * Initializes the Google credentials for calling the
 * Business Messages API.
 */
 async function initCredentials() {
  // Configure a JWT auth client
  const authClient = new google.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    scopes,
  );

  return new Promise(function(resolve, reject) {
    // Authenticate request
    authClient.authorize(function(err, tokens) {
      if (err) {
        reject(false);
      } else {
        resolve(authClient);
      }
    });
  });
}

main();

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.businesscommunications.v1.BusinessCommunications;
import com.google.api.services.businesscommunications.v1.model.Agent;
import java.io.FileInputStream;
import java.util.Arrays;

class Main {
  /**
   * Initializes credentials used by the Business Communications API.
   */
  private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() {
    BusinessCommunications.Builder builder = null;
    try {
      GoogleCredential credential = GoogleCredential
            .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY"));

      credential = credential.createScoped(Arrays.asList(
          "https://www.googleapis.com/auth/businesscommunications"));

      credential.refreshToken();

      HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

      // Create instance of the Business Communications API
      builder = new BusinessCommunications
          .Builder(httpTransport, jsonFactory, null)
          .setApplicationName(credential.getServiceAccountProjectId());

      // Set the API credentials and endpoint
      builder.setHttpRequestInitializer(credential);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return builder;
  }

  public static void main(String args[]) {
    try {
      // Create client library reference
      BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder();

      String agentName = "brands/BRAND_ID/agents/AGENT_ID/verification";

      BusinessCommunications.Brands.Agents.UpdateVerification request
          = builder.build().brands().agents().updateVerification(agentName,
              new AgentVerification().setVerificationState("VERIFICATION_STATE_UNVERIFIED"));

      System.out.println(request.execute().toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Mã này dựa trên thư viện ứng dụng Truyền thông doanh nghiệp của Java.

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)

Để biết các tùy chọn định dạng và giá trị, hãy xem brands.agents.updateVerification.

Xác minh địa điểm

Sau khi xác minh một nhân viên hỗ trợ, bạn có thể xác minh những vị trí liên kết với nhân viên hỗ trợ đó. Sau khi một vị trí được xác minh và tác nhân liên kết được khởi chạy, bạn có thể khởi chạy vị trí để sử dụng với tác nhân đó.

Nếu thương hiệu là một phần của chuỗi, thì bạn phải thêm tất cả các vị trí cho chuỗi đó để có thể bật tính năng nhắn tin. Để xác minh tất cả vị trí bạn đã thêm, hãy yêu cầu xác minh chỉ cho một vị trí. Sau khi xác minh vị trí đó, chúng tôi sẽ tự động xác minh những vị trí liên kết khác mà bạn đã thêm.

Sau khi xác minh, nếu bạn thêm vị trí bổ sung, bạn sẽ cần yêu cầu xác minh lại vị trí. Nếu bất kỳ vị trí nào không được tự động xác minh, vui lòng liên hệ với chúng tôi kèm theo thông tin chi tiết về doanh nghiệp và vị trí đó.

Danh sách kiểm tra trước khi xác minh

Trước khi xác minh vị trí của mình, bạn hãy sử dụng danh sách kiểm tra sau đây để phát hiện mọi vấn đề có thể xuất hiện trong quá trình xác minh.

Thông tin của nhân viên hỗ trợ
Xác minh nhân viên hỗ trợ

Bắt buộc. Xác minh rằng thông tin của nhân viên hỗ trợ là chính xác và nhân viên hỗ trợ có thể đại diện cho thương hiệu được liên kết. Hãy xem phần Xác minh nhân viên hỗ trợ và vị trí.

Thông tin vị trí
Mã địa điểm

Bắt buộc. Giá trị nhận dạng duy nhất cho một vị trí trong cơ sở dữ liệu Google Địa điểm và trên Google Maps. Xem Quản lý vị trí.

Điểm truy cập được phép

Bắt buộc. Chỉ cần thiết để kiểm tra xem bạn đã tạo nhân viên hỗ trợ này bằng API Business Messages hay chưa. Xem Quản lý vị trí.

Điều kiện tiên quyết

Trước khi có thể xác minh nhân viên hỗ trợ của mình, bạn cần thu thập một số thông tin:

Xác minh vị trí

Khi bạn yêu cầu xác minh cho một vị trí, Business Messages xác nhận rằng vị trí đó khớp với thương hiệu mà nhân viên hỗ trợ liên quan đại diện. Bạn sẽ nhận được email khi quá trình xác minh vị trí hoàn tất.

Sau khi xác minh một vị trí, bạn sẽ không thể cập nhật vị trí đó. Để cập nhật vị trí sau khi vị trí đó được xác minh, hãy hãy liên hệ với chúng tôi. (Trước tiên, bạn phải đăng nhập bằng Tài khoản Google Business Messages. Để đăng ký tài khoản, hãy xem phần Đăng ký bằng Business Messages.)

Để xác minh một vị trí, hãy chạy lệnh sau. Thay thế các biến bằng các giá trị được xác định trong Điều kiện tiên quyết.

URL


# This code requests a verification of a location.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/requestVerification

# Replace the __BRAND_ID__ and __LOCATION_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__:requestVerification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)"

Node.js


/**
 * This code snippet requests a verification for a location.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/requestVerification
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
const BRAND_ID = 'EDIT_HERE';
const LOCATION_ID = 'EDIT_HERE';
const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

const businesscommunications = require('businesscommunications');
const {google} = require('googleapis');

// Initialize the Business Communications API
const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

// Set the scope that we need for the Business Communications API
const scopes = [
  'https://www.googleapis.com/auth/businesscommunications',
];

// Set the private key to the service account file
const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

async function main() {
  const authClient = await initCredentials();

  const locationName = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID;

  if (authClient) {
    // Setup the parameters for the API call
    const apiParams = {
      auth: authClient,
      name: locationName,
    };

    bcApi.brands.locations.requestVerification(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Agent found
        console.log(response.data);
      }
    });
  }
  else {
    console.log('Authentication failure.');
  }
}

/**
 * Initializes the Google credentials for calling the
 * Business Messages API.
 */
 async function initCredentials() {
  // Configure a JWT auth client
  const authClient = new google.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    scopes,
  );

  return new Promise(function(resolve, reject) {
    // Authenticate request
    authClient.authorize(function(err, tokens) {
      if (err) {
        reject(false);
      } else {
        resolve(authClient);
      }
    });
  });
}

main();

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.businesscommunications.v1.BusinessCommunications;
import com.google.api.services.businesscommunications.v1.model.Agent;
import java.io.FileInputStream;
import java.util.Arrays;

class Main {
  /**
   * Initializes credentials used by the Business Communications API.
   */
  private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() {
    BusinessCommunications.Builder builder = null;
    try {
      GoogleCredential credential = GoogleCredential
            .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY"));

      credential = credential.createScoped(Arrays.asList(
          "https://www.googleapis.com/auth/businesscommunications"));

      credential.refreshToken();

      HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

      // Create instance of the Business Communications API
      builder = new BusinessCommunications
          .Builder(httpTransport, jsonFactory, null)
          .setApplicationName(credential.getServiceAccountProjectId());

      // Set the API credentials and endpoint
      builder.setHttpRequestInitializer(credential);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return builder;
  }

  public static void main(String args[]) {
    try {
      // Create client library reference
      BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder();

      String locationName = "brands/BRAND_ID/locations/LOCATION_ID/verification";

      BusinessCommunications.Brands.Locations.RequestVerification request
          = builder.build().brands().locations().requestVerification(locationName,
                new RequestLocationVerificationRequest());

      System.out.println(request.execute().toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Mã này dựa trên thư viện ứng dụng Truyền thông doanh nghiệp của Java.

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)

Để biết các tùy chọn định dạng và giá trị, hãy xem brands.locations.requestVerification.

Nhận trạng thái xác minh của vị trí

Sau khi gửi yêu cầu xác minh vị trí, bạn có thể kiểm tra trạng thái xác minh của vị trí đó.

Để nhận trạng thái xác minh của một vị trí, hãy chạy lệnh sau. Thay thế biến bằng các giá trị được xác định trong Điều kiện tiên quyết.

URL


# This code gets the verification state of a location.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification

# Replace the __BRAND_ID__ and __LOCATION_ID__
# Make sure a service account key file exists at ./service_account_key.json

curl -X GET \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__/verification" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)"

Node.js


/**
 * This code snippet gets the verification state of a location.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/getVerification?hl=en
 *
 * This code is based on the https://github.com/google-business-communications/nodejs-businesscommunications Node.js
 * Business Communications client library.
 */

/**
 * Edit the values below:
 */
const BRAND_ID = 'EDIT_HERE';
const LOCATION_ID = 'EDIT_HERE';
const PATH_TO_SERVICE_ACCOUNT_KEY = './service_account_key.json';

const businesscommunications = require('businesscommunications');
const {google} = require('googleapis');

// Initialize the Business Communications API
const bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});

// Set the scope that we need for the Business Communications API
const scopes = [
  'https://www.googleapis.com/auth/businesscommunications',
];

// Set the private key to the service account file
const privatekey = require(PATH_TO_SERVICE_ACCOUNT_KEY);

async function main() {
  const authClient = await initCredentials();

  const locationName = 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID;

  if (authClient) {
    // Setup the parameters for the API call
    const apiParams = {
      auth: authClient,
      name: locationName + '/verification',
    };

    bcApi.brands.locations.getVerification(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Agent found
        console.log(response.data);
      }
    });
  }
  else {
    console.log('Authentication failure.');
  }
}

/**
 * Initializes the Google credentials for calling the
 * Business Messages API.
 */
 async function initCredentials() {
  // Configure a JWT auth client
  const authClient = new google.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    scopes,
  );

  return new Promise(function(resolve, reject) {
    // Authenticate request
    authClient.authorize(function(err, tokens) {
      if (err) {
        reject(false);
      } else {
        resolve(authClient);
      }
    });
  });
}

main();

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.businesscommunications.v1.BusinessCommunications;
import com.google.api.services.businesscommunications.v1.model.Agent;
import java.io.FileInputStream;
import java.util.Arrays;

class Main {
  /**
   * Initializes credentials used by the Business Communications API.
   */
  private static BusinessCommunications.Builder getBusinessCommunicationsBuilder() {
    BusinessCommunications.Builder builder = null;
    try {
      GoogleCredential credential = GoogleCredential
            .fromStream(new FileInputStream("PATH_TO_SERVICE_ACCOUNT_KEY"));

      credential = credential.createScoped(Arrays.asList(
          "https://www.googleapis.com/auth/businesscommunications"));

      credential.refreshToken();

      HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();

      // Create instance of the Business Communications API
      builder = new BusinessCommunications
          .Builder(httpTransport, jsonFactory, null)
          .setApplicationName(credential.getServiceAccountProjectId());

      // Set the API credentials and endpoint
      builder.setHttpRequestInitializer(credential);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return builder;
  }

  public static void main(String args[]) {
    try {
      // Create client library reference
      BusinessCommunications.Builder builder = getBusinessCommunicationsBuilder();

      String locationName = "brands/BRAND_ID/locations/LOCATION_ID/verification";

      BusinessCommunications.Brands.Locations.GetVerification request
          = builder.build().brands().locations().getVerification(locationName);

      System.out.println(request.execute().toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Mã này dựa trên thư viện ứng dụng Truyền thông doanh nghiệp của Java.

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)

Để biết các tùy chọn định dạng và giá trị, hãy xem brands.locations.getVerification.

Các bước tiếp theo

Sau khi nhân viên hỗ trợ của bạn và mọi vị trí được liên kết đã được xác minh, bạn có thể ra mắt để nhân viên hỗ trợ có thể giao tiếp với người dùng.