Quản lý nhân viên hỗ trợ

Tất cả nhân viên hỗ trợ đều thuộc về một thương hiệu (doanh nghiệp, tổ chức hoặc nhóm). Trước khi tạo nhân viên hỗ trợ, bạn cần phải tạo một thương hiệu sở hữu. Thương hiệu chỉ mang tính tổ chức để giúp bạn nhóm các nhân viên hỗ trợ có liên quan lại với nhau

Đoạn mã trên trang này được lấy từ các mẫu Java và các mẫu Node.js.

Tạo và xác định nhân viên hỗ trợ

Tạo một nhân viên hỗ trợ

Để tạo nhân viên hỗ trợ RBM, bạn cần xác định thông tin cơ bản của nhân viên hỗ trợ đó.

Để biết thêm thông tin, hãy xem brands.agents.create.

cURL

curl -v -X POST "https://businesscommunications.googleapis.com/v1/$BRAND_ID/agents" \
  -H "Content-Type: application/json" \
  -H "User-Agent: curl/business-messaging" \
  -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`" \
  -d "{
    'displayName': 'My test agent',
    'rcsBusinessMessagingAgent': {
      'description': 'My agent description',
      'logoUri': 'https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf',
      'heroUri': 'https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP',
      'phoneNumbers': [
        {
            'phoneNumber': {
                'number': '+44800088088'
            },
            'label': 'My number'
        }
      ],
      'emails': [
        {
            'address': 'support@demo.test',
            'label': 'My email'
        }
      ],
      'websites': [
        {
            'uri': 'https://a.demo.test/',
            'label': 'My site'
        }
      ],
      'privacy': {
        'uri': 'https://a.demo.test/privacy',
        'label': 'My privacy policy'
      },
      'termsConditions': {
        'uri': 'https://a.demo.test/terms',
        'label': 'My terms'
      },
      'color': '#FFFFFF',
      'billingConfig': {
        'billingCategory': 'CONVERSATIONAL'
      },
      'agentUseCase': 'TRANSACTIONAL',
      'hostingRegion': 'EUROPE'
    }
  }"
Mã này là một đoạn trích từ mẫu API Quản lý RBM của chúng tôi.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

const newAgentDetails = {
  displayName: 'My new agent',
  name: brandId + '/agents/',
  rcsBusinessMessagingAgent: {
    description: 'This is the agent description that will be displayed in the Agent info tab in Messages',
    logoUri: 'https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf',
    heroUri: 'https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP',
    phoneNumbers: [
      {
        phoneNumber: {
          number: '+12223334444'
        },
        label: 'Call support'
      }
    ],
    // It's recommended to provide at least one contact method (phone or email) because
    // this is required for launch. For any phone, email, or website provided, a corresponding label
    // must also be included.
    privacy: {
      "uri": 'https://policies.google.com/privacy',
      "label": 'Our privacy policy'
    },
    termsConditions: {
      "uri": 'https://policies.google.com/terms',
      "label": 'Our Terms and Conditions'
    },
    color: '#0B78D0',
    billingConfig: { billingCategory: 'NON_CONVERSATIONAL' },
    agentUseCase: 'TRANSACTIONAL',
    hostingRegion: 'EUROPE'
  }
};

businessCommunicationsApiHelper.createAgent(brandId, newAgentDetails).then((response) => {

}).catch((err) => {
  console.log(err);
});

Java

Brand brand = api.getBrand(brandId);
logger.info("Brand to operate on: " + brand);
String displayName = flags.getOrDefault("agent_name", "Test RBM Agent: " + now.getSecond());
String suffix = flags.getOrDefault("agent_data_suffix", "API");
RcsBusinessMessagingAgent agentData = AgentFactory.createRbmAgent(suffix);
Agent agent = api.createRbmAgent(brand, displayName, agentData);
logger.info("RBM agent has been created: " + agent);

Mã này trả về thông tin về nhân viên hỗ trợ mới và một giá trị nhận dạng riêng biệt được chỉ định cho nhân viên hỗ trợ:

{
  name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_dxuewtvy_agent',
  displayName: 'My new agent',
  rcsBusinessMessagingAgent: {
    description: 'This is the agent description that will be displayed in the Agent info tab in Messages',
    logoUri: 'https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf',
    heroUri: 'https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP',
    phoneNumbers: [ [Object] ],
    privacy: {
      uri: 'https://policies.google.com/privacy',
      label: 'Our privacy policy'
    },
    termsConditions: {
      uri: 'https://policies.google.com/terms',
      label: 'Our Terms and Conditions'
    },
    color: '#0B78D0',
    billingConfig: { billingCategory: 'NON_CONVERSATIONAL' },
    agentUseCase: 'MULTI_USE',
    hostingRegion: 'EUROPE'
  }
}

Tra cứu định nghĩa của nhân viên hỗ trợ

Bạn có thể truy xuất nhân viên hỗ trợ bằng cách chỉ định giá trị nhận dạng riêng biệt (name). Để biết thêm thông tin, hãy xem brands.agents.list.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

// Retrieve details of the first agent (if one has already been created)
businessCommunicationsApiHelper.getAgent(agent.name).then((response) => {

}).catch((err) => {
  console.log(err);
});

Java

Agent agent = api.getAgent(flags.get("agent_id"));
logger.info("Agent: " + agent);

Mã này trả về thông tin về nhân viên hỗ trợ:

{
  name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_dxuewtvy_agent',
  displayName: 'My new agent',
  rcsBusinessMessagingAgent: {
    description: 'This is the agent description that will be displayed in the Agent info tab in Messages',
    logoUri: 'https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf',
    heroUri: 'https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP',
    phoneNumbers: [ [Object] ],
    privacy: {
      uri: 'https://policies.google.com/privacy',
      label: 'Our privacy policy'
    },
    termsConditions: {
      uri: 'https://policies.google.com/terms',
      label: 'Our Terms and Conditions'
    },
    color: '#0B78D0',
    billingConfig: { billingCategory: 'NON_CONVERSATIONAL' },
    agentUseCase: 'MULTI_USE',
    hostingRegion: 'EUROPE'
  }
}

Xác minh và ra mắt

Gửi thông tin xác minh

Bạn phải xác minh thương hiệu để ra mắt nhân viên hỗ trợ. Bạn phải gửi thông tin xác minh trước khi đưa ra yêu cầu ra mắt. Xin lưu ý rằng bạn không phải đợi phê duyệt thương hiệu trước khi đưa ra yêu cầu ra mắt; quy trình phê duyệt thương hiệu diễn ra trong quy trình phê duyệt ra mắt.

Để biết thêm thông tin, hãy xem brands.agents.requestVerification.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

let agentVerificationContact = {
  partnerName: 'Alice',
  partnerEmailAddress: 'alice@thepartner.com',
  brandContactName: 'Bob',
  brandContactEmailAddress: 'bob@thebrand.com',
  brandWebsiteUrl: 'https://thebrand.com/'
};

businessCommunicationsApiHelper.verifyAgent(agent.name, agentVerificationContact).then((response) => {

}).catch((err) => {
  console.log(err);
});

Java

AgentVerificationContact contact = AgentFactory.createRbmAgentVerification();
AgentVerification verification = api.requestAgentVerification(agent.getName(), contact);
logger.info("Verification requested: " + verification);

Mã này trả về thông tin xác minh:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_ciymyd2b_agent",
  "verificationState": "VERIFICATION_STATE_UNVERIFIED",
  "agentVerificationContact": {
    "partnerName": "Alice",
    "partnerEmailAddress": "alice@thepartner.com",
    "brandContactName": "Bob",
    "brandContactEmailAddress": "bob@thebrand.com",
    "brandWebsiteUrl": "https://thebrand.com/"
  }
}

Tra cứu thông tin xác minh của nhân viên hỗ trợ

Bạn có thể truy xuất trạng thái xác minh thương hiệu của nhân viên hỗ trợ. Để biết thêm thông tin, xem brands.agents.getVerification.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper.getAgentVerification(agent.name).then((response) => {

}).catch((err) => {
  console.log(err);
});

Java

AgentVerification verification = api.getAgentVerification(agent.getName());
logger.info("RBM agent verification: " + verification);

Mã này trả về trạng thái xác minh và thông tin đối tác:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_ciymyd2b_agent/verification",
  "verificationState": "VERIFICATION_STATE_UNVERIFIED",
  "agentVerificationContact": {
    "partnerName": "John Doe",
    "partnerEmailAddress": "john.doe@gmail.com",
    "brandContactName": "Bob",
    "brandContactEmailAddress": "bob@brand.com",
    "brandWebsiteUrl": "https://www.brand.com"
  }
}

Gửi nhân viên hỗ trợ để ra mắt

Bạn có thể gửi nhân viên hỗ trợ để ra mắt trên một hoặc nhiều nhà mạng. Một số lần ra mắt do Google quản lý và một số lần ra mắt do nhà mạng trực tiếp quản lý. Các lần ra mắt do nhà mạng quản lý có thể có thêm các yêu cầu. Hãy xem bài viết Các lần ra mắt do Google quản lý so với các lần ra mắt do nhà mạng quản lý để biết thêm thông tin.

Trước khi có thể ra mắt nhân viên hỗ trợ lần đầu tiên, bạn cần gửi thông tin xác minh. Thông tin này cho phép Google, nhà mạng hoặc cả hai xác minh với người liên hệ thương hiệu của bạn rằng bạn được uỷ quyền quản lý nhân viên hỗ trợ thay mặt họ. Hãy xem bài viết xác minh thương hiệu để biết thông tin chi tiết.

Sau khi gửi thông tin xác minh và hoàn tất các điều kiện tiên quyết để ra mắt, bạn có thể gửi yêu cầu ra mắt.

Bạn có thể gửi nhân viên hỗ trợ để ra mắt trên một hoặc nhiều nhà mạng. Bạn phải cung cấp bảng câu hỏi về việc ra mắt đã hoàn tất trong yêu cầu ra mắt. Để biết thêm thông tin, hãy xem brands.agents.requestLaunch.

cURL

curl -v -X POST "https://businesscommunications.googleapis.com/v1/$AGENT_ID:requestLaunch" \
  -H "Content-Type: application/json" \
  -H "User-Agent: curl/business-messaging" \
  -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`" \
  -d "{
    'agentLaunch': {
      'rcsBusinessMessaging': {
        'questionnaire': {
          'contacts': [
            {
              'name': 'John Doe',
              'title': 'Product Owner',
              'email': 'support@demo.test'
            }
          ],
          'optinDescription': 'Thanks for your request.',
          'triggerDescription': 'Promotional messages will be triggered in a timely manner.',
          'interactionsDescription': 'Promotional messages are one way.',
          'optoutDescription': 'Sorry to see you go.',
          'agentAccessInstructions': 'Thanks for your request.',
          'videoUris': [
            'https://d2q4iodazzzt8b.cloudfront.net/MicrosoftTeamsvideo2_1758533835.mp4'
          ],
          'screenshotUris': [
            'https://rm.virbm.com/Il9ChvVEhS1na5mr/ee9bc94b468a40688fb7fc71cb1c069c.png'
          ]
        },
        'launchDetails': {
          '/v1/regions/$CARRIER_ID': {}
        }
      }
    }
  }"
