Wszyscy agenci należą do marki (firmy, organizacji lub grupy). Zanim będzie można utworzyć agenta, musisz utworzyć markę, do której będzie on należeć. Marki służą wyłącznie do celów organizacyjnych, aby ułatwić grupowanie powiązanych agentów.
Fragmenty kodu na tej stronie pochodzą z przykładów w języku Java i Node.js.
Tworzenie i definiowanie agenta
Utwórz agenta
Aby utworzyć agenta RBM, musisz określić jego podstawowe informacje.
Więcej informacji znajdziesz w artykule 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);
Ten kod zwraca informacje o nowym agencie i unikalny identyfikator przypisany do agenta:
{
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'
}
}
Wyszukiwanie definicji agenta
Możesz pobrać agenta, podając jego unikalny identyfikator (name). Więcej
informacji znajdziesz w artykule 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);
Ten kod zwraca informacje o agencie:
{
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'
}
}
Weryfikacja i uruchomienie
Przesyłanie informacji weryfikacyjnych
Weryfikacja marki jest wymagana do uruchomienia agenta. Zanim prześlesz prośbę o uruchomienie, musisz przesłać informacje weryfikacyjne. Pamiętaj, że nie musisz czekać na zatwierdzenie marki, zanim prześlesz prośbę o uruchomienie. Zatwierdzenie marki jest częścią procesu zatwierdzania uruchomienia. W przypadku niektórych operatorów musisz też podać prawidłowy token weryfikacyjny wydany przez urząd weryfikacyjny.
Więcej informacji znajdziesz w artykule 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);
Ten kod zwraca informacje weryfikacyjne:
{
"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"
}
]
}
Wyszukiwanie informacji weryfikacyjnych agenta
Możesz pobrać stan weryfikacji marki agenta. Więcej informacji znajdziesz w artykule
zobacz 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);
Ten kod zwraca stan weryfikacji i informacje o partnerze:
{
"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"
}
]
}
Aktualizowanie i usuwanie tokenów weryfikacyjnych
Jeśli masz już uruchomionego agenta, możesz go zaktualizować za pomocą tokena weryfikacyjnego. Aby dodać lub zaktualizować token, wywołaj metodę updateVerification (za pomocą żądania PATCH) i określ maskę aktualizacji 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'} ] }"
Jeśli agent jest uruchomiony w wielu krajach, może być konieczne podanie kilku tokenów (po jednym na każdy kraj) wydanych przez zatwierdzone urzędy weryfikacyjne w tych regionach. Aby określić dodatkowy token, wywołaj metodę updateVerification i podaj wszystkie tokeny, które chcesz powiązać z agentem, w tym te, które są już z nim powiązane.
Aby usunąć wszystkie tokeny powiązane z agentem, wyślij pustą listę w żądaniu 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 "{}"
Rozwiązywanie problemów z błędami tokenów weryfikacyjnych
Podczas zarządzania tokenami weryfikacyjnymi i wysyłania próśb o uruchomienie mogą wystąpić te błędy:
- Missing token for launch (Brak tokena do uruchomienia): jeśli poprosisz o uruchomienie u operatora, który
wymaga tokena, ale agent go nie ma, otrzymasz
400 error(np."Verification token matching agent <...> and carrier country US is missing"). - Mismatched agent data (Niezgodne dane agenta): identyfikator agenta, jego nazwa, logo i baner w
profilu agenta muszą być dokładnie takie same jak dane osadzone w tokenie. Jeśli spróbujesz dołączyć token, który nie pasuje, lub poprosisz o uruchomienie z
niezgodnym tokenem, otrzymasz
400 error(np."Agent ID mismatch. Request agent ID: <...>, Token agent ID: <...>").
Przesyłanie agenta do uruchomienia
Możesz przesłać agenta do uruchomienia u co najmniej 1 operatora. Niektórymi uruchomieniami zarządza Google, a innymi – bezpośrednio operatorzy. Uruchomienia zarządzane przez operatora mogą mieć dodatkowe wymagania. Więcej informacji znajdziesz w artykule Uruchomienia zarządzane przez Google a uruchomienia zarządzane przez operatora .
Zanim po raz pierwszy uruchomisz agenta, musisz przesłać informacje weryfikacyjne. Dzięki temu Google, operatorzy lub obie te strony mogą potwierdzić u osoby kontaktowej w Twojej marce, że masz uprawnienia do zarządzania agentem w ich imieniu. Więcej informacji znajdziesz w artykule Weryfikacja marki.
Gdy prześlesz informacje weryfikacyjne i spełnisz wymagania wstępne dotyczące uruchomienia, możesz przesłać prośbę o uruchomienie.
Możesz przesłać agenta do uruchomienia u co najmniej 1 operatora. W ramach prośby o uruchomienie musisz przesłać wypełniony kwestionariusz uruchamiania. Więcej
informacji znajdziesz w artykule 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);
Ten kod zwraca informacje o uruchomieniu agenta:
{
"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"
}
}
Pamiętaj, że parametr launchRegion został wycofany i wkrótce zostanie usunięty.
Uruchamianie agenta w co najmniej 1 regionie
Aby uruchomić agenta w co najmniej 1 regionie, gdy agent nie został jeszcze uruchomiony
, wywołaj metodę requestLaunch z obiektem zawierającym mapę
tylko kluczy wszystkich regionów, w których chcesz uruchomić agenta. Użycie pustej mapy pozwala zachować wewnętrzną spójność interfejsu API w obiektach używanych między wywołaniami interfejsu 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': {} } } }"
Aby uruchomić agenta w co najmniej 1 regionie (gdy agent został już uruchomiony ), wywołaj metodę requestLaunch z obiektem zawierającym mapę tylko kluczy wszystkich regionów, w których agent jest już uruchomiony, oraz wszystkich regionów, w których chcesz go uruchomić. Użycie pustej mapy pozwala zachować wewnętrzną spójność interfejsu API w obiektach używanych między wywołaniami interfejsu 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': {} } } }"
Jeśli agent wywoła metodę requestLaunch, ale nie uwzględni wszystkich regionów
, w których jest już uruchomiony, jako kluczy, zostanie zgłoszony błąd 400 - Bad Request.
Wyszukiwanie stanu uruchomienia agenta
Możesz pobrać aktualny stan uruchomienia agenta. Więcej informacji znajdziesz w artykule
zobacz 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);
Jeśli operator odrzuci uruchomienie, partner może ponownie poprosić o uruchomienie u tego operatora (żądanie ma stan UNSPECIFIED, a backend ma stan REJECTED).
Ten kod zwraca informacje o uruchomieniu i stan uruchomienia dla każdego docelowego operatora:
{
"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"
}
}
Pamiętaj, że parametr launchRegion został wycofany i wkrótce zostanie usunięty.
Dodawanie kolejnych operatorów do uruchomienia agenta
Po pobraniu aktualnych informacji o uruchomieniu agenta za pomocą wywołania interfejsu API brands.agents.getLaunch możesz dodać więcej docelowych operatorów, aby zwiększyć zasięg agenta. Więcej informacji znajdziesz w artykule
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); });
Ten kod zwraca zaktualizowane informacje o uruchomieniu:
{
"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"
}
}
Po uruchomieniu i konserwacja
Wyświetlanie listy wszystkich agentów utworzonych dla marki
Programista może pobrać listę wszystkich agentów utworzonych dla marki.
Więcej informacji znajdziesz w artykule
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())); }
Ten kod zwraca listę wszystkich agentów należących do marki:
{
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]
}
]
}
Uwzględnianie zarchiwizowanych agentów
Domyślnie lista wszystkich agentów nie obejmuje agentów, którzy zostali zarchiwizowani przez partnera.
Aby uwzględnić zarchiwizowane agenty w wynikach, ustaw parametr includeArchived na true.
Node.js
Metoda `listAgents` akceptuje opcjonalny obiekt konfiguracji, który umożliwia uwzględnienie zarchiwizowanych agentów.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
Metoda `listAllAgents` zawiera parametr logiczny do kontrolowania widoczności.// 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())); }
Cofanie uruchomienia agenta
Aby cofnąć uruchomienie agenta w określonym regionie, wywołaj metodę updateLaunch,
określ region docelowy na mapie wywołania i ustaw launchState na
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' } } } }"
Usuwanie agenta
Ze względów bezpieczeństwa nie można już usuwać agentów RBM. Aby uzyskać pomoc, skontaktuj się z zespołem pomocy RCS dla firm.
Archiwizowanie i przywracanie agentów z archiwum
Aby zachować porządek w obszarze roboczym, możesz zarchiwizować agentów, którzy nie są już używani. Zarchiwizowanie agenta powoduje ukrycie go w domyślnych wynikach wyszukiwania interfejsu API.
Archiwizacja to zmiana dotycząca tylko widoczności. Nie powoduje usunięcia agenta ani nie wpływa na jego stan uruchomienia. W każdej chwili możesz przywrócić agenta z archiwum, aby przywrócić jego widoczność i kontynuować zarządzanie nim.
Aby aktywne agenty nie zostały przypadkowo ukryte, obowiązują te reguły:
- Kryteria kwalifikacji: możesz zarchiwizować tylko agenty, które są w stanie nieaktywnym:
UNLAUNCHED,SUSPENDED, lubREJECTED. - Ograniczenia: nie możesz zarchiwizować agenta, który jest
LAUNCHEDlubPENDINGu żadnego operatora. Jeśli spróbujesz zarchiwizować takiego agenta, żądanie zostanie odrzucone z błędem.
Aktualizowanie stanu archiwizacji
Aby zarchiwizować agenta lub przywrócić go z archiwum, użyj metody patch. Aby określić aktualizowane pole, musisz dodać do adresu URL parametr updateMask=is_archived. Aby zarchiwizować, ustaw wartość logiczną isArchived na true, a aby przywrócić z archiwum, ustaw ją na false.
Metoda: PATCH /v1/brands/{brandId}/agents/{agentId}
Dodaj is_archived do maski aktualizacji.
{
"isArchived": true
}
Wyświetlanie listy agentów z filtrami
Domyślnie metoda list ukrywa zarchiwizowane agenty. Aby uwzględnić je w wynikach, użyj parametru include_archived.
Metoda: GET /v1/brands/{brandId}/agents?include_archived=true