في الأمثلة التالية، يفترض العنصر 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");