অবস্থান যোগ করুন

একজন এজেন্ট যে ব্র্যান্ডের প্রতিনিধিত্ব করে তার যদি প্রকৃত অবস্থান থাকে, তাহলে আপনি এজেন্টের সাথে অবস্থানগুলিকে সংযুক্ত করতে পারেন যাতে ব্যবহারকারীরা ব্যবসায়িক বার্তাগুলির মাধ্যমে নির্দিষ্ট অবস্থানগুলিকে বার্তা দিতে পারে৷ ব্যবসার বার্তা স্থান আইডি দ্বারা অবস্থান সনাক্ত করে৷

প্লেস আইডিগুলির সাহায্যে, আপনি সনাক্ত করতে পারেন কোন ভৌত অবস্থানে একজন ব্যবহারকারী বার্তা পাঠান এবং ব্যবহারকারীকে প্রতিক্রিয়া জানানোর জন্য সর্বোত্তম পদক্ষেপ নির্ধারণ করতে পারেন৷

আপনি ব্যবসার বার্তা এজেন্টের সাথে অবস্থানগুলিকে সংযুক্ত করার আগে আপনাকে ব্যবসার প্রোফাইলের মাধ্যমে প্রকৃত অবস্থানের মালিকানা দাবি করতে হবে।

একাধিক অবস্থান পরিচালনা

যদি ব্র্যান্ডটি একটি চেইনের অংশ হয়, তাহলে আপনাকে অবশ্যই সেই চেইনের জন্য সমস্ত অবস্থান যোগ করতে হবে যেখানে আপনার কাছে মেসেজিং সক্ষম করার অনুমতি আছে৷ চেইনের সমস্ত অবস্থান যাচাই করতে, আপনি একটি অবস্থানের জন্য একটি একক যাচাইকরণের অনুরোধ করবেন ৷ একবার আমরা সেই অবস্থানটি যাচাই করলে, আমরা স্বয়ংক্রিয়ভাবে আপনার যুক্ত করা অন্যান্য সংশ্লিষ্ট অবস্থানগুলি যাচাই করব।

যাচাইকরণের পর, আপনি যদি অতিরিক্ত অবস্থান যোগ করেন, তাহলে আপনাকে আবার লোকেশন যাচাইয়ের অনুরোধ করতে হবে।

আপনার এজেন্টের সাথে যুক্ত অবস্থানগুলি দেখতে, একটি ব্র্যান্ডের জন্য সমস্ত অবস্থানের তালিকা দেখুন এবং তাদের agent মান অনুসারে ফলাফলগুলি ফিল্টার করুন৷

একটি অবস্থান তৈরি করুন

একটি এজেন্টে একটি অবস্থান যোগ করতে, আপনি ব্র্যান্ডের অবস্থান তৈরি করার জন্য বিজনেস কমিউনিকেশন API- এর সাথে একটি অনুরোধ করুন এবং অবস্থানে এজেন্টের name মান যোগ করে এজেন্টকে সংযুক্ত করুন।

পূর্বশর্ত

আপনি একটি অবস্থান তৈরি করার আগে, আপনাকে কয়েকটি আইটেম সংগ্রহ করতে হবে:

  • আপনার ডেভেলপমেন্ট মেশিনে আপনার GCP প্রকল্পের পরিষেবা অ্যাকাউন্ট কী-এর পথ
  • ব্র্যান্ডের name , যেমনটি বিজনেস কমিউনিকেশন এপিআই-তে প্রদর্শিত হয় (উদাহরণস্বরূপ, "ব্র্যান্ড/12345")

    আপনি যদি ব্র্যান্ডের name না জানেন, তাহলে brands.list দেখুন।

  • এজেন্টের name , যেমনটি বিজনেস কমিউনিকেশন এপিআই-তে প্রদর্শিত হয় (উদাহরণস্বরূপ, "brands/12345/agents/67890")

    আপনি যদি এজেন্টের name না জানেন তবে একটি ব্র্যান্ডের জন্য সমস্ত এজেন্টদের তালিকা দেখুন৷

  • অবস্থানের স্থান আইডি

    প্লেস আইডি ফাইন্ডারের সাহায্যে একটি অবস্থানের প্লেস আইডি শনাক্ত করুন। যদি অবস্থানটি একটি একক ঠিকানার পরিবর্তে একটি পরিষেবা -এরিয়া ব্যবসা হয়, তবে পরিবর্তে পরিষেবা-এরিয়া বিজনেস প্লেস আইডি ফাইন্ডার ব্যবহার করুন৷

  • লোকেলে যে লোকেশনটি সাধারণত কাজ করে, একটি দুই-অক্ষরের ISO 639-1 ভাষা কোড দ্বারা নির্দিষ্ট করা হয়

