मैसेज भेजें

आरबीएम एजेंट, मैसेज भेजकर और मैसेज पाकर उपयोगकर्ताओं से बातचीत करते हैं. उपयोगकर्ताओं को मैसेज भेजने के लिए, आपका एजेंट 'आरसीएस कारोबार मैसेज सेवा' एपीआई को मैसेज भेजने के अनुरोध भेजता है. एक अनुरोध में टेक्स्ट, रिच कार्ड, इमेज या वीडियो के साथ-साथ सुझाए गए जवाब और सुझाई गई कार्रवाइयां शामिल हो सकती हैं.

अगर किसी ऐसे उपयोगकर्ता को मैसेज भेजा जाता है जिसके डिवाइस पर आरसीएस काम नहीं करता या आरसीएस की सुविधा चालू नहीं है, तो आरबीएम प्लैटफ़ॉर्म 404 गड़बड़ी का कोड दिखाता है. इस मामले में, अपने इन्फ़्रास्ट्रक्चर में बताए गए फ़ॉलबैक तरीकों का इस्तेमाल करके, उपयोगकर्ता तक पहुंचा जा सकता है.

अगर आरसीएस का इस्तेमाल करने वाले किसी व्यक्ति को ऐसे नेटवर्क पर मैसेज भेजा जाता है जहां आपका एजेंट अभी तक लॉन्च नहीं हुआ है या ऐसे नेटवर्क पर भेजा जाता है जिसने आरसीएस ट्रैफ़िक को चालू नहीं किया है, तो RBM प्लैटफ़ॉर्म 403 कोड वाली गड़बड़ी दिखाता है.

अगर आपने ऐसी सुविधाओं के साथ मैसेज भेजा है जो उपयोगकर्ता के डिवाइस पर काम नहीं करती हैं, तो आरबीएम प्लैटफ़ॉर्म गड़बड़ी का मैसेज दिखाता है और आपका मैसेज डिलीवर नहीं करता.

कई चैनलों पर मैसेज भेजने की रणनीति के तहत, ऐसे मैसेज रद्द करना सबसे अच्छा होता है जो तय समय के बाद डिलीवर नहीं होते. साथ ही, उन्हें किसी दूसरे चैनल से भेजना चाहिए. अगर आपको मैसेज को तय समय पर अपने-आप रद्द करना है, तो मैसेज की समयसीमा सेट करें.

पाने वाला ऑफ़लाइन है

अगर मैसेज पाने वाला व्यक्ति ऑफ़लाइन है, तब भी RBM प्लैटफ़ॉर्म मैसेज को डिलीवर करने के लिए स्वीकार करता है. आपको 200 OK का जवाब मिलता है. इसके बाद, RBM प्लैटफ़ॉर्म मैसेज को सेव कर लेता है और 30 दिनों तक उसे फिर से डिलीवर करने की कोशिश करता है. आरबीएम से मैसेज फिर से भेजने के लिए कहने की ज़रूरत नहीं है.

आरबीएम, सबमिट किए गए ऐसे सभी मैसेज को 30 दिनों के बाद मिटा देता है जो डिलीवर नहीं किए जा सके.

अपने एजेंट के इस्तेमाल के उदाहरण के आधार पर, हो सकता है कि आप 30 दिनों के टाइम आउट से पहले, डिलीवर नहीं किए गए मैसेज को रद्द करना चाहें. रद्द करने की सुविधा से, ऑफ़लाइन उपयोगकर्ताओं को फिर से ऑनलाइन आने पर, पुराना मैसेज मिलने से रोका जा सकता है. मैसेज वापस लेने के कई तरीके हैं:

मैसेज के ऐक्सेस खत्म होने की समयसीमा सेट करना