Mã này là một đoạn trích từ mẫu API Quản lý RBM của chúng tôi.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);
  
let agentLaunch = {
  questionnaire: {
    contacts: [
      {
        name: 'James Bond',
        title: 'Mr 0 0 7',
        email: 'someone@somewhere.com'
      }
    ],
    optinDescription: 'Users accepted our terms of service online.',
    triggerDescription: 'We are reaching preregistered users',
    interactionsDescription: 'This agent does not do much.',
    optoutDescription: 'Reply stop and we stop.',
    agentAccessInstructions: 'This is a a simple agent that reaches registered users.',
    videoUris: [
      'https://www.google.com/a/video'
    ],
    screenshotUris: [
      'https://www.google.com/a/screenshot'
    ]
  },
  launchDetails: {}
};

businessCommunicationsApiHelper.launchAgent(agent.name, agentLaunch).then((response) => {

}).catch((err) => {
  console.log(err);
});

Java

Optional<Questionnaire> q = Optional.of(AgentFactory.createRbmQuestionnaire());
AgentLaunch launch = api.requestRbmAgentLaunch(agent.getName(), regionIds, q);
logger.info("RBM agent updated launch: " + launch);

Mã này trả về thông tin về việc ra mắt nhân viên hỗ trợ:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent/launch",
  "rcsBusinessMessaging": {
    "questionnaire": {
      "contacts": [
        {
          "name": "James Bond",
          "title": "Mr O O 7",
          "email": "someone@somewhere.com"
        }
      ],
      "optinDescription": "Users accepted our terms of service online.",
      "triggerDescription": "We are reaching preregistered users",
      "interactionsDescription": "This agent does not do much.",
      "optoutDescription": "Reply stop and we stop.",
      "agentAccessInstructions": "This is a a simple agent that reaches registered users.",
      "videoUris": [
        "https://www.google.com/a/video"
      ],
      "screenshotUris": [
        "https://www.google.com/a/screenshot"
      ]
    },
    "launchDetails": {
      "/v1/regions/some-carrier": {
        "launchState": "LAUNCH_STATE_PENDING",
        "updateTime": "2023-02-24T15:02:13.903554Z"
      }
    },
    "launchRegion": "NORTH_AMERICA"
  }
}

