Eventi

Nei seguenti esempi, rbm_api_helper.js (non utilizzato per Python) presuppone che il file su cui stai lavorando si trovi in una directory sotto la cartella principale dell'app. Potresti dover modificare la posizione a seconda della configurazione del progetto.

Leggere gli eventi

Gli eventi di lettura informano l'utente che l'agente ha ricevuto il messaggio e forniscono la certezza che la piattaforma RCS for Business lo abbia consegnato. Il seguente codice invia un evento di lettura a un dispositivo con una libreria client.

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);
Questo codice è un estratto di un agente di esempio 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");
Questo codice è un estratto di un agente di esempio 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)
Questo codice è un estratto di un agente di esempio 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");
Questo codice è un estratto di un agente di esempio RBM.

Eventi di digitazione

Gli eventi di digitazione informano l'utente che l'agente sta componendo un messaggio. Il seguente codice invia un evento di digitazione a un dispositivo con una libreria client.

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!');
});
Questo codice è un estratto di un agente di esempio 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");
Questo codice è un estratto di un agente di esempio 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')
Questo codice è un estratto di un agente di esempio 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");
Questo codice è un estratto di un agente di esempio RBM.