Sự kiện

Trong các ví dụ sau, rbm_api_helper.js (không dùng cho Python) giả định tệp mà bạn đang làm việc nằm trong một thư mục bên dưới thư mục ứng dụng chính. Bạn có thể cần điều chỉnh vị trí tuỳ theo cấu hình dự án của mình.

Đọc sự kiện

Sự kiện đã đọc cho người dùng biết rằng nhân viên hỗ trợ đã nhận được tin nhắn và mang lại sự tin tưởng rằng nền tảng RCS cho doanh nghiệp đã gửi tin nhắn của họ. Đoạn mã sau đây gửi một sự kiện đọc đến một thiết bị có thư viện ứng dụng.

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);
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu 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");
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu 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)
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu 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");
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu RBM.

Sự kiện nhập

Sự kiện nhập cho người dùng biết rằng trợ lý của bạn đang soạn tin nhắn. Đoạn mã sau đây sẽ gửi một sự kiện nhập liệu đến thiết bị bằng một thư viện ứng dụng.

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!');
});
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu 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");
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu 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')
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu 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");
Đoạn mã này là một phần trích dẫn từ nhân viên hỗ trợ mẫu RBM.