Xin lưu ý rằng launchRegion không được dùng nữa và dự kiến sẽ bị xoá trong thời gian tới.

Ra mắt nhân viên hỗ trợ ở một hoặc nhiều khu vực

Để ra mắt nhân viên hỗ trợ ở một hoặc nhiều khu vực, khi nhân viên hỗ trợ chưa ra mắt trước đó, hãy gọi phương thức requestLaunch bằng một đối tượng chứa bản đồ chỉ có khoá cho tất cả các khu vực mà bạn muốn nhân viên hỗ trợ ra mắt. Việc sử dụng bản đồ trống cho phép duy trì tính nhất quán của API nội bộ trong các đối tượng được dùng giữa các lệnh gọi API.

curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID:requestLaunch" \
-H "Content-Type: application/json" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'name': 'brands/BRAND_ID/agents/AGENT_ID/launch',
  'rcsBusinessMessaging': {
    'questionnaire': {
      'contacts': [
        {
          'name': 'Contact person 000',
          'title': 'Contact manager 000',
          'email': 'user@domain.com000'
        }
      ],
      'optinDescription': 'Opt-in description 0',
      'triggerDescription': 'Trigger description 0',
      'optoutDescription': 'Opt-out description 0',
      'agentAccessInstructions': 'Agent instructions 0',
      'videoUris': [
        'https://www.youtube.com/watch?v=NN75im_us4k'
      ],
      'screenshotUris': [
        'https://www.youtube.com/watch?v=NN75im_us4k'
      ]
    },
    'launchDetails': {
      '/v1/regions/fi-rcs': {}
    }
  }
}"

