Acara

Dalam contoh berikut, rbm_api_helper.js (tidak digunakan untuk Python) mengasumsikan bahwa file yang Anda gunakan adalah satu direktori di bawah folder aplikasi utama. Anda mungkin perlu menyesuaikan lokasi, bergantung pada konfigurasi project.

Membaca peristiwa

Peristiwa baca memberi tahu pengguna bahwa agen menerima pesan dan memberikan keyakinan bahwa platform RBM mengirimkan pesan mereka. Kode berikut mengirim peristiwa baca ke perangkat dengan library klien.

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);
Kode ini adalah kutipan dari agen contoh 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");
Kode ini adalah kutipan dari agen contoh 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)
Kode ini adalah kutipan dari agen contoh 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");
Kode ini adalah kutipan dari agen contoh RBM.

Peristiwa pengetikan

Peristiwa mengetik memberi tahu pengguna bahwa agen Anda sedang menulis pesan. Kode berikut mengirim peristiwa pengetikan ke perangkat dengan library klien.

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!');
});
Kode ini adalah kutipan dari agen contoh 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");
Kode ini adalah kutipan dari agen contoh 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')
Kode ini adalah kutipan dari agen contoh 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");
Kode ini adalah kutipan dari agen contoh RBM.