Événements

Dans les exemples suivants, rbm_api_helper.js (non utilisé pour Python) suppose que le fichier dans lequel vous travaillez se trouve un répertoire en dessous du dossier principal de l'application. Vous devrez peut-être ajuster l'emplacement en fonction de la configuration de votre projet.

Lire les événements

Les événements de lecture indiquent à l'utilisateur que l'agent a reçu le message et lui permettent de savoir que la plate-forme RBM a bien envoyé son message. Le code suivant envoie un événement de lecture à un appareil avec une bibliothèque cliente.

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);
Ce code est un extrait d'un exemple d'agent 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");
Ce code est un extrait d'un exemple d'agent 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)
Ce code est un extrait d'un exemple d'agent 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");
Ce code est un extrait d'un exemple d'agent RBM.

Événements de saisie

Les événements de frappe indiquent à l'utilisateur que votre agent est en train de rédiger un message. Le code suivant envoie un événement de saisie à un appareil avec une bibliothèque cliente.

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!');
});
Ce code est un extrait d'un exemple d'agent 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");
Ce code est un extrait d'un exemple d'agent 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')
Ce code est un extrait d'un exemple d'agent 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");
Ce code est un extrait d'un exemple d'agent RBM.