Để ra mắt nhân viên hỗ trợ ở một hoặc nhiều khu vực (khi nhân viên hỗ trợ đã ra mắt trước đó), hãy gọi phương thức requestLaunch bằng một đối tượng chứa bản đồ chỉ có khoá của tất cả các khu vực mà nhân viên hỗ trợ đã ra mắt tất cả các khu vực mà nhân viên hỗ trợ muốn ra mắt. Việc sử dụng bản đồ trống cho phép duy trì tính nhất quán của API nội bộ trong các đối tượng được dùng giữa các lệnh gọi API.

curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID:requestLaunch" \
-H "Content-Type: application/json" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'name': 'brands/BRAND_ID/agents/AGENT_ID/launch',
  'rcsBusinessMessaging': {
    'launchDetails': {
      '/v1/regions/fi-rcs': {},
      '/v1/regions/vodafone-idea-india': {}
    }
  }
}"

Nếu một nhân viên hỗ trợ gọi phương thức requestLaunch nhưng không bao gồm tất cả các khu vực mà nhân viên hỗ trợ đã ra mắt dưới dạng khoá, thì lỗi 400 - Bad Request sẽ được gửi.

Tra cứu trạng thái ra mắt của nhân viên hỗ trợ

Bạn có thể truy xuất trạng thái ra mắt hiện tại của nhân viên hỗ trợ. Để biết thêm thông tin, xem brands.agents.getLaunch.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper.getAgentLaunch(agent.name).then((response) => {

}).catch((err) => {
  console.log(err);
});