क्या आपके एजेंट का मैसेज समय के हिसाब से ज़रूरी है? उदाहरण के लिए, ओटीपी सिर्फ़ कुछ समय के लिए मान्य होते हैं. सीमित समय के ऑफ़र की समयसीमा खत्म हो जाती है. साथ ही, अपॉइंटमेंट की तारीख के बाद, अपॉइंटमेंट के रिमाइंडर काम के नहीं होते. समय पर और काम के मैसेज पाने के लिए, मैसेज के दिखने की समयसीमा सेट करें. इससे, ऑफ़लाइन उपयोगकर्ताओं को फिर से ऑनलाइन आने पर, पुराना कॉन्टेंट नहीं दिखता. समयसीमा खत्म होने पर, मैसेज भेजने की फ़ॉलबैक रणनीति को लागू करना भी एक अच्छा तरीका है. इससे उपयोगकर्ताओं को समय पर ज़रूरी जानकारी मिलती है.

मैसेज के खत्म होने की तारीख सेट करने के लिए, एजेंट मैसेज में इनमें से कोई एक फ़ील्ड डालें:

  • expireTime: यूटीसी में, मैसेज की समयसीमा खत्म होने का सटीक समय.
  • ttl(टाइम टू लाइव): मैसेज की समयसीमा खत्म होने में लगने वाला समय.

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, AgentMessage देखें.

मैसेज की समयसीमा खत्म होने के बाद, RBM प्लैटफ़ॉर्म मैसेज डिलीवर करने की कोशिश करना बंद कर देता है और मैसेज अपने-आप रद्द हो जाता है. हालांकि, ऐसा कभी-कभी हो सकता है कि यह काम न करे. उदाहरण के लिए, जब RBM प्लैटफ़ॉर्म मैसेज डिलीवर कर रहा हो, तब एपीआई रद्द करने की प्रोसेस को ट्रिगर कर सकता है. यह पुष्टि करने के लिए कि समयसीमा खत्म हो चुके मैसेज को रद्द किया गया है या नहीं, RBM आपके वेबहुक पर एक सूचना इवेंट भेजेगा.

मैसेज सबमिट करने के बाद, ttl और expireTime की ज़्यादा से ज़्यादा वैल्यू 15 दिन हो सकती है.

मैसेज के साइज़ की सीमाएं

स्ट्रिंग में बदले गए पूरे AgentMessage का साइज़ 250 केबी से ज़्यादा नहीं होना चाहिए. रिच कार्ड और अन्य मीडिया, साइज़ की इस सीमा में शामिल होते हैं. मैसेज के टेक्स्ट वाले हिस्से में ज़्यादा से ज़्यादा 3,072 वर्ण हो सकते हैं.

आरबीएम की मदद से, 100 एमबी तक की फ़ाइल भेजी जा सकती है. किसी एक आरबीएम मैसेज में सिर्फ़ एक PDF या मीडिया फ़ाइल अटैच की जा सकती है. ज़्यादा जानकारी के लिए, मीडिया और 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!'
  }
}"

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",
);
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.

मैसेज का बुनियादी कॉन्टेंट - एसएमएस का कन्वर्ज़न

मोबाइल और इंटरनेट सेवा देने वाली कंपनियों ने एसएमएस मैसेज को आरबीएम पर ट्रांसफ़र करने के लिए, बिलिंग मॉडल शुरू किए हैं. आरबीएम मैसेज में ज़्यादा से ज़्यादा 160 UTF-8 वर्ण हो सकते हैं. ऐसे मैसेज को बुनियादी मैसेज कहा जाता है.

बेसिक मैसेज भेजने का अनुरोध बनाते समय, ध्यान रखें कि वर्णों को 1 बाइट (UTF-8) के तौर पर गिना जाता है. अगर आपने कोई ऐसा मैसेज भेजा है जिसमें ईमोजी या मल्टी-बाइट वर्ण सेट जैसे खास वर्ण शामिल हैं, तो हर वर्ण को दो UTF-8 वर्ण माना जाएगा.

बॉक्स में कुछ टेक्स्ट डालकर उसकी लंबाई देखें:

उपयोगकर्ता की पुष्टि के लिए एक बार इस्तेमाल होने वाले पासवर्ड

SMS Retriever API की मदद से, उपयोगकर्ता की पुष्टि अपने-आप करने के लिए, एक बार इस्तेमाल होने वाले पासवर्ड (ओटीपी) भेजने के लिए, आरबीएम का इस्तेमाल किया जा सकता है. एसएमएस Retriever और उससे जुड़े एपीआई के बारे में ज़्यादा जानने के लिए, एसएमएस Retriever से जुड़ा दस्तावेज़ देखें. SMS Retriever API के साथ रजिस्टर किए गए ऐप्लिकेशन में, उपयोगकर्ता की पुष्टि अपने-आप होने की सुविधा के बारे में जानने के लिए, यह फ़्लो डायग्राम देखें.

