Tác nhân của bạn gửi các sự kiện trạng thái đến thiết bị của người dùng để mô phỏng các hoạt động tương tác của con người. Đối với người dùng, những sự kiện này xuất hiện dưới dạng thông báo xác nhận đã đọc hoặc chỉ báo đang nhập, đảm bảo rằng tin nhắn của họ đang được xử lý.
Để biết đầy đủ các lựa chọn định dạng và giá trị, hãy xem tài liệu tham khảo phones.agentEvents.
Để biết thông tin chi tiết về các sự kiện webhook mà tác nhân của bạn nhận được từ nền tảng RBM, hãy xem phần Nhận sự kiện.
Nhân viên hỗ trợ gửi một sự kiện READ
Đối với người dùng, sự kiện này xuất hiện dưới dạng thông báo đã đọc cho một tin nhắn cụ thể. Thông báo cho người dùng biết rằng nền tảng RBM đã gửi tin nhắn của họ và nhân viên hỗ trợ đang xử lý tin nhắn đó.
Đoạn mã sau đây sẽ gửi một sự kiện READ cho một thông báo có messageId trùng khớp.
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");
Nhân viên hỗ trợ gửi một sự kiện IS_TYPING
Đối với người dùng, sự kiện này xuất hiện dưới dạng chỉ báo nhập và cho họ biết rằng tác nhân của bạn đang soạn tin nhắn. Chỉ báo nhập liệu sẽ hết hạn sau một khoảng thời gian ngắn (khoảng 20 giây) hoặc khi thiết bị của người dùng nhận được tin nhắn mới từ tác nhân của bạn. Tác nhân của bạn có thể gửi nhiều sự kiện IS_TYPING để đặt lại bộ tính giờ hết hạn của chỉ báo nhập.
Đoạn mã sau đây sẽ gửi một sự kiện 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");