Java

AgentLaunch launch = api.getAgentLaunch(agent.getName());
logger.info("RBM agent launch: " + launch);

Nếu một lần ra mắt bị nhà mạng từ chối, thì đối tác có thể yêu cầu ra mắt lại trên nhà mạng đó (yêu cầu có trạng thái UNSPECIFIED và phần phụ trợ có trạng thái REJECTED).

Mã này trả về thông tin ra mắt và trạng thái ra mắt cho từng nhà mạng mục tiêu:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent/launch",
  "rcsBusinessMessaging": {
    "questionnaire": {
      "contacts": [
        {
          "name": "James Bond",
          "title": "Mr O O 7",
          "email": "someone@somewhere.com"
        }
      ],
      "optinDescription": "Users accepted our terms of service online.",
      "triggerDescription": "We are reaching preregistered users",
      "interactionsDescription": "This agent does not do much.",
      "optoutDescription": "Reply stop and we stop.",
      "agentAccessInstructions": "This is a a simple agent that reaches registered users.",
      "videoUris": [
        "https://www.google.com/a/video"
      ],
      "screenshotUris": [
        "https://www.google.com/a/screenshot"
      ]
    },
    "launchDetails": {
      "/v1/regions/some-carrier": {
        "launchState": "LAUNCH_STATE_PENDING",
        "updateTime": "2023-02-24T15:02:13.903554Z"
      }
    },
    "launchRegion": "NORTH_AMERICA"
  }
}

Xin lưu ý rằng launchRegion không được dùng nữa và dự kiến sẽ bị xoá trong thời gian tới.

Thêm nhà mạng vào lần ra mắt của nhân viên hỗ trợ

Sau khi truy xuất thông tin ra mắt hiện tại cho nhân viên hỗ trợ bằng lệnh gọi API brands.agents.getLaunch, bạn có thể thêm nhiều nhà mạng mục tiêu hơn để mở rộng phạm vi tiếp cận của nhân viên hỗ trợ. Để biết thêm thông tin, hãy xem brands.agents.updateLaunch.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);');

// To launch an agent to further carriers, we need to first obtain the existing
// launch information and extend it with the new carrier(s).
businessCommunicationsApiHelper.getAgentLaunch(agent.name).then((response) => {
  let existingLaunch = response.data.rcsBusinessMessaging;

  // Now we add the new carrier to the existing launch
  existingLaunch.launchDetails[config.launchCarrier2] = null;

  // And we submit the launch again
  businessCommunicationsApiHelper.launchAgent(agent.name, existingLaunch).then((response) => {
    console.log('Launch details are:');
    console.log(JSON.stringify(response.data, null, 2));
  }).catch((err) => {
    console.log(err);
  });
}).catch((err) => {
  console.log(err);
});

