Events

  • Read events inform the user that the agent has received their message, confirming delivery by the RBM platform, with code examples provided for Node.js, Java, Python, and C#.

  • Typing events signal to the user that the agent is currently composing a message, and examples using Node.js, Java, Python, and C# are shown.

  • The examples demonstrate how to use the RBM API helper to send read and typing events, across multiple programming languages.

  • rbm_api_helper.js is designed for use in Node.js and assumes a specific directory structure, which might need adjustments based on your project's configuration.

In the following examples, rbm_api_helper.js (not used for Python) assumes the file you are working in is one directory below the main app folder. You may need to adjust the location depending on your project's configuration.

Read events

Read events let the user know that the agent received the message and provide confidence that the RBM platform delivered their message. The following code sends a read event to a device with a client library.

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);
This code is an excerpt from an RBM sample agent.

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");
This code is an excerpt from an RBM sample agent.

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)
This code is an excerpt from an RBM sample agent.

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");
This code is an excerpt from an RBM sample agent.

Typing events

Typing events let the user know that your agent is composing a message. The following code sends a typing event to a device with a client library.

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!');
});
This code is an excerpt from an RBM sample agent.

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");
This code is an excerpt from an RBM sample agent.

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')
This code is an excerpt from an RBM sample agent.

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");
This code is an excerpt from an RBM sample agent.