पुष्टि की प्रोसेस के दौरान, एसएमएस रीट्रिवर एपीआई, आरबीएम मैसेज को सुनता है. इस मैसेज में एक ओटीपी और एक हैश होना चाहिए, जिससे ऐप्लिकेशन की पहचान की जा सके. ऐप्लिकेशन के साथ हैश मैच होने के बाद, ओटीपी को निकाला जाता है और उपयोगकर्ता की पुष्टि अपने-आप करने के लिए, ऐप्लिकेशन को भेजा जाता है.

उपयोगकर्ता की पुष्टि के लिए, आरबीएम का मैसेज यहां दिया गया है: आपका कोड <OTP> <app hash> है.

उदाहरण के लिए, Your code is 123456 M8tue43FGT.

मीडिया और PDF फ़ाइलें

अगर कोई इमेज, वीडियो, ऑडियो या PDF फ़ाइल भेजी जाती है, तो आपके एजेंट को कॉन्टेंट का ऐसा यूआरएल देना होगा जिसे सार्वजनिक तौर पर ऐक्सेस किया जा सके. इसके अलावा, वह फ़ाइल को सीधे अपलोड भी कर सकता है. मीडिया फ़ाइलों के लिए, थंबनेल इमेज भी दी जा सकती है. इससे उपयोगकर्ताओं को कॉन्टेंट पर क्लिक करने से पहले, उसकी झलक देखने में मदद मिलती है. ऑडियो फ़ाइलों के लिए, डिफ़ॉल्ट ऑडियो विजेट का इस्तेमाल प्लेसहोल्डर के तौर पर किया जाता है.

RBM प्लैटफ़ॉर्म, फ़ाइलों को 60 दिनों के लिए कैश मेमोरी में सेव रखता है. साथ ही, एपीआई एक फ़ाइल आईडी दिखाता है, जिसे आपका एजेंट उपयोगकर्ताओं को भेजे जाने वाले मैसेज में शामिल कर सकता है. 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'
   }
  }
}"

इस्तेमाल किए जा सकने वाले मीडिया टाइप

आरबीएम, इन मीडिया टाइप के साथ काम करता है:

मीडिया टाइप दस्तावेज़ का टाइप Extension रिच कार्ड के साथ काम करता है
application/ogg OGG ऑडियो .ogx नहीं
application/pdf PDF .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 हां
video/webm WEBM वीडियो .webm हां

सुझाए गए जवाब

सुझाए गए जवाब, उपयोगकर्ताओं को बातचीत के दौरान दिशा-निर्देश देते हैं. ये ऐसे जवाब होते हैं जिन पर आपका एजेंट जवाब दे सकता है. आपका एजेंट, सुझाए गए जवाबों को सुझाव चिप की सूचियों या रिच कार्ड में भेजता है.

जब कोई उपयोगकर्ता सुझाए गए जवाब पर टैप करता है, तो आपके एजेंट को एक इवेंट मिलता है. इसमें जवाब का टेक्स्ट और पोस्टबैक डेटा शामिल होता है.

सुझाए गए जवाबों में ज़्यादा से ज़्यादा 25 वर्ण होने चाहिए.

उदाहरण

नीचे दिया गया कोड, सुझाए गए दो जवाबों के साथ टेक्स्ट भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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
);
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.

सुझाई गई कार्रवाइयाँ

सुझाई गई कार्रवाइयां, उपयोगकर्ताओं को बातचीत के दौरान उनके डिवाइसों की पहले से मौजूद सुविधाओं का इस्तेमाल करने के लिए गाइड करती हैं. आपका एजेंट, उपयोगकर्ताओं को कोई नंबर डायल करने, मैप पर कोई जगह खोलने, कोई जगह शेयर करने, यूआरएल खोलने या कैलेंडर इवेंट बनाने का सुझाव दे सकता है. आपका एजेंट, सुझाव चिप की सूचियों या रिच कार्ड में सुझाई गई कार्रवाइयां भेजता है.

