Agent wysyła do urządzenia użytkownika zdarzenia stanu, aby symulować interakcje z człowiekiem. Użytkownicy widzą te zdarzenia jako potwierdzenia odbioru lub wskaźniki pisania, co daje im pewność, że ich wiadomości są przetwarzane.
Pełne opcje formatowania i wartości znajdziesz w phones.agentEvents.
Szczegółowe informacje o zdarzeniach webhook, które Twój agent otrzymuje z platformy RBM, znajdziesz w artykule Otrzymywanie zdarzeń.
Agent wysyła zdarzenie READ.
Dla użytkowników to zdarzenie jest potwierdzeniem odczytania konkretnej wiadomości. Informuje użytkownika, że platforma RBM dostarczyła jego wiadomość i agent ją przetwarza.
Zdarzenia READ są przechowywane przez 30 dni. Jeśli użytkownik ma włączone czaty RCS, ale jest niedostępny, zdarzenie jest umieszczane w kolejce. Jeśli nie mają włączonych czatów RCS, platforma RCS Business Messaging zwraca błąd NOT_FOUND (HTTP 404).
Poniższy kod wysyła zdarzenie READ w przypadku wiadomości z pasującym messageId.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d "{ 'eventType': 'READ', 'messageId': 'MESSAGE_ID' }"
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);
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");
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)
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");
Agent wysyła zdarzenie IS_TYPING
Użytkownicy widzą to zdarzenie jako wskaźnik pisania, który informuje ich, że Twój agent pisze wiadomość. Wskaźnik pisania wygasa po krótkim czasie (około 20 sekund) lub gdy urządzenie użytkownika otrzyma nową wiadomość od Twojego agenta. Agent może wysłać wiele zdarzeń IS_TYPING, aby zresetować czas wygaśnięcia wskaźnika pisania.
Zdarzenia IS_TYPING są krótkotrwałe i nie są umieszczane w kolejce.
Poniższy kod wysyła zdarzenie IS_TYPING.
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_ID&agentId=AGENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d "{ 'eventType': 'IS_TYPING', }"
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!'); });
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");
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')
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");