رویداد

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

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

رویدادهای خواندن به کاربر اطلاع می‌دهند که عامل پیام را دریافت کرده و اطمینان می‌دهند که پلتفرم RCS for Business پیام آنها را به مقصد رسانده است. کد زیر یک رویداد خواندن را به دستگاهی با کتابخانه کلاینت ارسال می‌کند.

نود جی اس

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

تایپ رویدادها

رویدادهای تایپ به کاربر اطلاع می‌دهند که عامل شما در حال نوشتن پیام است. کد زیر یک رویداد تایپ را به دستگاهی با کتابخانه کلاینت ارسال می‌کند.

نود جی اس

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