जब कोई उपयोगकर्ता सुझाई गई किसी कार्रवाई पर टैप करता है, तो आपके एजेंट को एक इवेंट मिलता है. इसमें कार्रवाई का पोस्टबैक डेटा होता है.

सुझाई गई कार्रवाइयों में ज़्यादा से ज़्यादा 25 वर्ण हो सकते हैं.

फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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
);
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.

कोई स्थान शेयर करें

'जगह की जानकारी शेयर करें' कार्रवाई की मदद से, उपयोगकर्ता आपके एजेंट को जगह की जानकारी भेज सकता है. यह ज़रूरी नहीं है कि उपयोगकर्ता की बताई गई जगह, उसकी जगह की जानकारी हो.

उदाहरण

यहां दिया गया कोड, जगह की जानकारी शेयर करने की कार्रवाई भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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
);
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.

वेबव्यू की मदद से यूआरएल खोलना

वेबव्यू ऐक्शन के साथ यूआरएल खोलने की सुविधा, आपके डिफ़ॉल्ट ब्राउज़र के रेंडरिंग इंजन की मदद से, मैसेजिंग ऐप्लिकेशन में बताए गए वेब पेज को लोड करती है. इससे, उपयोगकर्ता को आरबीएम बातचीत से बाहर निकले बिना वेब पेज से इंटरैक्ट करने की सुविधा मिलती है. वेबव्यू चालू करने के लिए, OpenURLApplication देखें.

वेबव्यू के तीन डिसप्ले मोड होते हैं. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, WebviewViewMode देखें.

  • फ़ुल: वेब पेज पूरी स्क्रीन पर दिखता है
  • हाफ़: वेब पेज, स्क्रीन के आधे हिस्से पर दिखता है
  • लंबा: वेब पेज, स्क्रीन के तीन चौथाई हिस्से पर दिखता है

उदाहरण

यहां दिया गया कोड, वेबव्यू ऐक्शन के साथ 'यूआरएल खोलें' निर्देश भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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;
    }

कैलेंडर इवेंट बनाओ

'कैलेंडर इवेंट बनाएं' कार्रवाई से, उपयोगकर्ता का कैलेंडर ऐप्लिकेशन खुलता है और तय की गई जानकारी के साथ नया इवेंट बनना शुरू हो जाता है.

उदाहरण

नीचे दिया गया कोड, कैलेंडर इवेंट बनाने का ऐक्शन भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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
);
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.

संदेश लिखें

'लिखें' कार्रवाई से, उपयोगकर्ता का मैसेजिंग ऐप्लिकेशन खुलता है, ताकि वह पहले से तय किए गए फ़ोन नंबर पर मैसेज भेज सके. जैसे, ग्राहक सहायता नंबर.

हों.

'लिखें' सुविधा से तीन तरह की कार्रवाइयां की जा सकती हैं. विज़ुअल उदाहरणों के लिए, टेक्स्ट, ऑडियो या वीडियो मैसेज लिखना लेख पढ़ें.

  • मैसेज लिखना: इससे मैसेजिंग ऐप्लिकेशन खुलता है. इसमें, उपयोगकर्ता के लिए पहले से टेक्स्ट भरा होता है, ताकि वह उसे भेज सके.
  • बोलकर मैसेज लिखना: इससे मैसेज सेवा ऐप्लिकेशन खुलता है और माइक्रोफ़ोन चालू होता है, ताकि उपयोगकर्ता ऑडियो रिकॉर्ड कर सके.
  • वीडियो मैसेज लिखना: इससे मैसेजिंग ऐप्लिकेशन खुलता है और कैमरा चालू होता है, ताकि उपयोगकर्ता वीडियो रिकॉर्ड कर सके.

उदाहरण

