RCS for Business एजेंट, बातचीत करने वाली इकाई होती है. यह आपके ब्रैंड का प्रतिनिधित्व करती है और लोगों से इंटरैक्ट करती है. RBM Management API का इस्तेमाल करके, एजेंट बनाए जा सकते हैं. साथ ही, उन्हें पुष्टि और लॉन्च करने के लिए सबमिट किया जा सकता है. इसके अलावा, उनके पूरे लाइफ़साइकल को मैनेज किया जा सकता है. हर एजेंट, मालिकाना हक रखने वाले ब्रैंड से जुड़ा होना चाहिए. इसलिए, एजेंट बनाने से पहले आपको एक ब्रैंड बनाना होगा.
इस पेज पर दिए गए कोड स्निपेट, Java के सैंपल और Node.js के सैंपल से लिए गए हैं.
एजेंट बनाना और उसकी परिभाषा
कोई एजेंट बनाएं
आरबीएम एजेंट बनाने के लिए, आपको उसकी बुनियादी जानकारी देनी होगी.
ज़्यादा जानकारी के लिए, 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'} ] }"
अगर आपका एजेंट कई देशों में लॉन्च किया गया है, तो आपको उन देशों/इलाकों के लिए, पुष्टि करने वाले कई टोकन (हर देश के लिए एक) देने पड़ सकते हैं. ये टोकन, पुष्टि करने वाले उन विभागों से जारी किए गए हों जिन्हें मंज़ूरी मिली है. कोई दूसरा टोकन तय करने के लिए, 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 "{}"
पुष्टि करने वाले टोकन से जुड़ी गड़बड़ियों को ठीक करना
पुष्टि करने वाले टोकन मैनेज करते समय और लॉन्च का अनुरोध करते समय, आपको ये गड़बड़ियां दिख सकती हैं:
- लॉन्च करने के लिए टोकन मौजूद नहीं है: अगर आपने किसी ऐसी मोबाइल और इंटरनेट सेवा देने वाली कंपनी के नेटवर्क पर एजेंट लॉन्च करने का अनुरोध किया है जिसके लिए टोकन की ज़रूरत होती है, लेकिन एजेंट के पास टोकन नहीं है, तो आपको
400 errorमिलेगा (उदाहरण के लिए,"Verification token matching agent <...> and carrier country US is missing"). - एजेंट का डेटा मेल नहीं खाता: आपकी एजेंट प्रोफ़ाइल में मौजूद एजेंट आईडी, एजेंट का नाम, लोगो, और बैनर, टोकन में एम्बेड किए गए डेटा से पूरी तरह मेल खाना चाहिए. अगर आपने ऐसा टोकन अटैच करने की कोशिश की है जो मैच नहीं करता या आपने ऐसे टोकन के साथ लॉन्च करने का अनुरोध किया है जो मैच नहीं करता, तो आपको
400 errorमिलेगा (उदाहरण के लिए,"Agent ID mismatch. Request agent ID: <...>, Token agent ID: <...>").
लॉन्च के लिए एजेंट सबमिट करना
एक या उससे ज़्यादा कैरियर पर लॉन्च करने के लिए, एजेंट सबमिट किया जा सकता है. कुछ लॉन्च को Google मैनेज करता है और कुछ को सीधे तौर पर मोबाइल और इंटरनेट सेवा देने वाली कंपनियां मैनेज करती हैं. कैरियर के ज़रिए मैनेज किए जाने वाले लॉन्च के लिए, कुछ और ज़रूरी शर्तें हो सकती हैं. ज़्यादा जानकारी के लिए, Google के ज़रिए मैनेज किए जाने वाले वर्शन बनाम कैरियर के ज़रिए मैनेज किए जाने वाले वर्शन लॉन्च करना लेख पढ़ें.
पहली बार एजेंट लॉन्च करने से पहले, आपको पुष्टि करने के लिए जानकारी सबमिट करनी होगी. इससे Google, मोबाइल और इंटरनेट सेवा देने वाली कंपनियों या दोनों को यह पुष्टि करने में मदद मिलती है कि आपके पास ब्रैंड के एजेंट को मैनेज करने का अधिकार है. इसके लिए, वे ब्रैंड के संपर्क से पुष्टि करते हैं. ज़्यादा जानकारी के लिए, ब्रैंड की पुष्टि देखें.
पुष्टि के लिए जानकारी सबमिट करने और लॉन्च करने से जुड़ी ज़रूरी शर्तें पूरी करने के बाद, लॉन्च करने का अनुरोध सबमिट किया जा सकता है.
एक या उससे ज़्यादा कैरियर पर लॉन्च करने के लिए, एजेंट सबमिट किया जा सकता है. लॉन्च करने के अनुरोध के साथ, लॉन्च से जुड़े सवालों की सूची सबमिट करना ज़रूरी है. ज़्यादा जानकारी के लिए, 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 अब काम नहीं करता. इसे जल्द ही हटा दिया जाएगा.
एक या उससे ज़्यादा क्षेत्रों में एजेंट लॉन्च करना
अगर किसी एजेंट को एक या उससे ज़्यादा क्षेत्रों में लॉन्च करना है और एजेंट को पहले लॉन्च नहीं किया गया है, तो requestLaunch तरीके को कॉल करें. इसके लिए, एक ऐसा ऑब्जेक्ट इस्तेमाल करें जिसमें उन सभी क्षेत्रों के लिए सिर्फ़ कुंजियों का मैप हो जहां आपको एजेंट को लॉन्च करना है. खाली मैप का इस्तेमाल करने से, एपीआई कॉल के बीच इस्तेमाल किए गए ऑब्जेक्ट में इंटरनल एपीआई की एक जैसी स्थिति बनाए रखने में मदद मिलती है.
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': {} } } }"
requestLaunch तरीके का इस्तेमाल करें. इसके लिए, एक ऑब्जेक्ट का इस्तेमाल करें. इस ऑब्जेक्ट में, उन सभी क्षेत्रों की सिर्फ़ कुंजियों का मैप होना चाहिए जहां एजेंट पहले से लॉन्च है और उन सभी क्षेत्रों की कुंजियों का मैप होना चाहिए जहां एजेंट को लॉन्च करना है. खाली मैप का इस्तेमाल करने से, एपीआई कॉल के बीच इस्तेमाल किए गए ऑब्जेक्ट में इंटरनल एपीआई की स्थिरता बनाए रखने में मदद मिलती है.
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 एपीआई कॉल का इस्तेमाल करके, अपने एजेंट के लिए लॉन्च की मौजूदा जानकारी पाने के बाद, ज़्यादा टारगेट कैरियर जोड़े जा सकते हैं. इससे आपके एजेंट की पहुंच बढ़ेगी. ज़्यादा जानकारी के लिए, 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' } } } }"
किसी एजेंट को मिटाना
सुरक्षा से जुड़ी वजहों से, अब आरबीएम एजेंट नहीं मिटाए जा सकते. मदद पाने के लिए, RCS for Business की सहायता टीम से संपर्क करें.
एजेंट को संग्रहित करना या संग्रह से निकालना
वर्कस्पेस को साफ़-सुथरा और व्यवस्थित रखने के लिए, उन एजेंट को संग्रहित किया जा सकता है जिनका अब इस्तेमाल नहीं किया जा रहा है. किसी एजेंट को संग्रहित करने पर, वह एपीआई खोजने के डिफ़ॉल्ट नतीजों में नहीं दिखता.
संग्रहित करने से, सिर्फ़ दिखने की सेटिंग में बदलाव होता है. इससे एजेंट नहीं मिटता और न ही लॉन्च की स्थिति पर कोई असर पड़ता है. किसी एजेंट को कभी भी संग्रह से निकाला जा सकता है, ताकि वह फिर से दिखने लगे और उसे मैनेज किया जा सके.
यह पक्का करने के लिए कि चालू एजेंट गलती से न छिप जाएं, ये नियम लागू होते हैं:
- ज़रूरी शर्तें: सिर्फ़ उन एजेंट को संग्रहित किया जा सकता है जो इनऐक्टिव हैं:
UNLAUNCHED,SUSPENDEDयाREJECTED. - पाबंदियां: ऐसे एजेंट को संग्रहित नहीं किया जा सकता जो किसी भी कैरियर पर
LAUNCHEDयाPENDINGहो. ऐसे एजेंट को संग्रहित करने की कोशिश करने पर, अनुरोध को अस्वीकार कर दिया जाएगा और गड़बड़ी का मैसेज दिखेगा.
संग्रहित करने की स्थिति अपडेट करना
किसी एजेंट को संग्रहित करने या संग्रह से निकालने के लिए, पैच तरीके का इस्तेमाल करें. आपको यूआरएल में updateMask=is_archived पैरामीटर शामिल करना होगा, ताकि अपडेट किए जा रहे फ़ील्ड के बारे में बताया जा सके. संग्रहित करने के लिए, isArchived बूलियन को true पर सेट करें और संग्रह से निकालने के लिए, इसे false पर सेट करें.
तरीका: PATCH /v1/brands/{brandId}/agents/{agentId}
अपडेट मास्क में is_archived जोड़ें.
{
"isArchived": true
}
फ़िल्टर की मदद से एजेंट की सूची बनाना
डिफ़ॉल्ट रूप से, list तरीके से संग्रहित किए गए एजेंट छिप जाते हैं. इन्हें अपने नतीजों में शामिल करने के लिए, include_archived पैरामीटर का इस्तेमाल करें.
तरीका: GET /v1/brands/{brandId}/agents?include_archived=true