RCS for Business エージェントは、ブランドを表し、ユーザーとやり取りする会話エンティティです。RBM Management API を使用して、エージェントの作成、確認とリリースへの送信、ライフサイクル全体の管理を行うことができます。すべてのエージェントは所有ブランドに属している必要があるため、エージェントを作成する前にブランドを作成する必要があります。
このページのコード スニペットは、Java サンプルと Node.js サンプルから抜粋したものです。
エージェントの作成と定義
エージェントを作成する
RBM エージェントを作成するには、基本情報を定義する必要があります。
詳細については、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' } }"
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);
このコードは、新しいエージェント情報と、エージェントに割り当てられた固有識別子を返します。
{
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'
}
}
エージェントの定義を検索する
エージェントを取得するには、一意の識別子(name)を指定します。詳細については、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);
このコードはエージェント情報を返します。
{
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'
}
}
検証とリリース
確認情報を送信する
エージェントを起動するには、ブランドの確認が必要です。起動リクエストを行う前に確認情報を送信する必要があります。リリース リクエストを行う前にブランドの承認を待つ必要はありません。ブランドの承認は、リリース承認プロセスの一環として行われます。一部の携帯通信会社では、認証機関が発行した有効な認証トークンも提供する必要があります。
詳細については、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);
このコードは検証情報を返します。
{
"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"
}
]
}
エージェントの確認情報を検索する
エージェントのブランド確認のステータスを取得できます。詳しくは、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);
このコードは、確認ステータスとパートナー情報を返します。
{
"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"
}
]
}
確認トークンを更新、削除する
すでにエージェントを起動している場合は、確認トークンを使用して更新できます。トークンを追加または更新するには、updateVerification メソッド(PATCH リクエストを使用)を呼び出し、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'} ] }"
エージェントが複数の国でリリースされている場合は、それらの地域で承認された認証機関から発行された複数のトークン(国ごとに 1 つ)を指定する必要がある場合があります。追加のトークンを指定するには、updateVerification メソッドを呼び出し、エージェントに関連付けるすべてのトークン(すでにエージェントに関連付けられているトークンを含む)を指定します。
エージェントに関連付けられているすべてのトークンを削除するには、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 "{}"
確認トークン エラーのトラブルシューティング
確認トークンを管理してリリースをリクエストする際に、次のエラーが発生することがあります。
- Missing token for launch(リリース用のトークンがない): トークンが必要な携帯通信会社でリリースをリクエストしたにもかかわらず、エージェントにトークンがない場合は、
400 error(例:"Verification token matching agent <...> and carrier country US is missing")が返されます。 - エージェントのデータが一致しない: エージェントのプロファイルにあるエージェント ID、エージェント名、ロゴ、バナーは、トークンに埋め込まれたデータと完全に一致している必要があります。一致しないトークンを付加しようとした場合や、一致しないトークンで起動をリクエストした場合は、
400 error("Agent ID mismatch. Request agent ID: <...>, Token agent ID: <...>"など)が返されます。
エージェントをリリース用に送信する
1 つ以上の携帯通信会社でリリースするエージェントを送信できます。一部のリリースは Google が管理し、一部は携帯通信会社が直接管理します。携帯通信会社が管理するリリースには、追加の要件が適用される場合があります。詳しくは、Google 管理のリリースと携帯通信会社管理のリリースをご覧ください。
エージェントを初めて起動する前に、確認情報を送信する必要があります。これにより、Google または携帯通信会社、あるいはその両方が、ブランドの連絡先に連絡して、お客様がブランドの代理としてエージェントを管理する権限を持っていることを確認できます。詳しくは、ブランドの確認をご覧ください。
確認情報を送信し、リリースに必要な条件を満たしたら、リリース リクエストを送信できます。
1 つ以上の携帯通信会社でリリースするエージェントを送信できます。リリース リクエストの一部として、リリース アンケートの記入済み版を提出する必要があります。詳しくは、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': {} } } } }"
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);
このコードは、エージェントの起動情報を返します。
{
"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"
}
}
なお、launchRegion は非推奨であり、まもなく削除される予定です。
1 つ以上のリージョンにエージェントをリリースする
1 つ以上のリージョンにエージェントを起動するには、エージェントが以前に起動されていない場合に、エージェントを起動するすべてのリージョンのキーのみのマップを含むオブジェクトを使用して requestLaunch メソッドを呼び出します。空のマップを使用すると、API 呼び出し間で使用されるオブジェクトの内部 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': {} } } }"
1 つ以上のリージョンにエージェントを起動するには(エージェントが以前に起動された場合)、エージェントがすでに起動されているすべてのリージョンと、エージェントを起動するすべてのリージョンのキーのみのマップを含むオブジェクトを使用して、requestLaunch メソッドを呼び出します。空のマップを使用すると、API 呼び出し間で使用されるオブジェクトの内部 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': {} } } }"
エージェントが requestLaunch メソッドを呼び出すときに、エージェントがすでに起動されているすべてのリージョンをキーとして含めないと、400 - Bad Request エラーがスローされます。
エージェントのリリース ステータスを調べる
エージェントの現在のリリース ステータスを取得できます。詳しくは、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);
リリースが携帯通信会社によって拒否された場合、パートナーは携帯通信会社に再度リリースをリクエストできます(リクエストは UNSPECIFIED 状態になり、バックエンドは REJECTED 状態になります)。
このコードは、各対象携帯通信会社のリリース情報とリリース ステータスを返します。
{
"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"
}
}
launchRegion は非推奨であり、まもなく削除される予定です。
エージェントのリリースに携帯通信会社を追加する
brands.agents.getLaunch API 呼び出しを使用してエージェントの現在のリリース情報を取得したら、対象となる携帯通信会社を追加して、エージェントのリーチを拡大できます。詳しくは 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); });
このコードは、更新されたリリース情報を返します。
{
"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"
}
}
リリース後とメンテナンス
ブランド用に作成されたすべてのエージェントを一覧表示する
デベロッパーは、ブランド用に作成したすべてのエージェントのリストを取得できます。詳しくは、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())); }
このコードは、ブランドが所有するすべてのエージェントのリストを返します。
{
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]
}
]
}
アーカイブされたエージェントを含める
デフォルトでは、すべてのエージェントのリストには、パートナーによってアーカイブされたエージェントは含まれません。アーカイブされたエージェントを結果に含めるには、includeArchived パラメータを true に設定します。
Node.js
`listAgents` メソッドは、アーカイブされたエージェントを含めるための構成オブジェクト(省略可)を受け取ります。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
`listAllAgents` メソッドには、可視性を制御するためのブール値パラメータが含まれています。// 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); Listagents = 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())); }
エージェントのリリースを解除する
特定のリージョンからエージェントのリリースを停止するには、updateLaunch メソッドを呼び出し、呼び出しのマップでターゲット リージョンを指定して、launchState を 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' } } } }"
エージェントを削除する
セキュリティ上の理由から、RBM エージェントを削除できなくなりました。サポートが必要な場合は、RCS for Business サポートチームにお問い合わせください。
エージェントをアーカイブまたはアーカイブ解除する
作業スペースを整理整頓するには、使用しなくなったエージェントをアーカイブします。エージェントをアーカイブすると、デフォルトの API 検出結果に表示されなくなります。
アーカイブは表示設定のみの変更です。エージェントは削除されず、基盤となるリリース状態にも影響しません。エージェントはいつでもアーカイブ解除して、可視性を復元し、管理を続行できます。
アクティブなエージェントが誤って非表示にならないように、次のルールが適用されます。
- 対象: アーカイブできるのは、非アクティブ状態(
UNLAUNCHED、SUSPENDED、REJECTED)のエージェントのみです。 - 制限事項: どの携帯通信会社でも、
LAUNCHEDまたはPENDINGのエージェントをアーカイブすることはできません。このようなエージェントをアーカイブしようとすると、リクエストはエラーで拒否されます。
アーカイブ ステータスを更新する
エージェントをアーカイブまたはアーカイブ解除するには、patch メソッドを使用します。更新するフィールドを指定するには、URL に updateMask=is_archived パラメータを含める必要があります。アーカイブするには、isArchived ブール値を true に設定します。アーカイブを解除するには、false に設定します。
メソッド: PATCH /v1/brands/{brandId}/agents/{agentId}
更新マスクに is_archived を追加します。
{
"isArchived": true
}
フィルタを使用してエージェントを一覧表示する
デフォルトでは、list メソッドはアーカイブされたエージェントを非表示にします。結果に含めるには、include_archived パラメータを使用します。
Method: GET /v1/brands/{brandId}/agents?include_archived=true