Eventos

Nos exemplos a seguir, rbm_api_helper.js (não usado para Python) assume que o arquivo em que você está trabalhando está um diretório abaixo da pasta principal do app. Talvez seja necessário ajustar o local dependendo da configuração do seu projeto.

Ler eventos

Os eventos de leitura informam ao usuário que o agente recebeu a mensagem e que a plataforma RBM a entregou. O código abaixo envia um evento de leitura para um dispositivo com uma biblioteca de 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);
Este código é um trecho de um agente de exemplo do 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");
Este código é um trecho de um agente de exemplo do 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)
Este código é um trecho de um agente de exemplo do 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");
Este código é um trecho de um agente de exemplo do RBM.

Eventos de digitação

Os eventos de digitação informam ao usuário que o agente está digitando uma mensagem. O código abaixo envia um evento de digitação para um dispositivo com uma biblioteca de 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!');
});
Este código é um trecho de um agente de exemplo do 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");
Este código é um trecho de um agente de exemplo do 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')
Este código é um trecho de um agente de exemplo do 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");
Este código é um trecho de um agente de exemplo do RBM.