رویداد

در مثال‌های زیر، rbm_api_helper.js (برای پایتون استفاده نمی‌شود) فرض می‌کند فایلی که در آن کار می‌کنید یک دایرکتوری زیر پوشه اصلی برنامه است. ممکن است لازم باشد مکان را بسته به پیکربندی پروژه خود تنظیم کنید.

رویدادها را بخوانید

رویدادهای خواندن به کاربر اطلاع می‌دهند که نماینده پیام را دریافت کرده است و اطمینان می‌دهد که پلتفرم 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);
این کد گزیده ای از یک عامل نمونه RBM است.

جاوا

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 است.

پایتون

# 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 است.

سی شارپ

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 است.

جاوا

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 است.

پایتون

# 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 است.

سی شارپ

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 است.