यहां दिए गए उदाहरणों में, rbm_api_helper.js
(Python के लिए इस्तेमाल नहीं किया जाता) यह मानता है कि जिस फ़ाइल पर काम किया जा रहा है वह मुख्य ऐप्लिकेशन फ़ोल्डर के नीचे मौजूद एक डायरेक्ट्री में है. आपको अपने प्रोजेक्ट के कॉन्फ़िगरेशन के आधार पर, जगह की जानकारी में बदलाव करना पड़ सकता है.
इवेंट पढ़ना
मैसेज पढ़े जाने के इवेंट से उपयोगकर्ता को पता चलता है कि एजेंट को मैसेज मिल गया है. साथ ही, इससे यह भी पता चलता है कि RBM प्लैटफ़ॉर्म ने मैसेज डिलीवर कर दिया है. नीचे दिया गया कोड, क्लाइंट लाइब्रेरी वाले डिवाइस पर रीड इवेंट भेजता है.
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Send the device an event to indicate that messageId has been read rbmApiHelper.sendReadMessage('+12223334444', messageId);
Java
import com.google.rbm.RbmApiHelper; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Send the device an event to indicate that messageId has been read rbmApiHelper.sendReadMessage(messageId, "+12223334444");
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service # Send the device an event to indicate that message_id was read rbm_service.send_read_event('+12223334444', message_id)
C#
using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Send the device an event to indicate that messageId has been read rbmApiHelper.SendReadMessage(messageId, "+12223334444");
टाइप करने से जुड़े इवेंट
टाइपिंग इवेंट से उपयोगकर्ता को पता चलता है कि आपका एजेंट मैसेज लिख रहा है. यहां दिया गया कोड, क्लाइंट लाइब्रेरी वाले डिवाइस पर टाइपिंग इवेंट भेजता है.
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Send the device an event to indicate that the agent is typing rbmApiHelper.sendIsTypingMessage('+12223334444', function() { console.log('Typing event sent!'); });
Java
import com.google.rbm.RbmApiHelper; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); // Send the device an event to indicate that the agent is typing rbmApiHelper.sendIsTypingMessage("+12223334444");
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service # Send the device an event to indicate that the agent is typing rbm_service.send_is_typing_event('+12223334444')
C#
using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Send the device an event to indicate that the agent is typing rbmApiHelper.SendIsTypingMessage(messageId, "+12223334444");