जगहों की जानकारी जोड़ें

अगर एजेंट जिस ब्रैंड का प्रतिनिधित्व करता है, अगर वह मौजूद है, तो आपके पास असोसिएट करने का विकल्प होता है एजेंट से जगहों की जानकारी शेयर करें, ताकि लोग खास जगहों पर मैसेज भेज सकें Business Messages. Business Messages, प्लेस आईडी से जगहों की पहचान करता है.

जगह के आईडी की मदद से, यह पता लगाया जा सकता है कि उपयोगकर्ता किस जगह की जानकारी को मैसेज भेज रहा है और उपयोगकर्ता को जवाब देने के लिए सबसे सही तरीका तय करते हैं.

आपको इसके ज़रिए कारोबार की जगहों के मालिकाना हक का दावा करना होगा Business Profile इससे पहले कि जगह की जानकारी को Business Messages के एजेंट के साथ जोड़ा जा सके.

एक से ज़्यादा स्थान प्रबंधित करना

अगर ब्रैंड किसी चेन का हिस्सा है, तो आपको उस चेन के लिए सभी जगहों को जोड़ना होगा, जहां आपके पास मैसेज सेवा चालू करने की अनुमति है. चेन की सभी जगहों की पुष्टि करने के लिए, आप एक एक पुष्टि करें किसी एक जगह का अनुरोध करें. उस स्थान की पुष्टि करने के बाद, हम जोड़े गए अन्य संबंधित स्थानों की पुष्टि करें.

पुष्टि के बाद, अगर आप और जगहें जोड़ते हैं, तो आपको अनुरोध करना होगा जगह की जानकारी की पुष्टि फिर से करें.

अपने एजेंट से जुड़ी जगहों की जानकारी देखने के लिए, ब्रैंड को चुनें और नतीजों को उनकी agent वैल्यू के हिसाब से फ़िल्टर करें.

कोई जगह बनाएं

किसी एजेंट में जगह की जानकारी जोड़ने के लिए, आपको कारोबार से संपर्क करना होगा कम्यूनिकेशन एपीआई बनाने और एजेंट का नाम जोड़कर उसे जगह के लिए name वैल्यू.

ज़रूरी शर्तें

इससे पहले कि आप कोई स्थान बनाएं, आपको कुछ आइटम इकट्ठा करने होंगे:

जगह बनाएं

जानकारी इकट्ठा करने के बाद, आपको जगह की जानकारी मिल जाएगी. में टर्मिनल के मुताबिक, नीचे दिया गया कमांड चलाएं.

हाइलाइट किए गए वैरिएबल को उन वैल्यू से बदलें जिनमें आपने पहचान की है ज़रूरी शर्तें. BRAND_ID को इसके हिस्से से बदलें ब्रैंड की name वैल्यू, जो "ब्रैंड/" के बाद होती है. उदाहरण के लिए, अगर name "brands/12345", ब्रैंड आईडी "12345" है.

cURL


# This code creates a location where a brand is available.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/create

# Replace the __BRAND_ID__ and __PLACE_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" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "placeId": "__PLACE_ID__",
  "agent": "brands/__BRAND_ID__/agents/__AGENT_ID__",
  "defaultLocale": "en",
}'

Node.js