অবস্থান তৈরি করুন

একবার আপনি আপনার তথ্য সংগ্রহ করলে, এটি অবস্থান তৈরি করার সময়। একটি টার্মিনালে, নিম্নলিখিত কমান্ডটি চালান।

হাইলাইট করা ভেরিয়েবলগুলিকে আপনার পূর্বশর্তগুলিতে চিহ্নিত মানগুলির সাথে প্রতিস্থাপন করুন। ব্র্যান্ডের name মানের অংশ দিয়ে BRAND_ID প্রতিস্থাপন করুন যা "brands/" অনুসরণ করে। উদাহরণস্বরূপ, যদি 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();

জাভা

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();
    }
  }
}
এই কোডটি জাভা বিজনেস কমিউনিকেশনস ক্লায়েন্ট লাইব্রেরির উপর ভিত্তি করে।

পাইথন


"""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 দেখুন।

আপনি অবস্থান তৈরি করার পরে, ব্যবসায়িক যোগাযোগ API অন্যান্য সংশ্লিষ্ট অবস্থানগুলি সনাক্ত করে এবং একই ব্র্যান্ড এবং এজেন্টের জন্য অবস্থান তৈরি করে৷

দোকান তথ্য

আপনি যখন একটি অবস্থান তৈরি করেন, তখন ব্যবসায়িক যোগাযোগ API name এবং testUrls সহ অবস্থানের মানগুলি প্রদান করে।

আপনি অ্যাক্সেস করতে পারেন এমন জায়গায় স্টোরের name । অবস্থান আপডেট করতে আপনার name প্রয়োজন।

একটি অবস্থান পরীক্ষা করুন

প্রতিটি এজেন্টের পরীক্ষার URL রয়েছে যা আপনাকে দেখতে দেয় যে সেই এজেন্টের সাথে কথোপকথন ব্যবহারকারীদের কাছে কীভাবে উপস্থিত হয় এবং আপনাকে আপনার মেসেজিং পরিকাঠামো যাচাই করার সুযোগ দেয়।

একটি TestUrl এর url এবং surface অ্যাট্রিবিউট আছে। একটি iOS ডিভাইসের সাথে একটি অবস্থান URL পরীক্ষা করতে, SURFACE_IOS_MAPS এর পৃষ্ঠের মান সহ পরীক্ষার URL ব্যবহার করুন। Google Maps অ্যাপ ইনস্টল করা iOS ডিভাইসে URL খুললে সংশ্লিষ্ট এজেন্টের সাথে একটি সম্পূর্ণ কার্যকরী কথোপকথন খুলে যায়।

অ্যান্ড্রয়েড ডিভাইস দুটি পরীক্ষা URL আছে. SURFACE_ANDROID_MAPS এর surface ভ্যালু সহ ইউআরএলগুলি Google ম্যাপে কথোপকথন খুলে দেয় এবং কথোপকথনমূলক এন্ট্রি পয়েন্টগুলিকে উপস্থাপন করে যা Google মানচিত্রে প্রদর্শিত হয়। SURFACE_ANDROID_WEB এর surface ভ্যালু সহ ইউআরএলগুলি একটি ওভারলে কথোপকথনমূলক দৃশ্যে কথোপকথন খোলে এবং অন্যান্য সমস্ত এন্ট্রি পয়েন্টগুলিকে উপস্থাপন করে।

একবার কথোপকথন সারফেস খোলে, কথোপকথনে সমস্ত ব্র্যান্ডিং তথ্য অন্তর্ভুক্ত থাকে যা ব্যবহারকারীরা দেখতে পাবেন এবং আপনি যখন এজেন্টকে একটি বার্তা পাঠান, তখন আপনার ওয়েবহুক বার্তাটি গ্রহণ করে , যার মধ্যে সম্পূর্ণ JSON পেলোড আপনি ব্যবহারকারীদের সাথে যোগাযোগ করার সময় আশা করতে পারেন৷ অবস্থানের তথ্য context ক্ষেত্রে উপস্থিত হয়।

একটি অবস্থানের পরীক্ষার URL খুলতে, একটি লিঙ্কে আলতো চাপুন বা ব্যবসা বার্তা এজেন্ট লঞ্চার ব্যবহার করুন৷ কপি এবং পেস্ট করা বা অন্যথায় ম্যানুয়ালি একটি পরীক্ষার URL-এ নেভিগেট করা ব্রাউজার নিরাপত্তা ব্যবস্থার কারণে কাজ করে না।

অবস্থানের তথ্য পান

অবস্থান সম্পর্কে তথ্য পেতে, যেমন locationTestUrl , আপনি ব্যবসায়িক যোগাযোগ API থেকে তথ্য পেতে পারেন, যতক্ষণ না আপনার কাছে অবস্থানের name মান থাকে।

একটি একক অবস্থানের জন্য তথ্য পান

অবস্থানের তথ্য পেতে, নিম্নলিখিত কমান্ডটি চালান। অবস্থানের name অনন্য মান দিয়ে BRAND_ID এবং LOCATION_ID প্রতিস্থাপন করুন।

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

জাভা

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();
    }
  }
}
এই কোডটি জাভা বিজনেস কমিউনিকেশনস ক্লায়েন্ট লাইব্রেরির উপর ভিত্তি করে।

পাইথন


"""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 না জানেন, তাহলে আপনি একটি GET অনুরোধ URL থেকে LOCATION_ID মান বাদ দিয়ে একটি ব্র্যান্ডের সাথে যুক্ত সমস্ত এজেন্টের তথ্য পেতে পারেন৷

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

