الأحداث

في الأمثلة التالية، يفترض الرمز rbm_api_helper.js (غير المستخدَم في Python) أنّ الملف الذي تعمل فيه يقع في دليل واحد أسفل مجلد التطبيق الرئيسي. قد تحتاج إلى تعديل الموقع الجغرافي حسب إعدادات مشروعك.

قراءة الأحداث

تتيح أحداث القراءة للمستخدم معرفة أنّ الوكيل تلقّى الرسالة، وتوفّر له الثقة بأنّ منصة RCS Business Messaging قد سلّمت رسالته. يرسل الرمز التالي حدث قراءة إلى جهاز يتضمّن مكتبة برامج للعملاء.

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);
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

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");
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

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)
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

#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");
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

أحداث الكتابة

تتيح أحداث الكتابة للمستخدم معرفة أنّ برنامج الدردشة الآلي يكتب رسالة. يرسل الرمز التالي حدث كتابة إلى جهاز مزوّد بمكتبة برامج للعميل.

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!');
});
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

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");
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

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')
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

#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");
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.