Mã này trả về thông tin ra mắt đã cập nhật:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent/launch",
  "rcsBusinessMessaging": {
    "questionnaire": {
      "contacts": [
        {
          "name": "James Bond",
          "title": "Mr O O 7",
          "email": "someone@somewhere.com"
        }
      ],
      "optinDescription": "Users accepted our terms of service online.",
      "triggerDescription": "We are reaching preregistered users",
      "interactionsDescription": "This agent does not do much.",
      "optoutDescription": "Reply stop and we stop.",
      "agentAccessInstructions": "This is a a simple agent that reaches registered users.",
      "videoUris": [
        "https://www.google.com/a/video"
      ],
      "screenshotUris": [
        "https://www.google.com/a/screenshot"
      ]
    },
    "launchDetails": {
      "/v1/regions/some-carrier": {
        "launchState": "LAUNCH_STATE_PENDING",
        "updateTime": "2023-02-24T15:02:13.903554Z"
      },
      "/v1/regions/another-carrier": {
        "launchState": "LAUNCH_STATE_PENDING",
        "updateTime": "2023-02-24T15:04:50.456552Z"
      }
    },
    "launchRegion": "NORTH_AMERICA"
  }
}

Sau khi ra mắt và bảo trì

Liệt kê tất cả nhân viên hỗ trợ được tạo cho một thương hiệu

Nhà phát triển có thể truy xuất danh sách tất cả nhân viên hỗ trợ mà họ đã tạo cho một thương hiệu. Để biết thêm thông tin, hãy xem brands.agents.list.

Node.js

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

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper.listAgents(brand.name).then((response) => {
  console.log('Current agents are:');
  console.log(response.data);
  datastore.saveJsonData('agents', response.data.agents);
}).catch((err) => {
  console.log(err);
});

Java

Brand brand = api.getBrand(brandId);
logger.info("Brand: " + brand);
ListAgentsResponse response = api.listAllAgents(brand);
List<Agent> agents = response.getAgents().stream()
  .sorted(Comparator.comparing(Agent::getName)).collect(Collectors.toList());
logger.info(String.format("Found %d agents", response.getAgents().size()));
for (Agent agent : agents) {
  logger.info(String.format("Agent [%s]: '%s'", agent.getName(), agent.getDisplayName()));
}

Mã này trả về danh sách tất cả nhân viên hỗ trợ do thương hiệu sở hữu:

{
  agents: [
    {
      name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_4fpd1psz_agent',
      displayName: 'My new agent',
      rcsBusinessMessagingAgent: [Object]
    },
    {
      name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_ciymyd2b_agent',
      displayName: 'My second agent',
      rcsBusinessMessagingAgent: [Object]
    },
    {
      name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_helof85o_agent',
      displayName: 'My third agent',
      rcsBusinessMessagingAgent: [Object]
    }
  ]
}

Hiển thị cả các nhân viên hỗ trợ đã lưu trữ

Theo mặc định, danh sách tất cả nhân viên hỗ trợ sẽ không bao gồm những nhân viên hỗ trợ mà đối tác đã lưu trữ. Để hiển thị cả các nhân viên hỗ trợ đã lưu trữ trong kết quả, hãy đặt tham số includeArchived thành true.

Node.js

Phương thức `listAgents` chấp nhận một đối tượng cấu hình không bắt buộc để hiển thị cả các nhân viên hỗ trợ đã lưu trữ.
const businessCommunicationsApiHelper =
 require('@google/rbm-businesscommunications');

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

businessCommunicationsApiHelper.initBusinessCommunicationsApi(privateKey);

// To list all agents including archived ones, set includeArchived to true
const listOptions = {
  includeArchived: true
};

businessCommunicationsApiHelper.listAgents(brand.name, listOptions).then((response) => {
 console.log('Current agents (including archived) are:');
 console.log(response.data);
 datastore.saveJsonData('agents', response.data.agents);
}).catch((err) => {
 console.log(err);
});

Java

Phương thức `listAllAgents` bao gồm một tham số boolean để kiểm soát khả năng hiển thị.
// To list all agents including archived ones, pass 'true' for the includeArchived parameter
boolean includeArchived = true;
Brand brand = api.getBrand(brandId);
logger.info("Brand: " + brand);

// Call listAllAgents with the brand and the includeArchived flag
ListAgentsResponse response = api.listAllAgents(brand, includeArchived);

