आरबीएम एजेंट, लोगों के साथ मैसेज भेजकर और पाकर बातचीत करते हैं. उपयोगकर्ताओं को मैसेज भेजने के लिए, आपका एजेंट RCS Business Messaging API को मैसेज भेजने के अनुरोध भेजता है. एक अनुरोध में टेक्स्ट, रिच कार्ड, मीडिया और PDF फ़ाइलें के साथ-साथ जवाब देने के सुझाव और कार्रवाइयां करने के सुझाव शामिल हो सकते हैं.
RBM प्लैटफ़ॉर्म, मैसेज की डिलीवरी को मैनेज करने में आपकी मदद करने के लिए, कुछ स्थितियों में गड़बड़ियां दिखाएगा:
- अगर आपने किसी ऐसे व्यक्ति को मैसेज भेजा है जिसके डिवाइस पर आरसीएस की सुविधा काम नहीं करती या आरसीएस की सुविधा चालू नहीं है, तो RBM प्लैटफ़ॉर्म, 404 NOT_FOUND गड़बड़ी दिखाता है. ऐसे में, अपने इंफ़्रास्ट्रक्चर में तय किए गए फ़ॉलबैक तरीकों का इस्तेमाल करके, उपयोगकर्ता से संपर्क किया जा सकता है.
- अगर आपने किसी ऐसे नेटवर्क पर आरसीएस का इस्तेमाल करने वाले व्यक्ति को मैसेज भेजा है जहां आपका एजेंट अब तक लॉन्च नहीं हुआ है या जहां आरसीएस ट्रैफ़िक चालू नहीं है, तो RBM प्लैटफ़ॉर्म, 404 NOT_FOUND गड़बड़ी दिखाता है.
- अगर आपने किसी ऐसे ऐप्लिकेशन का इस्तेमाल करके मैसेज भेजा है जो उपयोगकर्ता के डिवाइस पर काम नहीं करता, तो RBM प्लैटफ़ॉर्म, 400 INVALID_ARGUMENT गड़बड़ी का मैसेज दिखाता है. साथ ही, आपका मैसेज डिलीवर नहीं करता.
मल्टी-चैनल मैसेजिंग की रणनीति के तहत, यह सबसे अच्छा है कि आप उन मैसेज को वापस ले लें जो तय समय के बाद भी डिलीवर नहीं हुए हैं. इसके बाद, उन्हें किसी दूसरे चैनल से भेजें. मैसेज को तय समय पर अपने-आप मिटाने के लिए, मैसेज के मिटने की अवधि सेट करें.
पाने वाला ऑफ़लाइन है
अगर मैसेज पाने वाला व्यक्ति ऑफ़लाइन है, तो भी RBM प्लैटफ़ॉर्म डिलीवरी के लिए मैसेज स्वीकार करता है. आपको 200 OK रिस्पॉन्स मिलता है. साथ ही, RBM प्लैटफ़ॉर्म मैसेज को सेव करके रखता है और 30 दिनों तक उसे फिर से डिलीवर करने की कोशिश करता है. RBM से मैसेज को फिर से भेजने के लिए कहने की ज़रूरत नहीं है.
RBM, डिलीवर न किए गए मैसेज को सबमिट करने के 30 दिनों के बाद मिटा देता है.
आपके एजेंट के इस्तेमाल के उदाहरण के आधार पर, हो सकता है कि आपको 30 दिनों के टाइम आउट से पहले, डिलीवर नहीं किए गए मैसेज को वापस लेना हो. सर्टिफ़िकेट रद्द करने से, ऑफ़लाइन उपयोगकर्ताओं को पुराना मैसेज मिलने से रोका जा सकता है. ऐसा तब होता है, जब वे वापस ऑनलाइन आते हैं. मैसेज को वापस लेने के कई तरीके हैं:
- निलंबन हटाने का अनुरोध ट्रिगर करने के लिए, निलंबन हटाने का अनुरोध भेजें.
- मैसेज के अपने-आप मिटने की सुविधा सेट करें, ताकि मैसेज सही समय पर अपने-आप मिट जाए.
मैसेज के मिटने की समयसीमा सेट करना
क्या आपके एजेंट का मैसेज समय के हिसाब से ज़रूरी है? उदाहरण के लिए, ओटीपी सिर्फ़ कुछ समय के लिए मान्य होते हैं. कुछ समय के लिए उपलब्ध ऑफ़र खत्म हो जाते हैं. साथ ही, अपॉइंटमेंट की तारीख के बाद, अपॉइंटमेंट के रिमाइंडर काम के नहीं होते. मैसेज को समय पर और काम का बनाए रखने के लिए, मैसेज के खत्म होने की अवधि सेट करें. इससे ऑफ़लाइन उपयोगकर्ताओं को, ऑनलाइन होने पर पुराना कॉन्टेंट नहीं मिलता. कुकी के खत्म होने की तारीख भी, फ़ॉलबैक मैसेजिंग की रणनीति लागू करने का एक अच्छा तरीका है. इससे उपयोगकर्ताओं को समय पर ज़रूरी जानकारी मिल जाती है.
मैसेज के खत्म होने की अवधि सेट करने के लिए, एजेंट के मैसेज में इनमें से कोई एक फ़ील्ड तय करें:
expireTime
: यूटीसी में वह सटीक समय जब मैसेज की समयसीमा खत्म हो जाती है.ttl
(टाइम टू लिव): वह समय जिसके बाद मैसेज की समयसीमा खत्म हो जाती है.
फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, AgentMessage
देखें.
मैसेज की समयसीमा खत्म होने के बाद, RBM प्लैटफ़ॉर्म मैसेज डिलीवर करने की कोशिश करना बंद कर देता है. साथ ही, मैसेज अपने-आप रद्द हो जाता है. हालांकि, ऐसा बहुत कम होता है कि यह तरीका काम न करे. उदाहरण के लिए, ऐसा हो सकता है कि RBM प्लैटफ़ॉर्म मैसेज डिलीवर कर रहा हो और उसी दौरान एपीआई, ऐक्सेस रद्द करने की प्रोसेस शुरू कर दे. यह पुष्टि करने के लिए कि समयसीमा खत्म हो चुके मैसेज को रद्द किया गया है या नहीं, RBM आपके वेबुक को इवेंट की सूचना भेजेगा.
ttl
और expireTime
की ज़्यादा से ज़्यादा वैल्यू, मैसेज सबमिट करने के बाद 15 दिन होती है.
ttl
और expireTime
के लिए कोई कम से कम वैल्यू तय नहीं है. हालांकि, मैसेज सबमिट करने के बाद कम से कम 10 सेकंड तक इंतज़ार करने का सुझाव दिया जाता है. इससे, मैसेज वापस लेने और डिलीवर होने, दोनों की सूचना मिलने की संभावना काफ़ी कम हो जाती है.
मैसेज के ट्रैफ़िक का टाइप सेट करना
RBM API में, मैसेज को कैटगरी के हिसाब से बांटने के लिए messageTrafficType
फ़ील्ड शामिल होता है.
एजेंट के इस्तेमाल के उदाहरण से अब भी एजेंट के व्यवहार और लागू होने वाले कारोबारी नियमों के बारे में पता चलता है. हालांकि, messageTrafficType
की मदद से मैसेज के कॉन्टेंट को ज़्यादा बारीकी से कैटगरी में बांटा जा सकता है. इससे एक ही एजेंट को कई इस्तेमाल के उदाहरणों को हैंडल करने में मदद मिलेगी. फ़िलहाल, एजेंट के मौजूदा इस्तेमाल के उदाहरणों या कारोबार के नियमों पर कोई असर नहीं पड़ा है.
इस फ़ील्ड को सेट करना ज़रूरी नहीं है. हालांकि, हमारा सुझाव है कि आप इसे अभी सेट कर लें, ताकि जब यह फ़ील्ड ज़रूरी हो जाए, तब आपको कोई गड़बड़ी न मिले.
मैसेज के ट्रैफ़िक टाइप को सेट करने के लिए, हर मैसेज के कॉन्टेंट के आधार पर सही messageTrafficType
असाइन करें. RBM, इस तरह के ट्रैफ़िक के साथ काम करता है.
ट्रैफ़िक का प्रकार | मैसेज का कॉन्टेंट | एजेंट के इस्तेमाल का उदाहरण |
---|---|---|
AUTHENTICATION |
पुष्टि करने वाले ईमेल के लिए. | ओटीपी |
TRANSACTION |
किसी व्यक्ति की मौजूदा सेवाओं या प्रॉडक्ट के बारे में मैसेज पाने के लिए. उदाहरण के लिए: पुष्टि करने वाले ईमेल, पेमेंट की रसीदें या बुकिंग की जानकारी. | लेन-देन से जुड़ा या मल्टी-यूज़ |
PROMOTION |
प्रमोशन वाले मैसेज के लिए. जैसे, ऑफ़र, छूट, एलान या प्रमोशन वाला अन्य कॉन्टेंट. | प्रमोशन वाला या मल्टी-यूज़ |
SERVICEREQUEST |
उन सेवाओं के बारे में मैसेज भेजने के लिए जिनके लिए उपयोगकर्ता ने साफ़ तौर पर अनुरोध किया है. | ओटीपी, लेन-देन से जुड़ा, प्रमोशनल या एक से ज़्यादा बार इस्तेमाल किया जा सकने वाला |
ACKNOWLEDGEMENT |
इन ईमेल का इस्तेमाल, उपयोगकर्ता की कार्रवाई की पुष्टि करने के लिए किया जाता है. खास तौर पर, सदस्यता छोड़ने के अनुरोध की पुष्टि करने के लिए. इससे पुष्टि होती है कि उपयोगकर्ता का अनुरोध मिल गया है और उसे प्रोसेस किया जा रहा है. | ओटीपी, लेन-देन से जुड़ा, प्रमोशनल या एक से ज़्यादा बार इस्तेमाल किया जा सकने वाला |
अगर कोई ट्रैफ़िक टाइप सेट नहीं किया गया है, तो सिस्टम एजेंट के इस्तेमाल के उदाहरण के लिए डिफ़ॉल्ट टाइप असाइन करता है.
एजेंट के इस्तेमाल का उदाहरण | ट्रैफ़िक का डिफ़ॉल्ट टाइप |
---|---|
OTP | AUTHENTICATION |
लेन-देन से जुड़ी क्वेरी | TRANSACTION |
प्रमोशन से जुड़ा | PROMOTION |
एक से ज़्यादा बार इस्तेमाल किया जा सकता है | MESSAGE_TRAFFIC_TYPE_UNSPECIFIED |
एक से ज़्यादा कामों के लिए इस्तेमाल किए जाने वाले एजेंट के लिए, कोई डिफ़ॉल्ट ट्रैफ़िक टाइप नहीं होता. आपको हर मैसेज के लिए, ट्रैफ़िक टाइप साफ़ तौर पर सेट करना होगा. यह मैसेज के कॉन्टेंट के आधार पर तय किया जाता है. अगर MESSAGE_TRAFFIC_TYPE_UNSPECIFIED
वैल्यू को नहीं बदला जाता है, तो गड़बड़ी होगी.
ईमेल के साइज़ की सीमाएं
स्ट्रिंग के तौर पर सेव किए गए पूरे AgentMessage का साइज़ 250 केबी से ज़्यादा नहीं होना चाहिए. मैसेज के टेक्स्ट वाले हिस्से में ज़्यादा से ज़्यादा 3,072 वर्ण हो सकते हैं.
RBM के ज़रिए ज़्यादा से ज़्यादा 100 एमबी की फ़ाइल भेजी जा सकती है. ज़्यादा जानकारी के लिए, मीडिया और PDF फ़ाइलें लेख पढ़ें.
टेक्स्ट
सबसे आसान मैसेज, टेक्स्ट से बने होते हैं. टेक्स्ट मैसेज, ऐसी जानकारी देने के लिए सबसे सही होते हैं जिनमें विज़ुअल, जटिल इंटरैक्शन या जवाब की ज़रूरत नहीं होती.
उदाहरण
नीचे दिया गया कोड, सादा टेक्स्ट वाला मैसेज भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, phones.agentMessages.create
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!" }, "messageTrafficType": "PROMOTION" }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); let params = { messageText: 'Hello, world!', msisdn: '+12223334444', }; // Send a simple message to the device rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Send simple text message to user rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444" ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create a simple RBM text message message_text = messages.TextMessage('Hello, world!') # Send text message to the device messages.MessageCluster().append_message(message_text).send_to_msisdn('+12223334444')
C#
using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", );
बेसिक मैसेज का कॉन्टेंट - एसएमएस को मैसेज में बदलना
मोबाइल और इंटरनेट सेवा देने वाली कंपनियों ने, एसएमएस मैसेज को आरबीएम पर माइग्रेट करने के लिए बिलिंग मॉडल लॉन्च किए हैं. RBM मैसेज में ज़्यादा से ज़्यादा 160 UTF-8 वर्ण हो सकते हैं. इसे सामान्य मैसेज कहा जाता है.
बेसिक मैसेज भेजने का अनुरोध करते समय, ध्यान रखें कि वर्णों को 1 बाइट (UTF-8) के तौर पर गिना जाता है. अगर आपने कोई ऐसा मैसेज भेजा है जिसमें खास वर्ण शामिल हैं, जैसे कि इमोजी या मल्टी-बाइट वर्ण सेट, तो हर वर्ण को 2 से 4 या इससे ज़्यादा UTF-8 वर्णों के तौर पर गिना जाता है.
इस बॉक्स में कुछ टेक्स्ट डालें और देखें कि उसकी लंबाई कितनी है:
मैसेज का बुनियादी कॉन्टेंट और लिंक की झलक
आरसीएस क्लाइंट, लिंक की झलक दिखाने की सुविधा लागू कर सकते हैं. अगर सिर्फ़ टेक्स्ट वाले RBM मैसेज में, openGraph टैग वाली वेबसाइट का यूआरएल शामिल है, तो झलक वाली इमेज दिख सकती है. इससे ऐसा लगता है कि मैसेज में ज़्यादा कॉन्टेंट शामिल है.
ध्यान रखें कि आरसीएस क्लाइंट, उपयोगकर्ता को लिंक की झलक दिखाने की सुविधा बंद करने की अनुमति दे सकता है.
उपयोगकर्ता की पुष्टि के लिए, एक बार इस्तेमाल होने वाले पासवर्ड
एसएमएस वापस पाने वाले एपीआई के साथ, उपयोगकर्ता की पुष्टि अपने-आप करने के लिए, RBM का इस्तेमाल करके एक बार इस्तेमाल होने वाले पासवर्ड (ओटीपी) भेजे जा सकते हैं. RBM के ज़रिए मिले ओटीपी को पढ़ने के लिए, कोई खास एपीआई नहीं है.
Android के लिए यह सुविधा कैसे काम करती है
SMS Retriever API के साथ रजिस्टर किए गए Android ऐप्लिकेशन के लिए, यह एपीआई सही फ़ॉर्मैट वाले RBM मैसेज को सुनता है. इस मैसेज में, ओटीपी और एक यूनीक हैश होना चाहिए. इससे आपके ऐप्लिकेशन की पहचान होती है.
जब सही फ़ॉर्मैट में RBM मैसेज मिलता है, तो SMS Retriever API उसे उसी तरह प्रोसेस करता है जिस तरह वह एसएमएस ओटीपी को प्रोसेस करता है. जब हैश आपके ऐप्लिकेशन से मैच हो जाता है, तब ओटीपी निकाल लिया जाता है. इसके बाद, इसे आपके ऐप्लिकेशन पर भेज दिया जाता है, ताकि उपयोगकर्ता की पुष्टि अपने-आप हो सके.
- उपयोगकर्ता की पुष्टि के लिए, RBM का टेक्स्ट मैसेज का सैंपल:
Your code is <OTP> <app hash>.
- उदाहरण:
Your code is 123456 M8tue43FGT.
एसएमएस रिट्रीवर और इससे जुड़े एपीआई के बारे में ज़्यादा जानने के लिए, एसएमएस रिट्रीवर का दस्तावेज़ देखें. SMS Retriever API के साथ रजिस्टर किए गए ऐप्लिकेशन में, उपयोगकर्ता की पुष्टि अपने-आप होने की सुविधा के बारे में जानने के लिए, यह फ़्लो डायग्राम देखें.
iOS के लिए यह सुविधा कैसे काम करती है
iOS के लिए, सिस्टम में पहले से मौजूद ओटीपी हैंडलिंग की सुविधा, एसएमएस ओटीपी की तरह ही, अपने-आप भरने के लिए RBM ओटीपी का पता लगाती है और उनका सुझाव देती है. iOS ऐप्लिकेशन को ओटीपी पढ़ने के लिए, किसी खास एपीआई इंटिग्रेशन की ज़रूरत नहीं होती.
मीडिया और PDF फ़ाइलें
अगर आपको किसी इमेज, वीडियो, ऑडियो या PDF फ़ाइल के साथ कोई मैसेज भेजना है, तो आपके एजेंट को कॉन्टेंट का ऐसा यूआरएल देना होगा जिसे सार्वजनिक तौर पर ऐक्सेस किया जा सकता हो. इसके अलावा, वह फ़ाइल को सीधे तौर पर अपलोड भी कर सकता है. मीडिया फ़ाइलों के लिए, थंबनेल इमेज भी तय की जा सकती है. इससे लोग, कॉन्टेंट पर क्लिक करने से पहले उसकी झलक देख पाते हैं. ऑडियो फ़ाइलों के लिए, डिफ़ॉल्ट ऑडियो विजेट का इस्तेमाल प्लेसहोल्डर के तौर पर किया जाता है.
RBM प्लैटफ़ॉर्म, फ़ाइलों को 60 दिनों के लिए कैश मेमोरी में सेव करता है. साथ ही, एपीआई एक फ़ाइल आईडी दिखाता है. आपका एजेंट, इस फ़ाइल आईडी को लोगों को भेजे जाने वाले मैसेज में शामिल कर सकता है. RBM, 60 दिनों के बाद फ़ाइलों को कैश मेमोरी से हटा देता है.
यूआरएल के हिसाब से फ़ाइलें तय करते समय, contentMessage.forceRefresh
को false
पर सेट करना सबसे सही तरीका है. contentMessage.forceRefresh
को true
पर सेट करने से, RBM को तय किए गए यूआरएल से नया कॉन्टेंट फ़ेच करना पड़ता है. भले ही, यूआरएल का कॉन्टेंट कैश मेमोरी में सेव हो. इससे उपयोगकर्ताओं को मैसेज मिलने में ज़्यादा समय लगता है.
फ़ाइल के साइज़ से जुड़े सुझावों और सीमाओं के बारे में जानने के लिए, सबसे सही तरीके देखें.
फ़ाइल के यूआरएल का उदाहरण
नीचे दिया गया कोड, एक इमेज भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, AgentContentMessage
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "contentInfo": { "fileUrl": "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif", "forceRefresh": false } } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); let params = { fileUrl: 'http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif', msisdn: '+12223334444', }; // Send an image/video to a device rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.AgentContentMessage; import com.google.api.services.rcsbusinessmessaging.v1.model.AgentMessage; import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); String fileUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif"; // create media only message AgentContentMessage agentContentMessage = new AgentContentMessage(); agentContentMessage.setContentInfo(new ContentInfo().setFileUrl(fileUrl)); // attach content to message AgentMessage agentMessage = new AgentMessage(); agentMessage.setContentMessage(agentContentMessage); rbmApiHelper.sendAgentMessage(agentMessage, "+12223334444"); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create media file attachment file_message = messages.FileMessage('http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif') messages.MessageCluster().append_message(file_message).send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); string fileUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif"; // Create content info with the file url ContentInfo contentInfo = new ContentInfo { FileUrl = fileUrl }; // Attach content info to a message AgentContentMessage agentContentMessage = new AgentContentMessage { ContentInfo = contentInfo, }; // Attach content to message AgentMessage agentMessage = new AgentMessage { ContentMessage = agentContentMessage }; rbmApiHelper.SendAgentMessage(agentMessage, "+12223334444");
इसके अलावा, files.create
का इस्तेमाल करके, मैसेज में मीडिया भेजने से पहले उसे अपलोड किया जा सकता है.
फ़ाइल अपलोड करने का उदाहरण
नीचे दिए गए कोड से, वीडियो फ़ाइल और थंबनेल फ़ाइल अपलोड की जाती है. इसके बाद, दोनों फ़ाइलों को मैसेज में भेजा जाता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, files.create
और AgentContentMessage
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/upload/v1/files?agentId=AGENT_ID" \ -H "Content-Type: video/mp4" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ --upload-file "FULL_PATH_TO_VIDEO_MEDIA_FILE"
# Capture server-specified video file name from response body JSON
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/upload/v1/files?agentId=AGENT_ID" \ -H "Content-Type: image/jpeg" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ --upload-file "FULL_PATH_TO_THUMBNAIL_MEDIA_FILE"
# Capture server-specified image file name from response body JSON
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "uploadedRbmFile": { "fileName": "SERVER-SPECIFIED_VIDEO_FILE_NAME", "thumbnailName": "SERVER-SPECIFIED_THUMBNAIL_FILE_NAME" } } }'
इस्तेमाल किए जा सकने वाले मीडिया टाइप
RBM में इन मीडिया टाइप का इस्तेमाल किया जा सकता है. थंबनेल के लिए, सिर्फ़ image/jpeg, image/jpg, image/gif, और image/png फ़ॉर्मैट इस्तेमाल किए जा सकते हैं.
मीडिया टाइप | दस्तावेज़ का टाइप | Extension | रिच कार्ड के साथ काम करता है |
---|---|---|---|
application/ogg | OGG ऑडियो | .ogx | नहीं |
application/pdf | नहीं | ||
audio/aac | AAC ऑडियो | .aac | नहीं |
audio/mp3 | MP3 ऑडियो | .mp3 | नहीं |
audio/mpeg | MPEG ऑडियो | .mpeg | नहीं |
audio/mpg | MPG ऑडियो | .mp3 | नहीं |
audio/mp4 | MP4 ऑडियो | .mp4 | नहीं |
audio/mp4-latm | MP4-latm ऑडियो | .mp4 | नहीं |
audio/3gpp | 3GPP ऑडियो | .3gp | नहीं |
image/jpeg | JPEG | .jpeg, .jpg | हां |
image/gif | GIF | .gif | हां |
image/png | PNG | .png | हां |
video/h263 | H263 वीडियो | .h263 | हां |
video/m4v | M4V वीडियो | .m4v | हां |
video/mp4 | MP4 वीडियो | .mp4 | हां |
video/mpeg4 | MPEG-4 वीडियो | .mp4, .m4p | हां |
video/mpeg | MPEG वीडियो | .mpeg | हां |
video/webm | WEBM वीडियो | .webm | हां |
सुझाव
आपका एजेंट, सुझाव वाले चिप की सूचियों (ज़्यादा से ज़्यादा 11 सुझाव) या रिच कार्ड (ज़्यादा से ज़्यादा चार सुझाव) में सुझाव (जवाब और कार्रवाइयों के सुझाव) भेजता है.
हर सुझाव में ज़्यादा से ज़्यादा 25 वर्ण होने चाहिए.
सुझाए गए जवाब
सुझाए गए जवाबों की मदद से, उपयोगकर्ता बातचीत कर पाते हैं. ये ऐसे जवाब होते हैं जिनके बारे में आपके एजेंट को पता होता है कि उसे कैसे जवाब देना है.
जब कोई उपयोगकर्ता सुझाए गए जवाब पर टैप करता है, तो आपके एजेंट को एक इवेंट मिलता है. इसमें जवाब का टेक्स्ट और पोस्टबैक डेटा शामिल होता है. पे लोड में ज़्यादा से ज़्यादा 2048 वर्ण हो सकते हैं.
उदाहरण
नीचे दिए गए कोड में, दो सुझाए गए जवाबों के साथ टेक्स्ट भेजा गया है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, SuggestedReply
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "reply": { "text": "Suggestion #1", "postbackData": "suggestion_1" } }, { "reply": { "text": "Suggestion #2", "postbackData": "suggestion_2" } } ] } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); let suggestions = [ { reply: { 'text': 'Suggestion #1', 'postbackData': 'suggestion_1', }, }, { reply: { 'text': 'Suggestion #2', 'postbackData': 'suggestion_2', }, }, ]; let params = { messageText: 'Hello, world!', msisdn: '+12223334444', suggestions: suggestions, }; // Send a simple message with suggestion chips to the device rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; import com.google.rbm.SuggestionHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); suggestions.add( new SuggestionHelper("Suggestion #1", "suggestion_1").getSuggestedReply()); suggestions.add( new SuggestionHelper("Suggestion #2", "suggestion_2").getSuggestedReply()); // Send simple text message to user rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create text message to send to user text_msg = messages.TextMessage('Hello, world!') cluster = messages.MessageCluster().append_message(text_msg) # Append suggested replies for the message to send to the user cluster.append_suggestion_chip(messages.SuggestedReply('Suggestion #1', 'reply:suggestion_1')) cluster.append_suggestion_chip(messages.SuggestedReply('Suggestion #2', 'reply:suggestion_2')) # Send a simple message with suggestion chips to the device cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); List<Suggestion> suggestions = new List<Suggestion> { // Create suggestion chips new SuggestionHelper("Suggestion #1", "suggestion_1").SuggestedReply(), new SuggestionHelper("Suggestion #2", "suggestion_2").SuggestedReply() }; // Send simple text message with suggestions to user rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", suggestions );
सुझाई गई कार्रवाइयाँ
सुझाई गई कार्रवाइयों की मदद से, उपयोगकर्ता अपने डिवाइसों में मौजूद सुविधाओं का इस्तेमाल करके बातचीत कर सकते हैं. आपका एजेंट, उपयोगकर्ताओं को कोई नंबर डायल करने, मैप पर कोई जगह खोलने, जगह की जानकारी शेयर करने, कोई यूआरएल खोलने या कैलेंडर इवेंट बनाने का सुझाव दे सकता है.
सुझाए गए हर ऐक्शन के लिए, फ़ॉलबैक यूआरएल (ज़्यादा से ज़्यादा 2048 वर्ण) दिया जा सकता है. हालांकि, ऐसा करना ज़रूरी नहीं है. अगर उपयोगकर्ता के डिवाइस पर सुझाई गई कार्रवाई काम नहीं करती है, तो यह यूआरएल नई ब्राउज़र विंडो में खुलेगा.
जब कोई उपयोगकर्ता सुझाई गई कार्रवाई पर टैप करता है, तो आपके एजेंट को एक इवेंट मिलता है. इसमें कार्रवाई का पोस्टबैक डेटा होता है.
फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, SuggestedAction
देखें.
नंबर डायल करें
डायल ऐक्शन की मदद से, उपयोगकर्ता को आपके एजेंट की ओर से दिए गए फ़ोन नंबर को डायल करने का तरीका बताया जाता है.
फ़ोन नंबर में सिर्फ़ अंक (0-9
), प्लस का निशान (+
), तारा चिह्न (*
), और हैशटैग (#
) शामिल किए जा सकते हैं. E.164 अंतरराष्ट्रीय फ़ॉर्मैट (उदाहरण के लिए, +14155555555
) इस्तेमाल किया जा सकता है, लेकिन यह ज़रूरी नहीं है. इसका मतलब है कि +14155555555
और 1011
, दोनों मान्य एंट्री हैं.
उदाहरण
नीचे दिया गया कोड, डायल करने की कार्रवाई शुरू करता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, DialAction
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "action": { "text": "Call", "postbackData": "postback_data_1234", "fallbackUrl": "https://www.google.com/contact/", "dialAction": { "phoneNumber": "+15556667777" } } } ] } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Define a dial suggested action let suggestions = [ { action: { text: 'Call', postbackData: 'postback_data_1234', dialAction: { phoneNumber: '+15556667777' } } }, ]; let params = { messageText: 'Hello, world!', msisdn: '+12223334444', suggestions: suggestions, }; // Send a simple message with a dial suggested action rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.DialAction; import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); // creating a dial suggested action DialAction dialAction = new DialAction(); dialAction.setPhoneNumber("+15556667777"); // creating a suggested action based on a dial action SuggestedAction suggestedAction = new SuggestedAction(); suggestedAction.setText("Call"); suggestedAction.setPostbackData("postback_data_1234"); suggestedAction.setDialAction(dialAction); // attaching action to a suggestion Suggestion suggestion = new Suggestion(); suggestion.setAction(suggestedAction); suggestions.add(suggestion); // Send simple text message with the suggestion action rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create a dial suggested action suggestions = [ messages.DialAction('Call', 'reply:postback_data_1234', '+15556667777') ] # Create text message to send to user text_msg = messages.TextMessage('Hello, world!') cluster = messages.MessageCluster().append_message(text_msg) # Append suggestions for the message to send to the user for suggestion in suggestions: cluster.append_suggestion_chip(suggestion) # Send a simple message with suggested action to the device cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Create a dial an agent suggested action DialAction dialAction = new DialAction { PhoneNumber = "+15556667777" }; // Creating a suggested action based on a dial action SuggestedAction suggestedAction = new SuggestedAction { Text = "Call", PostbackData = "postback_data_1234", DialAction = dialAction }; // Attach action to a suggestion Suggestion suggestion = new Suggestion { Action = suggestedAction }; List<Suggestion> suggestions = new List<Suggestion> { suggestion }; rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", suggestions );
किसी जगह की जानकारी देखना
'जगह की जानकारी देखें' कार्रवाई से, उपयोगकर्ता के डिफ़ॉल्ट मैप ऐप्लिकेशन में जगह की जानकारी दिखती है. जगह की जानकारी को अक्षांश और देशांतर के हिसाब से या उपयोगकर्ता की मौजूदा जगह के हिसाब से क्वेरी के आधार पर तय किया जा सकता है. मैप ऐप्लिकेशन में दिखने वाले पिन के लिए, कस्टम लेबल भी सेट किया जा सकता है.
उदाहरण
यहां दिया गया कोड, जगह की जानकारी देखने की कार्रवाई को भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, ViewLocationAction
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "action": { "text": "View map", "postbackData": "postback_data_1234", "fallbackUrl": "https://www.google.com/maps/@37.4220188,-122.0844786,15z", "viewLocationAction": { "latLong": { "latitude": "37.4220188", "longitude": "-122.0844786" }, "label": "Googleplex" } } } ] } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Define a view location suggested action let suggestions = [ { action: { text: 'View map', postbackData: 'postback_data_1234', viewLocationAction: { latLong: { latitude: 37.4220188, longitude: -122.0844786 }, label: 'Googleplex' } } }, ]; let params = { messageText: 'Hello, world!', msisdn: '+12223334444', suggestions: suggestions, }; // Send a simple message with a view location suggested action rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.ViewLocationAction; import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); // creating a view location suggested action ViewLocationAction viewLocationAction = new ViewLocationAction(); viewLocationAction.setQuery("Googleplex, Mountain View, CA"); // creating a suggested action based on a view location action SuggestedAction suggestedAction = new SuggestedAction(); suggestedAction.setText("View map"); suggestedAction.setPostbackData("postback_data_1234"); suggestedAction.setViewLocationAction(viewLocationAction); // attaching action to a suggestion Suggestion suggestion = new Suggestion(); suggestion.setAction(suggestedAction); suggestions.add(suggestion); // Send simple text message with the suggestion action rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create a view location suggested action suggestions = [ messages.ViewLocationAction('View map', 'reply:postback_data_1234', query='Googleplex, Mountain View, CA') ] # Create text message to send to user text_msg = messages.TextMessage('Hello, world!') cluster = messages.MessageCluster().append_message(text_msg) # Append suggestions for the message to send to the user for suggestion in suggestions: cluster.append_suggestion_chip(suggestion) # Send a simple message with suggested action to the device cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // create an view location action ViewLocationAction viewLocationAction = new ViewLocationAction { Query = "Googleplex Mountain View, CA" }; // Attach the view location action to a suggested action SuggestedAction suggestedAction = new SuggestedAction { ViewLocationAction = viewLocationAction, Text = "View map", PostbackData = "postback_data_1234" }; // Attach the action to a suggestion object Suggestion suggestion = new Suggestion { Action = suggestedAction }; List<Suggestion> suggestions = new List<Suggestion> { suggestion }; rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", suggestions );
कोई स्थान शेयर करें
'जगह की जानकारी शेयर करें' कार्रवाई की मदद से, उपयोगकर्ता आपके एजेंट के साथ जगह की जानकारी शेयर कर सकता है. उपयोगकर्ता, Maps ऐप्लिकेशन से अपनी मौजूदा जगह की जानकारी या मैन्युअल तरीके से चुनी गई जगह की जानकारी शेयर कर सकता है.
उदाहरण
यहां दिया गया कोड, जगह की जानकारी शेयर करने की कार्रवाई को भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, ShareLocationAction
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "action": { "text": "Share your location", "postbackData": "postback_data_1234", "shareLocationAction": {} } } ] } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Define a share location suggested action let suggestions = [ { action: { text: 'Share your location', postbackData: 'postback_data_1234', shareLocationAction: { } } }, ]; let params = { messageText: 'Hello, world!', msisdn: '+12223334444', suggestions: suggestions, }; // Send a simple message with a share location suggested action rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.ShareLocationAction; import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); // creating a share location suggested action ShareLocationAction shareLocationAction = new ShareLocationAction(); // creating a suggested action based on a share location action SuggestedAction suggestedAction = new SuggestedAction(); suggestedAction.setText("Share location"); suggestedAction.setPostbackData("postback_data_1234"); suggestedAction.setShareLocationAction(shareLocationAction); // attaching action to a suggestion Suggestion suggestion = new Suggestion(); suggestion.setAction(suggestedAction); suggestions.add(suggestion); // Send simple text message with the suggestion action rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create a share location suggested action suggestions = [ messages.ShareLocationAction('Share location', 'reply:postback_data_1234') ] # Create text message to send to user text_msg = messages.TextMessage('Hello, world!') cluster = messages.MessageCluster().append_message(text_msg) # Append suggestions for the message to send to the user for suggestion in suggestions: cluster.append_suggestion_chip(suggestion) # Send a simple message with suggested action to the device cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Create a share location action ShareLocationAction shareLocationAction = new ShareLocationAction(); // Attach the share location action to a suggested action SuggestedAction suggestedAction = new SuggestedAction { ShareLocationAction = shareLocationAction, Text = "Share location", PostbackData = "postback_data_1234" }; // Attach the action to a suggestion object Suggestion suggestion = new Suggestion { Action = suggestedAction }; List<Suggestion> suggestions = new List<Suggestion> { suggestion }; rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", suggestions );
कोई यूआरएल खोलना
यूआरएल खोलने की कार्रवाई की मदद से, उपयोगकर्ताओं को आपके एजेंट की ओर से तय किए गए वेब पेज पर भेजा जा सकता है. डिफ़ॉल्ट रूप से, वेब पेज उपयोगकर्ता के ब्राउज़र में खुलता है. अगर किसी उपयोगकर्ता ने वेब पेज के लिए कोई डिफ़ॉल्ट ऐप्लिकेशन कॉन्फ़िगर किया है, तो वह ऐप्लिकेशन खुलेगा. ऐसे में, सुझाए गए ऐक्शन बटन पर मौजूद आइकॉन, ऐप्लिकेशन का आइकॉन होगा.
यूआरएल खोलने की कार्रवाई, इंटिग्रेटेड वेबव्यू के साथ भी काम करती है. इसके बारे में जानने के लिए, वेबव्यू के साथ यूआरएल खोलना लेख पढ़ें.
उदाहरण
यहां दिया गया कोड, 'यूआरएल खोलें' कार्रवाई को ट्रिगर करता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, OpenUrlAction
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "action": { "text": "Open Google", "postbackData": "postback_data_1234", "openUrlAction": { "url": "https://www.google.com" } } } ] } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Define an open URL suggested action let suggestions = [ { action: { text: 'Open Google', postbackData: 'postback_data_1234', openUrlAction: { url: 'https://www.google.com' } } }, ]; let params = { messageText: 'Hello, world!', msisdn: '+12223334444', suggestions: suggestions, }; // Send a simple message with an open URL suggested action rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.OpenUrlAction; import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); // creating an open url suggested action OpenUrlAction openUrlAction = new OpenUrlAction(); openUrlAction.setUrl("https://www.google.com"); // creating a suggested action based on an open url action SuggestedAction suggestedAction = new SuggestedAction(); suggestedAction.setText("Open Google"); suggestedAction.setPostbackData("postback_data_1234"); suggestedAction.setOpenUrlAction(openUrlAction); // attaching action to a suggestion Suggestion suggestion = new Suggestion(); suggestion.setAction(suggestedAction); suggestions.add(suggestion); // Send simple text message with the suggestion action rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create an open url suggested action suggestions = [ messages.OpenUrlAction('Open Google', 'reply:postback_data_1234', 'https://www.google.com') ] # Create text message to send to user text_msg = messages.TextMessage('Hello, world!') cluster = messages.MessageCluster().append_message(text_msg) # Append suggestions for the message to send to the user for suggestion in suggestions: cluster.append_suggestion_chip(suggestion) # Send a simple message with suggested action to the device cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Create an open url action OpenUrlAction openUrlAction = new OpenUrlAction { Url = "https://www.google.com" }; // Attach the open url action to a suggested action SuggestedAction suggestedAction = new SuggestedAction { OpenUrlAction = openUrlAction, Text = "Open Google", PostbackData = "postback_data_1234" }; // Attach the action to a suggestion object Suggestion suggestion = new Suggestion { Action = suggestedAction }; List<Suggestion> suggestions = new List<Suggestion> { suggestion }; rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", suggestions );
वेबव्यू की मदद से यूआरएल खोलना
वेबव्यू के साथ यूआरएल खोलने की सुविधा, आपके डिफ़ॉल्ट ब्राउज़र के रेंडरिंग इंजन की मदद से, मैसेजिंग ऐप्लिकेशन में बताए गए वेब पेज को लोड करती है. इससे उपयोगकर्ता, RBM बातचीत को छोड़े बिना वेब पेज से इंटरैक्ट कर सकता है. अगर उपयोगकर्ता के डिवाइस पर वेबव्यू काम नहीं करता है, तो वेब पेज, उपयोगकर्ता के ब्राउज़र में खुलता है. वेबव्यू चालू करने के लिए, OpenURLApplication
देखें.
वेबव्यू को तीन डिसप्ले मोड में दिखाया जा सकता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, WebviewViewMode
देखें.
- फ़ुल: वेब पेज पूरी स्क्रीन पर दिखता है
- आधा: वेब पेज, स्क्रीन के आधे हिस्से पर दिखता है
- लंबा: वेब पेज, स्क्रीन के तीन-चौथाई हिस्से पर दिखता है
उदाहरण
यहां दिया गया कोड, वेबव्यू ऐक्शन के साथ Open URL भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, OpenURLAction
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "action": { "text": "Open Google", "postbackData": "postback_data_1234", "openUrlAction": { "url": "https://www.google.com", "application": "WEBVIEW", "webviewViewMode": "FULL", "description": "Accessibility description" } } } ] } }'
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.OpenUrlAction; import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; … try { String URL = "https://www.google.com"; // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); // Create suggestion to view webpage in full mode Suggestion viewInFullMode = getUrlActionInWebview(URL, "FULL") suggestions.add(viewInFullMode); // create suggestion to view webpage in half mode Suggestion viewInHalfMode = getUrlActionInWebview(URL, "HALF") suggestions.add(viewInHalfMode); // create suggestion to view webpage in tall mode Suggestion viewInTallMode = getUrlActionInWebview(URL, "TALL") suggestions.add(viewInTallMode); // Send simple text message with the suggested action rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); } /** * Creates a suggested action to open URL in webview. * * @return a suggestion object for an open URL in webview action . */ private Suggestion getUrlActionInWebview(String url, String viewMode) { // create an open url action OpenUrlAction openUrlAction = new OpenUrlAction(); openUrlAction.setUrl(url); openUrlAction.setApplication("WEBVIEW"); openUrlAction.setWebviewViewMode(viewMode); openUrlAction.setDescription("Accessibility description"); // attach the open url action to a suggested action SuggestedAction suggestedAction = new SuggestedAction(); suggestedAction.setOpenUrlAction(openUrlAction); suggestedAction.setText('display_text'); suggestedAction.setPostbackData('postback_data_123'); // attach the action to a suggestion object Suggestion suggestion = new Suggestion(); suggestion.setAction(suggestedAction); return suggestion; }
कैलेंडर इवेंट बनाना
'कैलेंडर इवेंट बनाएं' ऐक्शन से, उपयोगकर्ता का कैलेंडर ऐप्लिकेशन खुल जाता है. साथ ही, दी गई जानकारी के साथ एक नया इवेंट बनना शुरू हो जाता है.
कैलेंडर इवेंट का टाइटल डालना ज़रूरी है. इसमें ज़्यादा से ज़्यादा 100 वर्ण हो सकते हैं. कैलेंडर इवेंट का ब्यौरा देना ज़रूरी नहीं है. इसमें ज़्यादा से ज़्यादा 500 वर्ण हो सकते हैं.
उदाहरण
नीचे दिया गया कोड, कैलेंडर इवेंट बनाने का ऐक्शन भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, CreateCalendarEventAction
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "text": "Hello, world!", "suggestions": [ { "action": { "text": "Save to calendar", "postbackData": "postback_data_1234", "fallbackUrl": "https://www.google.com/calendar", "createCalendarEventAction": { "startTime": "2020-06-30T19:00:00Z", "endTime": "2020-06-30T20:00:00Z", "title": "My calendar event", "description": "Description of the calendar event" } } } ] } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Define a create calendar event suggested action let suggestions = [ { action: { text: 'Save to calendar', postbackData: 'postback_data_1234', createCalendarEventAction: { startTime: '2020-06-30T19:00:00Z', endTime: '2020-06-30T20:00:00Z', title: 'My calendar event', description: 'Description of the calendar event', }, } }, ]; let params = { messageText: 'Hello, world!', msisdn: '+12223334444', suggestions: suggestions, }; // Send a simple message with a create calendar event suggested action rbmApiHelper.sendMessage(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.CreateCalendarEventAction; import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.RbmApiHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); // creating a create calendar event suggested action CreateCalendarEventAction createCalendarEventAction = new CreateCalendarEventAction(); calendarEventAction.setTitle("My calendar event"); calendarEventAction.setDescription("Description of the calendar event"); calendarEventAction.setStartTime("2020-06-30T19:00:00Z"); calendarEventAction.setEndTime("2020-06-30T20:00:00Z"); // creating a suggested action based on a create calendar event action SuggestedAction suggestedAction = new SuggestedAction(); suggestedAction.setText("Save to calendar"); suggestedAction.setPostbackData("postback_data_1234"); suggestedAction.setCreateCalendarEventAction(createCalendarEventAction); // attaching action to a suggestion Suggestion suggestion = new Suggestion(); suggestion.setAction(suggestedAction); suggestions.add(suggestion); // Send simple text message with the suggestion action rbmApiHelper.sendTextMessage( "Hello, world!", "+12223334444", suggestions ); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Create a calendar event suggested action suggestions = [ messages.CreateCalendarEventAction('Save to Calendar', 'reply:postback_data_1234', '2020-06-30T19:00:00Z', '2020-06-30T20:00:00Z', 'My calendar event', 'Description of the calendar event') ] # Create text message to send to user text_msg = messages.TextMessage('Hello, world!') cluster = messages.MessageCluster().append_message(text_msg) # Append suggestions for the message to send to the user for suggestion in suggestions: cluster.append_suggestion_chip(suggestion) # Send a simple message with suggested action to the device cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Create a calendar event action CreateCalendarEventAction calendarEventAction = new CreateCalendarEventAction { Title = "My calendar event", Description = "Description of the calendar event", StartTime = "2020-06-30T19:00:00Z", EndTime = "2020-06-30T20:00:00Z" }; // Attach the calendar event action to a suggested action SuggestedAction suggestedAction = new SuggestedAction { CreateCalendarEventAction = calendarEventAction, Text = "Save to calendar", PostbackData = "postback_data_1234" }; // Attach the action to a suggestion object Suggestion suggestion = new Suggestion { Action = suggestedAction }; List<Suggestion> suggestions = new List<Suggestion> { suggestion }; rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", suggestions );
सुझाव वाले चिप की सूची
आपका एजेंट, उपयोगकर्ताओं को आगे की कार्रवाइयों के बारे में बताने के लिए, मैसेज के साथ सुझाव वाले चिप की सूचियां भेजता है. चिप की सूची सिर्फ़ तब दिखती है, जब उससे जुड़ा मैसेज बातचीत में सबसे नीचे हो. बातचीत में इसके बाद भेजे गए मैसेज (उपयोगकर्ता या आपके एजेंट में से किसी के भी) से, चिप की सूची बदल जाती है.
सूची में मौजूद चिप, सुझाए गए जवाब और सुझाई गई कार्रवाइयां हैं.
चिप वाली सूचियों में ज़्यादा से ज़्यादा 11 सुझाव वाली चिप होती हैं. साथ ही, हर चिप के लेबल में ज़्यादा से ज़्यादा 25 वर्ण हो सकते हैं.
फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, AgentContentMessage
देखें.
रिच कार्ड
जब आपको एक साथ कई तरह की जानकारी, मीडिया या सुझाव भेजने हों, तो आपको रिच कार्ड भेजना चाहिए. रिच कार्ड की मदद से, आपका एजेंट एक ही मैसेज में कई तरह की जानकारी भेज सकता है.
रिच कार्ड में ये आइटम शामिल हो सकते हैं:
- कोई इमेज या वीडियो
- टाइटल का टेक्स्ट
- विवरण टेक्स्ट
- सुझाए गए जवाब और सुझाई गई कार्रवाइयां (ज़्यादा से ज़्यादा चार)
रिच कार्ड में यहां दी गई सभी चीज़ें शामिल हो सकती हैं. हालांकि, किसी कार्ड में कम से कम एक इमेज, वीडियो या टाइटल होना ज़रूरी है, ताकि उसे मान्य माना जा सके. रिच कार्ड में ज़्यादा से ज़्यादा चार सुझाई गई कार्रवाइयां और सुझाए गए जवाब शामिल किए जा सकते हैं.
आपका एजेंट, एक साथ कई रिच कार्ड भेज सकता है. इसके लिए, उसे रिच कार्ड कैरसेल का इस्तेमाल करना होगा.
रिच कार्ड के पेलोड का साइज़ ज़्यादा से ज़्यादा 250 केबी हो सकता है. मीडिया फ़ाइल के साइज़ के बारे में सुझाव पाने और उसकी सीमाएं जानने के लिए, सबसे सही तरीके देखें.
रिच कार्ड की खास बातें, रिच कार्ड में देखी जा सकती हैं.
कार्ड की ऊंचाई
कार्ड, कॉन्टेंट के हिसाब से वर्टिकल तौर पर बड़े हो जाते हैं. रिच कार्ड की कम से कम ऊंचाई 112 डीपी और ज़्यादा से ज़्यादा ऊंचाई 344 डीपी होती है. अगर कार्ड का कॉन्टेंट, कार्ड की कम से कम ऊंचाई को भरने के लिए काफ़ी नहीं है, तो कार्ड बड़ा हो जाता है और अतिरिक्त ऊंचाई को वाइटस्पेस से भर देता है.
रिच कार्ड में मौजूद मीडिया की लंबाई इनमें से किसी एक के हिसाब से होनी चाहिए:
- छोटा: 112 डीपी
- मीडियम: 168 डीपी
- लंबा: 264 डीपी
अगर चुनी गई ऊंचाई के हिसाब से कार्ड में मीडिया के डाइमेंशन फ़िट नहीं होते हैं, तो मीडिया को ज़ूम और क्रॉप करके उसकी झलक दिखाई जाती है.
उदाहरण
नीचे दिया गया कोड, इमेज और सुझाए गए जवाबों के साथ एक रिच कार्ड भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, RichCard
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "richCard": { "standaloneCard": { "thumbnailImageAlignment": "RIGHT", "cardOrientation": "VERTICAL", "cardContent": { "title": "Hello, world!", "description": "RBM is awesome!", "media": { "height": "TALL", "contentInfo":{ "fileUrl": "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif", "forceRefresh": false } }, "suggestions": [ { "reply": { "text": "Suggestion #1", "postbackData": "suggestion_1" } }, { "reply": { "text": "Suggestion #2", "postbackData": "suggestion_2" } } ] } } } } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Suggested replies to be used in the card let suggestions = [ { reply: { 'text': 'Suggestion #1', 'postbackData': 'suggestion_1', }, }, { reply: { 'text': 'Suggestion #2', 'postbackData': 'suggestion_2', }, }, ]; // Image to be displayed by the card let imageUrl = 'http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif'; // Definition of the card parameters let params = { messageText: 'Hello, world!', messageDescription: 'RBM is awesome!', msisdn: '+12223334444', suggestions: suggestions, imageUrl: imageUrl, height: 'TALL', }; // Send rich card to device rbmApiHelper.sendRichCard(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.StandaloneCard; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.cards.CardOrientation; import com.google.rbm.cards.MediaHeight; import com.google.rbm.RbmApiHelper; import com.google.rbm.SuggestionHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Create suggestions for chip list List<Suggestion> suggestions = new ArrayList<Suggestion>(); suggestions.add( new SuggestionHelper("Suggestion #1", "suggestion_1").getSuggestedReply()); suggestions.add( new SuggestionHelper("Suggestion #2", "suggestion_2").getSuggestedReply()); String imageUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif"; // Create a standalone rich card to send to the user StandaloneCard standaloneCard = rbmApiHelper.createStandaloneCard( "Hello, world!", "RBM is awesome!", imageUrl, MediaHeight.MEDIUM, CardOrientation.VERTICAL, suggestions ); rbmApiHelper.sendStandaloneCard(standaloneCard, "+12223334444"); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Suggested replies to be used in the card suggestions = [ messages.SuggestedReply('Suggestion #1', 'reply:suggestion_1'), messages.SuggestedReply('Suggestion #2', 'reply:suggestion_2') ] # Image to be displayed by the card image_url = 'http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif'; # Define rich card structure rich_card = messages.StandaloneCard('VERTICAL', 'Hello, world!', 'RBM is awesome!', suggestions, image_url, None, None, 'MEDIUM') # Append rich card and send to the user cluster = messages.MessageCluster().append_message(rich_card) cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; using RCSBusinessMessaging.Cards; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); List<Suggestion> suggestions = new List<Suggestion> { // Create suggestion chips new SuggestionHelper("Suggestion #1", "suggestion_1").SuggestedReply(), new SuggestionHelper("Suggestion #2", "suggestion_2").SuggestedReply() }; string imageUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif"; // Create rich card with suggestions StandaloneCard standaloneCard = rbmApiHelper.CreateStandaloneCard( "Hello, world!", "RBM is awesome", imageUrl, MediaHeight.TALL, CardOrientation.VERTICAL, suggestions ); // Send rich card to user rbmApiHelper.SendStandaloneCard(standaloneCard, "+12223334444");
रिच कार्ड कैरसेल
जब आपको किसी व्यक्ति को चुनने के लिए कई विकल्प दिखाने हों, तो रिच कार्ड कैरसेल का इस्तेमाल करें. कैरसेल में कई रिच कार्ड एक साथ दिखाए जाते हैं. इससे लोग, आइटम की तुलना कर पाते हैं और हर आइटम पर अलग-अलग प्रतिक्रिया दे पाते हैं.
कैरसेल में कम से कम दो और ज़्यादा से ज़्यादा दस रिच कार्ड हो सकते हैं. कैरसेल में मौजूद रिच कार्ड, कॉन्टेंट और ऊंचाई के लिए रिच कार्ड की सामान्य ज़रूरी शर्तों के मुताबिक होने चाहिए. कैरसेल की खास बातें, रिच कार्ड में देखी जा सकती हैं.
रिच कार्ड कैरसेल के पेलोड का साइज़ 250 केबी से ज़्यादा नहीं होना चाहिए. मीडिया फ़ाइल के साइज़ के बारे में सुझाव पाने और उसकी सीमाएं जानने के लिए, सबसे सही तरीके देखें.
काट-छांट
रिच कार्ड की तरह ही, कई चीज़ें (जैसे कि स्क्रीन रिज़ॉल्यूशन, पिक्सल डेंसिटी, और उपयोगकर्ता की प्राथमिकताएं) इस बात पर असर डालती हैं कि कार्ड, उपयोगकर्ताओं को कैसे दिखते हैं. हालांकि, कैरसेल में पहले कुछ कार्ड की ऊंचाई से, कैरसेल में मौजूद सभी कार्ड की ऊंचाई तय होती है. साथ ही, कार्ड की ऊंचाई से टाइटल, जानकारी, और सुझाव के छोटे होने पर असर पड़ता है.
अगर डिसप्ले से जुड़ी पाबंदियों या कार्ड की ऊंचाई की वजह से, कोई डिवाइस कार्ड के सभी एलिमेंट नहीं दिखा पाता है, तो RBM कार्ड को तब तक छोटा करता है, जब तक वह डिवाइस पर नहीं दिख जाता. इसके लिए, वह इस लॉजिक का इस्तेमाल करता है:
- जानकारी को एक लाइन में लिखो.
- टाइटल को एक लाइन में छोटा करें.
- कार्ड में शामिल न किए जा सकने वाले सुझावों को हटाओ. ऐसा, तय की गई सूची के आखिर से शुरू करो.
- ब्यौरा शामिल न करें.
- टाइटल शामिल न करें.
काट-छांट से बचने के लिए, टाइटल और ब्यौरे को जितना हो सके उतना छोटा रखें. लंबी इमेज या वीडियो के लिए, टाइटल और ब्यौरे का इस्तेमाल करें या कोई एक सुझाव चुनें. मीडियम मीडिया के लिए, ज़्यादा से ज़्यादा दो सुझावों का इस्तेमाल करें. छोटे मीडिया के लिए, ज़्यादा से ज़्यादा तीन सुझावों का इस्तेमाल करें. चार सुझाव दिखाने के लिए, कार्ड में मीडिया शामिल न करें.
कॉन्टेंट के साइज़ और लंबाई के हिसाब से, कार्ड को एक जैसा रखें. अगर ज़रूरी हो, तो कैरसेल में बड़े कार्ड सबसे पहले रखें, ताकि बाद के कार्ड में कॉन्टेंट न कटे.
उदाहरण
नीचे दिया गया कोड, रिच कार्ड का कैरसेल भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, RichCard
देखें.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d '{ "contentMessage": { "richCard": { "carouselCard": { "cardWidth": "MEDIUM", "cardContents": [ { "title": "Card #1", "description": "The description for card #1", "suggestions": [ { "reply": { "text": "Card #1", "postbackData": "card_1" } } ], "media": { "height": "MEDIUM", "contentInfo": { "fileUrl": "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg", "forceRefresh": false } } }, { "title": "Card #2", "description": "The description for card #2", "suggestions": [ { "reply": { "text": "Card #2", "postbackData": "card_2" } } ], "media": { "height": "MEDIUM", "contentInfo": { "fileUrl": "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg", "forceRefresh": false } } } ] } } } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Images for the carousel cards let card1Image = 'https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg'; let card2Image = 'https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg'; // Define the card contents for a carousel with two cards, each with one suggested reply let cardContents = [ { title: 'Card #1', description: 'The description for card #1', suggestions: [ { reply: { text: 'Card #1', postbackData: 'card_1', } } ], media: { height: 'MEDIUM', contentInfo: { fileUrl: card1Image, forceRefresh: false, }, }, }, { title: 'Card #2', description: 'The description for card #2', suggestions: [ { reply: { text: 'Card #2', postbackData: 'card_2', } } ], media: { height: 'MEDIUM', contentInfo: { fileUrl: card2Image, forceRefresh: false, }, }, }, ]; // Definition of carousel card let params = { msisdn: '+12223334444', cardContents: cardContents, }; // Send the device the carousel card defined above rbmApiHelper.sendCarouselCard(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.CardContent; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.cards.CardOrientation; import com.google.rbm.cards.CardWidth; import com.google.rbm.cards.MediaHeight; import com.google.rbm.RbmApiHelper; import com.google.rbm.SuggestionHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); List cardContents = new ArrayList(); // Images for the carousel cards String card1Image = "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg"; // Create suggestions for first carousel card List card1Suggestions = new ArrayList(); card1Suggestions.add( new SuggestionHelper("Card #1", "card_1")); cardContents.add( new StandaloneCardHelper( "Card #1", "The description for card #1", card1Image, card1Suggestions) .getCardContent(MediaHeight.SHORT) ); // Images for the carousel cards String card2Image = "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg"; // Create suggestions for second carousel card List card2Suggestions = new ArrayList(); card2Suggestions.add( new SuggestionHelper("Card #2", "card_2")); cardContents.add( new StandaloneCardHelper( "Card #2", "The description for card #2", card2Image, card2Suggestions) .getCardContent(MediaHeight.SHORT) ); // Send the carousel to the user rbmApiHelper.sendCarouselCards(cardContents, CardWidth.MEDIUM, "+12223334444"); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Images for the carousel cards card_image_1 = 'https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg'; card_image_2 = 'https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg'; # Suggested replies to be used in the cards suggestions1 = [ messages.SuggestedReply('Card #1', 'reply:card_1') ] suggestions2 = [ messages.SuggestedReply('Card #2', 'reply:card_2') ] # Define the card contents for a carousel with two cards, # each with one suggested reply card_contents = [] card_contents.append(messages.CardContent('Card #1', 'The description for card #1', card_image_1, 'MEDIUM', suggestions1)) card_contents.append(messages.CardContent('Card #2', 'The description for card #2', card_image_2, 'MEDIUM', suggestions2)) # Send the device the carousel card defined above carousel_card = messages.CarouselCard('MEDIUM', card_contents) cluster = messages.MessageCluster().append_message(carousel_card) cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; using RCSBusinessMessaging.Cards; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Image references to be used in the carousel cards string card1Image = "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg"; string card2Image = "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg"; // Suggestion chip lists to be used in carousel cards List<Suggestion> suggestions1 = new List<Suggestion> { new SuggestionHelper("Card #1", "card_1").SuggestedReply() }; List<Suggestion> suggestions2 = new List<Suggestion> { new SuggestionHelper("Card #2", "card_2").SuggestedReply() }; // Create the card content for the carousel List<CardContent> cardContents = new List<CardContent> { // Add items as card content new StandaloneCardHelper( "Card #1", "The description for card #1", card1Image, suggestions1).GetCardContent(), new StandaloneCardHelper( "Card #2", "The description for card #2", card2Image, suggestions2).GetCardContent() }; // Send the carousel to the user rbmApiHelper.SendCarouselCards(cardContents, CardWidth.MEDIUM, msisdn);