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

Nhân viên hỗ trợ RCS for Business là thực thể đàm thoại đại diện cho thương hiệu của bạn và tương tác với người dùng. Bạn có thể sử dụng API Quản lý RBM để tạo nhân viên hỗ trợ, gửi nhân viên hỗ trợ để xác minh và ra mắt, đồng thời quản lý toàn bộ vòng đời của nhân viên hỗ trợ. Vì mọi tác nhân đều phải thuộc về một thương hiệu sở hữu, nên bạn cần tạo một thương hiệu trước khi tạo một tác nhân.

Các đ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 tác nhân

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

Để tạo một 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'
    }
  }"
Đoạn mã này là một phần trong mẫu RBM Management API 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 duy nhấ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 về tác nhân

Bạn có thể truy xuất một tác nhân bằng cách chỉ định giá trị nhận dạng riêng biệt (name). Để biết thêm thông tin chi tiết, 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ề tác nhân:

{
  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à triển khai

Gửi thông tin xác minh

Xác minh thương hiệu là bước bắt buộc để ra mắt nhân viên hỗ trợ. Bạn phải gửi thông tin xác minh trước khi gửi yêu cầu ra mắt. Xin lưu ý rằng bạn không cần phải đợi thương hiệu phê duyệt trước khi gửi yêu cầu phát hành; thương hiệu phê duyệt trong quy trình phê duyệt phát hành. Đối với một số hãng vận chuyển, bạn cũng phải cung cấp mã xác minh hợp lệ do Cơ quan xác minh cấp.

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

cURL

curl -v "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID:requestVerification" \
-H "Content-Type: application/json" \
-H "x-http-method-override: POST" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'agentVerificationContact': {
     ...
   },
   'agentVerificationToken':
     {'tokenBase64Encoded': '$TOKEN'}
}"

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/"
  },
  "agentVerificationTokens": [
    {
      "verificationAuthorityDisplayName": "Example Verification Authority",
      "expirationTime": "2027-06-16T13:45:14Z",
      "status": "ACTIVE",
      "countryCode": "US",
      "tokenBase64Encoded": "...",
      "certificateChainUri": "https://rbm.goog/certificates?v=5&kid=6CAE185529AABAC216565E99A8DE22504B086209"
    }
  ]
}

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 một tác nhân. Để biết thêm thông tin, hãy 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"
  },
  "agentVerificationTokens": [
    {
      "verificationAuthorityDisplayName": "Example Verification Authority",
      "expirationTime": "2027-06-16T13:45:14Z",
      "status": "ACTIVE",
      "countryCode": "US",
      "tokenBase64Encoded": "...",
      "certificateChainUri": "https://rbm.goog/certificates?v=5&kid=6CAE185529AABAC216565E99A8DE22504B086209"
    }
  ]
}

Cập nhật và xoá mã xác minh

Nếu đã ra mắt một tác nhân, bạn có thể cập nhật tác nhân đó bằng mã thông báo xác minh. Để thêm hoặc cập nhật mã thông báo, hãy gọi phương thức updateVerification (bằng yêu cầu PATCH) và chỉ định mặt nạ cập nhật agent_verification_tokens.

cURL

curl -v -X PATCH "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID/verification?updateMask=agent_verification_tokens" \
-H "Content-Type: application/json" \
-H "x-http-method-override: PATCH" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
   'agentVerificationTokens': [
     {'tokenBase64Encoded': '$TOKEN'}
   ]
}"

Nếu ra mắt tác nhân ở nhiều quốc gia, bạn có thể cần chỉ định nhiều mã thông báo (mỗi mã thông báo cho một quốc gia) do các cơ quan xác minh được phê duyệt cấp cho những khu vực đó. Để chỉ định một mã thông báo bổ sung, hãy gọi phương thức updateVerification và cung cấp tất cả mã thông báo mà bạn muốn liên kết với tác nhân, bao gồm cả những mã thông báo đã được liên kết với tác nhân.

Để xoá tất cả mã thông báo được liên kết với một tác nhân, hãy gửi một danh sách trống trong yêu cầu PATCH:

cURL

curl -v -X PATCH "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID/verification?updateMask=agent_verification_tokens" \
-H "Content-Type: application/json" \
-H "x-http-method-override: PATCH" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{}"

Khắc phục lỗi mã xác minh