জাভা

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();
    }
  }
}
এই কোডটি জাভা বিজনেস কমিউনিকেশনস ক্লায়েন্ট লাইব্রেরির উপর ভিত্তি করে।

পাইথন


"""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 দেখুন।

একটি অবস্থান আপডেট করুন

একটি অবস্থান আপডেট করতে, আপনি বিজনেস কমিউনিকেশন এপিআই-এর সাথে একটি প্যাচ অনুরোধ করেন৷ আপনি যখন API কল করেন, তখন আপনি "updateMask" URL প্যারামিটারের মান হিসাবে সম্পাদনা করছেন এমন ক্ষেত্রগুলির নাম অন্তর্ভুক্ত করেন।

উদাহরণস্বরূপ, আপনি যদি ডিফল্টলোকেল এবং এজেন্ট ক্ষেত্রগুলি আপডেট করেন তবে "আপডেটমাস্ক" URL প্যারামিটারটি "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();

জাভা

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();
    }
  }
}
এই কোডটি জাভা বিজনেস কমিউনিকেশনস ক্লায়েন্ট লাইব্রেরির উপর ভিত্তি করে।

পাইথন


"""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 Google অ্যাকাউন্ট দিয়ে সাইন ইন করতে হবে। একটি অ্যাকাউন্টের জন্য নিবন্ধন করতে, Business Messages এর সাথে নিবন্ধন করুন দেখুন।)

একটি অবস্থান মুছে ফেলার জন্য, নিম্নলিখিত কমান্ডটি চালান। অবস্থানের name অনন্য মান দিয়ে BRAND_ID এবং LOCATION_ID প্রতিস্থাপন করুন।

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

জাভা

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();
    }
  }
}
এই কোডটি জাভা বিজনেস কমিউনিকেশনস ক্লায়েন্ট লাইব্রেরির উপর ভিত্তি করে।

পাইথন


"""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 দেখুন।

পরবর্তী পদক্ষেপ

এখন যেহেতু আপনার কাছে অবস্থান সহ একজন এজেন্ট আছে, আপনি আপনার মেসেজিং ফ্লো ডিজাইন করতে পারেন৷