List agents = response.getAgents().stream()
 .sorted(Comparator.comparing(Agent::getName)).collect(Collectors.toList());

logger.info(String.format("Found %d agents (including archived)", response.getAgents().size()));
for (Agent agent : agents) {
 logger.info(String.format("Agent [%s]: '%s' (Archived: %s)",
    agent.getName(), agent.getDisplayName(), agent.getIsArchived()));
}

Huỷ ra mắt nhân viên hỗ trợ

Để huỷ ra mắt nhân viên hỗ trợ khỏi một khu vực cụ thể, hãy gọi phương thức updateLaunch, chỉ định khu vực mục tiêu trong bản đồ của lệnh gọi và đặt launchState thành LAUNCH_STATE_UNLAUNCHED.

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID" \
-H "Content-Type: application/json" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)"\
-d "{
  'rcsBusinessMessaging': {
    'launchDetails': {
      '/v1/regions/fi-rcs': {
        'launchState': 'LAUNCH_STATE_UNLAUNCHED'
      },
      '/v1/regions/vodafone-idea-india': {
        'launchState': 'LAUNCH_STATE_UNLAUNCHED'
      }
    }
  }
}"

Xoá nhân viên hỗ trợ

Vì lý do bảo mật, bạn không thể xoá nhân viên hỗ trợ RBM nữa. Để được hỗ trợ, hãy liên hệ với nhóm hỗ trợ RCS for Business.

Lưu trữ hoặc huỷ lưu trữ nhân viên hỗ trợ

Để duy trì một không gian làm việc gọn gàng và có tổ chức, bạn có thể lưu trữ những nhân viên hỗ trợ không còn được sử dụng nữa. Khi bạn lưu trữ nhân viên hỗ trợ, nhân viên hỗ trợ đó sẽ bị ẩn khỏi kết quả khám phá API mặc định.

Việc lưu trữ chỉ là thay đổi về khả năng hiển thị. Việc này không xoá nhân viên hỗ trợ hoặc ảnh hưởng đến trạng thái ra mắt cơ bản của nhân viên hỗ trợ đó. Bạn có thể huỷ lưu trữ nhân viên hỗ trợ bất cứ lúc nào để khôi phục khả năng hiển thị và tiếp tục quản lý.

Để đảm bảo rằng các nhân viên hỗ trợ đang hoạt động không bị ẩn do nhầm lẫn, hãy áp dụng các quy tắc sau:

  • Điều kiện: Bạn chỉ có thể lưu trữ những nhân viên hỗ trợ đang ở trạng thái không hoạt động: UNLAUNCHED, SUSPENDED hoặc REJECTED.
  • Hạn chế: Bạn không thể lưu trữ nhân viên hỗ trợ đang ở trạng thái LAUNCHED hoặc PENDING trên bất kỳ nhà mạng nào. Nếu bạn cố gắng lưu trữ một nhân viên hỗ trợ như vậy, thì yêu cầu sẽ bị từ chối kèm theo lỗi.

Cập nhật trạng thái lưu trữ

Để lưu trữ hoặc huỷ lưu trữ nhân viên hỗ trợ, hãy sử dụng phương thức vá. Bạn phải thêm tham số updateMask=is_archived vào URL để chỉ định trường đang được cập nhật. Để lưu trữ, hãy đặt giá trị boolean isArchived thành true và để huỷ lưu trữ, hãy đặt giá trị này thành false.

Phương thức: PATCH /v1/brands/{brandId}/agents/{agentId} Thêm is_archived vào mặt nạ cập nhật.

{
  "isArchived": true
}

Liệt kê nhân viên hỗ trợ bằng bộ lọc

Theo mặc định, phương thức list sẽ ẩn các nhân viên hỗ trợ đã lưu trữ. Để hiển thị các nhân viên hỗ trợ này trong kết quả, hãy sử dụng tham số include_archived.

Phương thức: GET /v1/brands/{brandId}/agents?include_archived=true