브랜드 관리

모든 상담사가 브랜드 (비즈니스, 조직, 그룹)에 속해 있습니다. 에이전트를 만들려면 먼저 소유 브랜드를 만들어야 합니다. 브랜드는 순전히 관련 에이전트를 그룹화하는 데 도움이 되는 구조입니다.

이 페이지의 코드 스니펫은 자바 샘플Node.js 샘플에서 가져온 것입니다.

브랜드 만들기

브랜드에는 displayName 및 고유 식별자 name가 있습니다.

Node.js

const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

const privateKey =
  require('../../resources/businesscommunications-service-account-credentials.json');

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper.createBrand('My new brand').then((response) => {
	console.log('The new brand is:');
	console.log(response.data);
}).catch((err) => {
	console.log(err);
});

Java.js

String displayName = flags.getOrDefault("brand_name", "Test brand: " + now.getSecond());
Brand brand = api.createBrand(displayName);
logger.info("New brand id: " + brand.getName());

이 코드는 새 브랜드 정보와 브랜드에 할당된 고유 식별자를 반환합니다.

{
  name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
  displayName: 'My new brand'
}

브랜드 검색

브랜드는 고유 식별자 (name)를 사용하여 가져올 수 있습니다.

Node.js

const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

const privateKey =
  require('../../resources/businesscommunications-service-account-credentials.json');

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper.getBrand(brandId).then((response) => {
  console.log('Brand details are:');
  console.log(response.data);
}).catch((err) => {
  console.log(err);
});

Java

Brand brand = api.getBrand(brandId);
logger.info("Brand: " + brand);

이 코드는 브랜드 정보를 반환합니다.

{
  name: 'brands/17456b6b-65dc-4e35-b128-fd3047664ddf',
  displayName: 'My new brand'
}

브랜드 표시

지금까지 만든 모든 브랜드 목록을 가져올 수 있습니다.

Node.js

const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

const privateKey =
  require('../../resources/businesscommunications-service-account-credentials.json');

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper.listBrands().then((response) => {
  console.log('Current brands available are:');
  console.log(response.data);
}).catch((err) => {
  console.log(err);
});

Java

List<Brand> brands = api.listBrands().stream().sorted(Comparator.comparing(Brand::getName))
  .collect(Collectors.toList());
logger.info(String.format("Found %d brands", brands.size()));
for (Brand brand : brands) {
  logger.info(String.format("Brand [%s]: '%s'", brand.getName(), brand.getDisplayName()));
}

이 코드는 모든 브랜드 목록을 반환합니다.

{
  brands: [
    {
      name: 'brands/1deb6297-8a57-474a-a02c-48529a3de0a0',
      displayName: 'My brand'
    },
    {
      name: 'brands/3b607982-8c06-467a-96b8-020ddc26ac83',
      displayName: 'My second brand'
    },
    {
      name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',
      displayName: 'My thrd brand'
    }
  ]
}

브랜드 이름 바꾸기

브랜드의 표시 이름은 patch 연산자를 사용하여 변경할 수 있습니다.

Node.js

const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

const privateKey =
  require('../../resources/businesscommunications-service-account-credentials.json');

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper
  .patchBrand(brand.name, 'My brand new name').then((response) => {
    console.log(response.data);
});

이 코드는 업데이트된 브랜드 정보를 반환합니다.

{
  name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017',
  displayName: 'My brands new name'
}