नीचे दिया गया कोड, लिखने की कार्रवाई भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, ComposeAction देखें.

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': 'Compose a text message',
          'postbackData': 'postback_data_123',
          'composeAction': {
            'composeTextMessage': {
              'phoneNumber': '+15556667777'
              'text': 'Draft to go into the send message text field.'
            }
          }
        }
      },{
        'action': {
          'text': 'Compose an audio message',
          'postbackData': 'postback_data_456',
          'composeAction': {
            'composeRecordingMessage': {
              'phoneNumber': '+15556667777'
              'type': 'ACTION_TYPE_AUDIO'
            }
          }
        }
      },{
        'action': {
          'text': 'Compose a video message',
          'postbackData': 'postback_data_789',
          'composeAction': {
            'composeRecordingMessage': {
              'phoneNumber': '+15556667777'
              'type': 'ACTION_TYPE_VIDEO'
            }
          }
        }
      }
    ]
  }
}"

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Define a compose suggested action
let suggestions = [
   {
      action: {
         text: 'Compose a text message',
         postbackData: 'postback_data_123',
         'composeAction': {
            'composeTextMessage': {
               'phoneNumber': '+15556667777'
               'text': 'Draft to go into the send message text field.'
            }
         }
      }
   },{
      action: {
         text: 'Compose an audio message',
         postbackData: 'postback_data_456',
         'composeAction': {
            'composeRecordingMessage': {
               'phoneNumber': '+15556667777'
               'type': 'ACTION_TYPE_AUDIO'
            }
         }
      }
   },{
      action: {
         text: 'Compose a video message',
         postbackData: 'postback_data_789',
         'composeAction': {
            'composeRecordingMessage': {
               'phoneNumber': '+15556667777'
               'type': 'ACTION_TYPE_VIDEO'
            }
         }
      }
   }
];

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.ComposeAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.ComposeRecordingMessage;
import com.google.api.services.rcsbusinessmessaging.v1.model.ComposeTextMessage;
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 compose text suggested action
   Suggestion composeTextSuggestion =  getComposeTextAction()
   suggestions.add(composeTextSuggestion);

   // creating compose audio suggested action
   Suggestion composeAudioSuggestion =  getComposeAudioAction()
   suggestions.add(composeAudioSuggestion);


   // Send simple text message with the suggestion action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}

 /**
   * Creates a compose text suggested action.
   * @return A suggestion object for a compose text action.
 */
 private Suggestion getComposeTextAction() {
        // creating a compose text suggested action
        ComposeTextMessage message = new ComposeTextMessage();
        message.setPhoneNumber("+12223334444");
        message.setText("Draft to go into the send message text field.");
        ComposeAction composeAction = new ComposeAction();
        composeAction.setComposeTextMessage(message);

        // creating a suggested action based on a compose text action
        SuggestedAction suggestedAction = new SuggestedAction();
        suggestedAction.setText("Send a text message");
        suggestedAction.setPostbackData("postback_data_123");
        suggestedAction.setComposeAction(composeAction);

        // attaching action to a suggestion
        Suggestion suggestion = new Suggestion();
        suggestion.setAction(suggestedAction);

        return suggestion;
    }

    /**
     * Creates a compose audio suggested action.
     * @return A suggestion object for a compose audio action.
    */
    private Suggestion getComposeAudioAction() {
        // creating a compose audio suggested action
        ComposeRecordingMessage message = new ComposeRecordingMessage();
        message.setPhoneNumber("+12223334444");
        message.setType("ACTION_TYPE_AUDIO");
        ComposeAction composeAction = new ComposeAction();
        composeAction.setComposeRecordingMessage(message);

        // creating a suggested action based on a compose text action
        SuggestedAction suggestedAction = new SuggestedAction();
        suggestedAction.setText("Send an audio message");
        suggestedAction.setPostbackData("postback_data_456");
        suggestedAction.setComposeAction(composeAction);

        // attaching action to a suggestion
        Suggestion suggestion = new Suggestion();
        suggestion.setAction(suggestedAction);

        return suggestion;
    }

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.ComposeTextMessageAction(
          'Send a text message',
          'postback_data_123',
          '+15556667777',
          '')
      messages.ComposeRecordingMessageAction(
          'Send an audio message',
          'postback_data_456',
          '+15556667777',
          'ACTION_TYPE_AUDIO')
  
  ]

  # 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 compose text suggested action
  ComposeTextMessage composeTextMessage = new ComposeTextMessage{
      PhoneNumber = "+15556667777"
      Text = "Draft to go into the send message text field."
  };

  ComposeAction composeAction = new ComposeAction
  {
      ComposeTextMessage = composeTextMessage
  };

  // Creating a suggested action based on a compose action
  SuggestedAction suggestedAction = new SuggestedAction
  {
      Text = "Send a text message",
      PostbackData = "postback_data_123",
      ComposeAction = composeAction
  };

  // Attach action to a suggestion
  Suggestion suggestion = new Suggestion
  {
      Action = suggestedAction
  };

  List suggestions = new List
  {
      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");
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.

रिच कार्ड कैरसेल

जब आपको उपयोगकर्ता को कई विकल्पों में से चुनने के लिए दिखाने हों, तो रिच कार्ड कैरसेल का इस्तेमाल करें. कैरसेल में कई रिच कार्ड एक साथ दिखते हैं. इनकी मदद से, उपयोगकर्ता आइटम की तुलना कर सकते हैं और हर आइटम पर अलग-अलग प्रतिक्रिया दे सकते हैं.

कैरसेल में कम से कम दो और ज़्यादा से ज़्यादा 10 रिच कार्ड हो सकते हैं. कैरसेल में मौजूद रिच कार्ड, कॉन्टेंट और ऊंचाई के लिए रिच कार्ड की सामान्य ज़रूरी शर्तों के मुताबिक होने चाहिए.

रिच कार्ड कैरसेल के पेलोड का साइज़ 250 केबी से ज़्यादा नहीं होना चाहिए. मीडिया फ़ाइल के साइज़ के सुझावों और सीमाओं के लिए, सबसे सही तरीके देखें.

रिच कार्ड की तरह ही, कई चीज़ों (जैसे, स्क्रीन रिज़ॉल्यूशन, पिक्सल डेंसिटी, और उपयोगकर्ता की प्राथमिकताएं) का असर इस बात पर पड़ता है कि कार्ड, असली उपयोगकर्ताओं को कैसे दिखते हैं. हालांकि, कैरसेल में पहले कुछ कार्ड की ऊंचाई से, कैरसेल में मौजूद सभी कार्ड की ऊंचाई तय होती है. साथ ही, कार्ड की ऊंचाई से टाइटल, ब्यौरे, और सुझाव के काटे जाने पर असर पड़ता है.

अगर डिसप्ले की सीमाओं या कार्ड की ऊंचाई की वजह से, कोई डिवाइस कार्ड के सभी एलिमेंट नहीं दिखा पाता है, तो आरबीएम कार्ड को तब तक छोटा करता है, जब तक वह डिवाइस पर दिखने लायक नहीं हो जाता. इसके लिए, यह लॉजिक इस्तेमाल किया जाता है:

  1. ब्यौरे को एक लाइन में लिखें.
  2. टाइटल को एक लाइन में लिखें.
  3. कार्ड में फ़िट न होने वाले सुझावों को हटाएं. इसके लिए, तय की गई सूची के आखिर से शुरू करें.
  4. ब्यौरा न दें.
  5. टाइटल को हटाएं.

काट-छांट से बचने के लिए, टाइटल और ब्यौरे को जितना हो सके उतना छोटा रखें. लंबी अवधि के मीडिया के लिए, टाइटल और ब्यौरे या किसी एक सुझाव का इस्तेमाल करें. मीडियम मीडिया के लिए, ज़्यादा से ज़्यादा दो सुझावों का इस्तेमाल करें. छोटे मीडिया के लिए, ज़्यादा से ज़्यादा तीन सुझावों का इस्तेमाल करें. चार सुझावों को फ़िट करने के लिए, कार्ड में मीडिया शामिल न करें.

कार्ड के कॉन्टेंट के साइज़ और लंबाई को एक जैसा रखें. अगर ज़रूरी हो, तो कैरसेल में बड़े कार्ड को सबसे पहले लोड करें, ताकि अगले कार्ड में कॉन्टेंट काटकर न दिखाया जाए.

उदाहरण

नीचे दिया गया कोड, रिच कार्ड कैरसेल भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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);
यह कोड, आरबीएम सैंपल एजेंट का एक हिस्सा है.