Khi quản lý mã thông báo xác minh và yêu cầu phát hành, bạn có thể gặp phải các lỗi sau:

  • Thiếu mã thông báo để ra mắt: Nếu yêu cầu ra mắt trên một hãng hàng không yêu cầu mã thông báo nhưng tác nhân lại thiếu mã thông báo, bạn sẽ nhận được 400 error (ví dụ: "Verification token matching agent <...> and carrier country US is missing").
  • Dữ liệu tác nhân không khớp: Mã tác nhân, tên tác nhân, biểu trưng và biểu ngữ trong hồ sơ tác nhân phải khớp chính xác với dữ liệu được nhúng trong mã thông báo. Nếu cố gắng đính kèm một mã thông báo không khớp hoặc yêu cầu khởi chạy bằng một mã thông báo không khớp, bạn sẽ nhận được 400 error (ví dụ: "Agent ID mismatch. Request agent ID: <...>, Token agent ID: <...>").

Gửi tác nhân để ra mắt

Bạn có thể gửi một tác nhân để ra mắt trên một hoặc nhiều nhà mạng. Một số đợt ra mắt do Google quản lý và một số khác do nhà mạng quản lý trực tiếp. Các bản phát hành 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 Bản phát hành do Google quản lý so với bản phát hành do nhà mạng quản lý để biết thêm thông tin.

Trước khi 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. Điều này cho phép Google, nhà mạng hoặc cả hai xác minh với người liên hệ của thương hiệu rằng bạn được uỷ quyền quản lý tác nhân thay cho 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 một tác nhân để 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 đã hoàn tất về việc ra mắt trong yêu cầu ra mắt. Để biết thêm thông tin chi tiết, 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': {}
        }
      }
    }
  }"
Đoạn mã này là một phần trong mẫu RBM Management API 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 khởi chạy tác nhân:

{
  "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òn được dùng nữa và sẽ sớm bị xoá.

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

Để chạy một tác nhân ở một hoặc nhiều khu vực, khi tác nhân chưa chạy trước đó, hãy gọi phương thức requestLaunch bằng một đối tượng chứa bản đồ chỉ có các khoá cho tất cả các khu vực mà bạn muốn tác nhân chạy. Việc sử dụng một 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': {}
    }
  }
}"

Để chạy 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ạy trước đó), hãy gọi phương thức requestLaunch bằng một đối tượng chứa bản đồ chỉ các khoá của tất cả các khu vực mà nhân viên hỗ trợ đã chạy và tất cả các khu vực mà nhân viên hỗ trợ muốn chạy. Việc sử dụng một bản đồ trống giú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 tác nhân gọi phương thức requestLaunch nhưng không bao gồm tất cả các khu vực mà tác nhân đã 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 khởi chạy hiện tại của một tác nhân. Để biết thêm thông tin, hãy 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 hãng vận chuyển từ chối việc phát hành, thì đối tác có thể yêu cầu hãng vận chuyển phát hành lại (yêu cầu có trạng thái UNSPECIFIED và chương trình 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 của 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òn được dùng nữa và sẽ sớm bị xoá.

Thêm các nhà mạng khác vào đợt ra mắt của tác nhân

Sau khi truy xuất thông tin triển khai hiện tại cho hãng vận chuyển bằng lệnh gọi API brands.agents.getLaunch, bạn có thể thêm nhiều hãng vận chuyển mục tiêu hơn để mở rộng phạm vi tiếp cận của hãng vận chuyển. Để 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 khởi chạy đã 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 phát hành và duy trì

Liệt kê tất cả các tác nhân đượ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ả các tác nhân 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ả các tác nhân thuộc sở hữu của thương hiệ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]
    }
  ]
}

Bao gồm nhân viên hỗ trợ đã lưu trữ

Theo mặc định, danh sách tất cả các đại lý sẽ không bao gồm những đại lý đã được đối tác lưu trữ. Để đưa các nhân viên hỗ trợ đã lưu trữ vào 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 để đưa các tác nhân đã lưu trữ vào.
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" có 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 tác nhân

Để huỷ ra mắt một tác nhân ở 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/launch" \
-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á một tác nhân

Vì lý do bảo mật, bạn không thể xoá nhân viên hỗ trợ RBM nữa. Để được trợ giúp, hãy liên hệ với nhóm hỗ trợ của 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à ngăn nắp, bạn có thể lưu trữ những tác nhân không còn được sử dụng. Khi bạn lưu trữ một 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.

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

Để đảm bảo rằng các tác nhân đang hoạt động không bị ẩn nhầm, các quy tắc sau sẽ được áp dụng:

  • Điều kiện: Bạn chỉ có thể lưu trữ những nhân viên đ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 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 tác nhân như vậy, 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ữ một tác nhân, 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ê các tác nhân 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ữ. Để đưa các kết quả này vào, hãy sử dụng tham số include_archived.

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