/**
 * This code snippet creates a location.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/create
 *
 * 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 PLACE_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 brandName = 'brands/' + BRAND_ID;
  const agentName = 'brands/' + BRAND_ID + 'agents/' + AGENT_ID;

  if (authClient) {
    const locationObject = {
      placeId: PLACE_ID,
      agent: agentName,
      defaultLocale: 'en',
    };

    // setup the parameters for the API call
    const apiParams = {
      auth: authClient,
      parent: brandName,
      resource: locationObject,
    };

    bcApi.brands.locations.create(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Location created
        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.Location;
import com.google.common.collect.ImmutableMap;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.UUID;

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 brandName = "brands/BRAND_ID";

      BusinessCommunications.Brands.Locations.Create request = builder
          .build().brands().locations().create(brandName,
              new Location()
                  .setDefaultLocale("LOCALE")
                  .setAgent("FULL_AGENT_NAME")
                  .setPlaceId("PLACE_ID"));

      Location location = request.execute();

      System.out.println(location.toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
यह कोड इस पर आधारित है Java बिज़नेस बातचीत के लिए क्लाइंट लाइब्रेरी.

Python


"""This code creates a location where a brand is available.

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

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 (
    BusinesscommunicationsBrandsLocationsCreateRequest,
    Location
)

# Edit the values below:
BRAND_ID = 'EDIT_HERE'
AGENT_ID = 'EDIT_HERE'
PLACE_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)

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

location = locations_service.Create(BusinesscommunicationsBrandsLocationsCreateRequest(
        location=Location(
            agent=agent_name,
            placeId=PLACE_ID,
            defaultLocale='en'
        ),
        parent=brand_name
    ))

print(location)

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, यह देखें brands.locations.create.

जगह की जानकारी जोड़ने के बाद, Business Communications API, अन्य संबंधित जगहें होती हैं और एक ही ब्रैंड और एजेंट के लिए जगहें तय करती हैं.

स्टोर की जानकारी

जगह की जानकारी जोड़ने पर, Business Communications API, स्थान के मान, जिनमें name और testUrls शामिल हैं.

name को ऐसी जगह पर सेव करें जिसे आप ऐक्सेस कर सकें. जगह की जानकारी अपडेट करने के लिए, आपको name चाहिए.

किसी जगह की जांच करें

हर एजेंट के पास टेस्ट यूआरएल होते हैं. इनकी मदद से, यह देखा जा सकता है कि एजेंट से बातचीत कैसे की जा रही है लोगों को दिखाई देता है और आपको अपनी मैसेज सेवा की पुष्टि करने का मौका देता है किया जा सकता है.

TestUrl में url और surface विशेषता है. iOS डिवाइस पर, जगह के यूआरएल की जांच करने के लिए, सरफ़ेस वैल्यू के साथ टेस्ट यूआरएल का इस्तेमाल करें SURFACE_IOS_MAPS पेज चुने जा सकते हैं. यूआरएल को Google Maps ऐप्लिकेशन वाले iOS डिवाइस पर खोला जा रहा है इंस्टॉल किए गए ऐप्लिकेशन की मदद से, इससे जुड़े एजेंट के साथ पूरी तरह से काम करने वाली बातचीत खुलती है.

Android डिवाइसों में दो टेस्ट यूआरएल होते हैं. surface वैल्यू वाले यूआरएल SURFACE_ANDROID_MAPS Google Maps में खुली बातचीत और दिखाता है Google Maps में दिखने वाले आम बातचीत के एंट्री पॉइंट. surface वैल्यू के साथ SURFACE_ANDROID_WEB खुली बातचीत वाले यूआरएल ओवरले में बातचीत वाला व्यू और अन्य सभी एंट्री पॉइंट दिखाए गए हों.

बातचीत वाला प्लैटफ़ॉर्म खुलने के बाद, इस बातचीत में ब्रैंडिंग से जुड़ी वह सारी जानकारी शामिल है जिसे लोग देखेंगे, और जब आप एजेंट को कोई मैसेज भेजते हैं, तो आपके वेबहुक को मैसेज, उपयोगकर्ताओं से बातचीत करते समय, आपको पूरा JSON पेलोड भी शामिल करना होगा. जगह की जानकारी, context फ़ील्ड में दिखती है.

किसी जगह का टेस्ट यूआरएल खोलने के लिए, लिंक पर टैप करें या Business Messages के एजेंट लॉन्चर. कॉपी की जा रही है और टेस्ट यूआरएल पर चिपकाने या मैन्युअल तरीके से नेविगेट करने की सुविधा काम नहीं करती. इसकी वजह यह है कि सुरक्षा के उपायों के बारे में बताया है.

जगह की जानकारी पाएं

किसी जगह, जैसे कि locationTestUrl के बारे में जानकारी पाने के लिए, को ऐक्सेस कर सकते हैं, जब तक कि आपके पास स्थान का name मान.

किसी एक जगह की जानकारी पाना

जगह की जानकारी पाने के लिए, नीचे दिया गया निर्देश चलाएं. बदलें BRAND_ID और LOCATION_ID यूनीक वैल्यू के साथ जगहों की जानकारी name है.

cURL


# This code gets the location where a brand is available.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/get

# 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__" \
-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 location of a brand.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/get
 *
 * 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();

  if (authClient) {
    const apiParams = {
      auth: authClient,
      name: 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID,
    };

    bcApi.brands.locations.get(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        // Location 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.Location;
import com.google.common.collect.ImmutableMap;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.UUID;

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();

      BusinessCommunications.Brands.Locations.Get request = builder
          .build().brands().locations().get("brands/BRAND_ID/locations/LOCATION_ID");

      Location location = request.execute();

      System.out.println(location.toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
यह कोड इस पर आधारित है Java बिज़नेस बातचीत के लिए क्लाइंट लाइब्रेरी.

Python


"""This code gets the location where a brand is available.

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

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 (
    BusinesscommunicationsBrandsLocationsGetRequest,
    Location
)

# 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

location = locations_service.Get(
        BusinesscommunicationsBrandsLocationsGetRequest(name=location_name)
    )

print(location)

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, यह देखें brands.locations.get.

किसी ब्रैंड की सभी जगहों की सूची बनाना

अगर आपको जगहों के name के बारे में पता नहीं है, तो आपको सभी एजेंट की जानकारी मिल सकती है जीईटी में LOCATION_ID वैल्यू को हटाकर किसी ब्रैंड से जोड़ा जाता है अनुरोध URL है.

cURL


# This code gets all locations where a brand is available.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/list

# Replace the __BRAND_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/" \
-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 lists the locations of a brand.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/list
 *
 * 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 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();

  if (authClient) {
    const apiParams = {
      auth: authClient,
      parent: 'brands/' + BRAND_ID,
    };

    bcApi.brands.locations.list(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        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.Location;
import com.google.common.collect.ImmutableMap;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.UUID;

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();

      BusinessCommunications.Brands.Locations.List request
          = builder.build().brands().locations().list("brands/BRAND_ID");

      List locations = request.execute().getLocations();
      locations.stream().forEach(location -> {
        try {
          System.out.println(location.toPrettyString());
        } catch (IOException e) {
          e.printStackTrace();
        }
      });
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
यह कोड इस पर आधारित है Java बिज़नेस बातचीत के लिए क्लाइंट लाइब्रेरी.

Python


"""This code gets all locations where a brand is available.

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

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 (
    BusinesscommunicationsBrandsLocationsListRequest,
    Location
)

# Edit the values below:
BRAND_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'

locations = locations_service.List(
        BusinesscommunicationsBrandsLocationsListRequest(name=location_name)
    )

print(locations)

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, यह देखें brands.locations.list.

जगह की जानकारी अपडेट करें

जगह की जानकारी अपडेट करने के लिए, आपको कारोबार की मदद से पैच करने का अनुरोध करना है Communications API. एपीआई कॉल करते समय, आपको फ़ील्ड जिन्हें आप "updateMask" के मान के रूप में संपादित कर रहे हैं यूआरएल पैरामीटर.

उदाहरण के लिए, अगर defaultLocale और एजेंट फ़ील्ड अपडेट की जाती है, तो "updateMask" यूआरएल पैरामीटर "updateMask=defaultLocale,agent" है.

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, यह देखें brands.locations.patch.

अगर आप किसी स्थान के name को नहीं जानते हैं, तो किसी स्थान के लिए सभी स्थानों को सूचीबद्ध करें ब्रैंड के बारे में ज़्यादा जानें.

उदाहरण: डिफ़ॉल्ट स्थान-भाषा अपडेट करना

cURL


# This code updates the default locale of an agent.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/patch

# Replace the __BRAND_ID__ and __LOCATION_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__/locations/__LOCATION_ID__?updateMask=defaultLocale" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-communications" \
-H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \
-d '{
  "defaultLocale": "en"
}'

Node.js


/**
 * This code snippet updates the defaultLocale of a Business Messages agent.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/patch
 *
 * 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();

  if (authClient) {
    const locationObject = {
      defaultLocale: 'en'
    };

    const apiParams = {
      auth: authClient,
      name: 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID,
      resource: locationObject,
      updateMask: 'defaultLocale',
    };

    bcApi.brands.locations.patch(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        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.Location;
import com.google.common.collect.ImmutableMap;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.UUID;

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();

      BusinessCommunications.Brands.Locations.Patch request =
          builder.build().brands().locations().patch("brands/BRAND_ID/locations/LOCATION_ID",
            new Location()
                .setDefaultLocale("en"));

      request.setUpdateMask("defaultLocale");

      Location location = request.execute();

      System.out.println(location.toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
यह कोड इस पर आधारित है Java बिज़नेस बातचीत के लिए क्लाइंट लाइब्रेरी.

Python


"""This code updates the default locale of an agent.

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

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 (
    BusinesscommunicationsBrandsLocationsPatchRequest,
    Location
)

# 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 = Location(defaultLocale='US')

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

updated_location = locations_service.Patch(
        BusinesscommunicationsBrandsLocationsPatchRequest(
            location=location,
            name=location_name,
            updateMask='defaultLocale'
        )
    )

print(updated_location)

किसी जगह की जानकारी मिटाना

किसी एजेंट को मिटाने पर, Business Messages, जगह की जानकारी का पूरा डेटा मिटा देता है. बिज़नेस क्लास Messages उस जगह से जुड़े आपके एजेंट के मैसेज नहीं मिटाता जहां उपयोगकर्ता के डिवाइस में हो या सेव हो. लोगों को भेजे गए मैसेज जगह की जानकारी का डेटा.

अगर आपने स्थान को एक या ज़्यादा बार. उस स्थान को हटाने के लिए जिसे आपने सत्यापित किया है या पुष्टि करने की कोशिश की गई, अभी तक किसी भी व्यक्ति ने चेक इन नहीं किया है हमसे संपर्क करें. (आपको पहले हस्ताक्षर करना होगा में Business Messages के Google खाते से साइन इन करें. खाता रजिस्टर करने के लिए, देखें Business Profile में रजिस्टर करें मैसेज.)

किसी जगह को मिटाने के लिए, नीचे दिया गया कमांड चलाएं. BRAND_ID बदलें और LOCATION_ID में, जगह के name से मिली यूनीक वैल्यू शामिल हैं.

cURL


# This code deletes a location where a brand is available.
# Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/delete

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

curl -X DELETE \
"https://businesscommunications.googleapis.com/v1/brands/__BRAND_ID__/locations/__LOCATION_ID__" \
-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 deletes a location.
 * Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.locations/delete
 *
 * 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();

  if (authClient) {
    const apiParams = {
      auth: authClient,
      name: 'brands/' + BRAND_ID + '/locations/' + LOCATION_ID,
    };

    bcApi.brands.locations.delete(apiParams, {}, (err, response) => {
      if (err !== undefined && err !== null) {
        console.dir(err);
      } else {
        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.common.collect.ImmutableMap;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.UUID;

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();

      BusinessCommunications.Brands.Locations.Delete request = builder.build().brands().locations()
          .delete("brands/BRAND_ID/locations/LOCATION_ID");

      System.out.println(request.execute().toPrettyString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
यह कोड इस पर आधारित है Java बिज़नेस बातचीत के लिए क्लाइंट लाइब्रेरी.

Python


"""This code deletes a location where a brand is available.

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

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 (
    BusinesscommunicationsBrandsLocationsDeleteRequest,
    LocationEntryPointConfig,
    Location
)

# 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

location = locations_service.Delete(BusinesscommunicationsBrandsLocationsDeleteRequest(
        name=location_name
    ))

print(location)

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, यह देखें brands.locations.delete.

अगले चरण

अब आपको जगह की जानकारी देने वाला एजेंट मिला है. इसलिए, मैसेज डिज़ाइन किया जा सकता है फ़्लो के बारे में नहीं है.