मैसेज भेजें

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

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

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

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

स्ट्रिंग के साथ बनाए गए AgentMessage का साइज़ 250 केबी से ज़्यादा नहीं होना चाहिए.

किसी ऑफ़लाइन उपयोगकर्ता को भेजा जा रहा है

अगर ईमेल पाने वाला व्यक्ति इंटरनेट से नहीं जुड़ा है, तो आरबीएम प्लैटफ़ॉर्म डिलीवरी के लिए मैसेज स्वीकार करता है. ऐसा करने पर, आपको 200 के जवाब में 'ठीक है' के तौर पर जवाब मिलता है. आरबीएम प्लैटफ़ॉर्म इस मैसेज को 30 दिनों के लिए फिर से डिलीवर करने की कोशिश करता है. आरबीएम को फिर से मैसेज भेजने के लिए कहने की ज़रूरत नहीं है.

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

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

मैसेज की समयसीमा सेट करना

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

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

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

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

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

टेक्स्ट

सबसे आसान मैसेज, टेक्स्ट से बने होते हैं. टेक्स्ट मैसेज, विज़ुअल, कॉम्प्लेक्स इंटरैक्शन या रिस्पॉन्स की ज़रूरत के बिना, जानकारी देने के लिए सबसे अच्छा विकल्प होता है.

उदाहरण

यह कोड एक सामान्य मैसेज भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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) के तौर पर की जाती है. अगर इमोजी या मल्टी-बाइट वर्ण सेट जैसे खास वर्णों वाला कोई मैसेज भेजा जाता है, तो हर वर्ण को 2 UTF-8 वर्णों के तौर पर गिना जाता है.

बॉक्स में टेक्स्ट की लंबाई देखने के लिए, कोई टेक्स्ट डालें:

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

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

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

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

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

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

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

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

फ़ाइल के साइज़ से जुड़े सुझावों और सीमाओं के लिए सबसे सही तरीके देखें.

फ़ाइल के यूआरएल का उदाहरण

यह कोड एक इमेज भेजता है. फ़ॉर्मैटिंग और वैल्यू के विकल्पों के लिए, 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 रिच कार्ड के साथ काम करता है
ऐप्लिकेशन/pdf PDF .pdf नहीं
image/jpeg JPEG .jpeg, .jpg हां
image/gif GIF .gif हां
image/png PNG .png हां
वीडियो/h263 H263 वीडियो .h263 हां
वीडियो/m4v M4V वीडियो .m4 वोल्ट हां
video/mp4 MP4 वीडियो .mp4 हां
वीडियो/mpeg4 MPEG-4 वीडियो .mp4, .m4p हां
वीडियो/mpeg MPEG वीडियो .mpeg हां
वीडियो/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 देखें.

नंबर डायल करें

डायल कार्रवाई, उपयोगकर्ता को वह फ़ोन नंबर डायल करने में मदद करती है जो आपका एजेंट बताता है. फ़ोन नंबरों में शुरुआत में +, देश का कोड, और एरिया कोड शामिल होना चाहिए. हालांकि, इसमें सेपरेटर नहीं होने चाहिए. उदाहरण के लिए, +14155555555.

उदाहरण

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

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

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

उदाहरण

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

रिच कार्ड

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

रिच कार्ड में ये आइटम हो सकते हैं:

  • इमेज/वीडियो
  • टाइटल का टेक्स्ट
  • जानकारी देने वाला टेक्स्ट
  • सुझाए गए जवाबों और सुझाई गई कार्रवाइयों की सूची (ज़्यादा से ज़्यादा चार)

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

आपका एजेंट एक रिच कार्ड कैरसेल में एक साथ कई रिच कार्ड भेज सकता है.

कार्ड की ऊंचाई

कार्ड, कॉन्टेंट के हिसाब से वर्टिकल तौर पर बड़े होते हैं. रिच कार्ड की ऊंचाई कम से कम 112 डीपी और ऊंचाई 344 डीपी होनी चाहिए. अगर किसी कार्ड में मौजूद कॉन्टेंट, कार्ड की कम से कम ऊंचाई को भरने के लिए काफ़ी नहीं है, तो कार्ड बड़ा हो जाता है और अतिरिक्त ऊंचाई को खाली सफ़ेद जगह से भर देता है.

रिच कार्ड के मीडिया की लंबाई इन तीन में से किसी एक में होनी चाहिए:

  • छोटा फ़ॉर्मैट: 112 DP
  • मीडियम: 168 DP
  • बड़ा: 264 DP

अगर चुनी गई ऊंचाई दिए गए कार्ड में मीडिया फ़िट नहीं होता है, तो मीडिया को ज़ूम करके और क्रॉप करके चुना जाता है.

उदाहरण

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

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

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

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

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

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

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