Eventi

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

Leggere gli eventi

Gli eventi di lettura comunicano all'utente che l'agente ha ricevuto il messaggio e lo rassicurano sul fatto che la piattaforma RBM lo ha recapitato. Il codice seguente 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 comunicano all'utente che il tuo agente sta scrivendo 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.