يرسل الوكيل أحداث الحالة إلى جهاز المستخدم لمحاكاة التفاعلات البشرية. بالنسبة إلى المستخدمين، تظهر هذه الأحداث على شكل إشعارات بالقراءة أو مؤشرات الكتابة، ما يؤكّد لهم أنّه تتم معالجة رسائلهم.
للاطّلاع على خيارات التنسيق والقيم الكاملة، يُرجى الرجوع إلى مرجع phones.agentEvents.
للاطّلاع على تفاصيل أحداث Webhook التي يتلقّاها الوكيل من منصة RBM، يُرجى الرجوع إلى تلقّي الأحداث.
يرسل الوكيل حدث READ
يظهر هذا الحدث للمستخدمين على شكل إشعار بالقراءة لرسالة معيّنة. ويُعلم المستخدم بأنّ منصة RBM قد سلّمت رسالته وأنّ الوكيل يعالجها.
يتم الاحتفاظ بأحداث READ وتخزينها لمدة 30 يومًا. إذا كان لدى المستخدم ميزة "خدمات الاتصالات التفاعلية" (RCS) مفعّلة ولكن لا يمكن الوصول إليه، يتم وضع الحدث في قائمة الانتظار. إذا لم تكن ميزة "خدمات الاتصالات التفاعلية" (RCS) مفعّلة، تعرض منصة RCS للأعمال خطأ NOT_FOUND (HTTP 404).
يرسل الرمز التالي حدث READ لرسالة تتضمّن 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);
جافا
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");
يرسل الوكيل حدث IS_TYPING
يظهر هذا الحدث للمستخدمين على شكل مؤشر كتابة ويُعلمهم بأنّ الوكيل يكتب رسالة. تنتهي صلاحية مؤشر الكتابة بعد فترة قصيرة (20 ثانية تقريبًا) أو عندما يتلقّى جهاز المستخدم رسالة جديدة من الوكيل. يمكن للوكيل إرسال أحداث IS_TYPING متعدّدة لإعادة ضبط مؤقت انتهاء صلاحية مؤشر الكتابة.
أحداث IS_TYPING مؤقتة ولا يتم وضعها في قائمة الانتظار.
يرسل الرمز التالي حدث 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!'); });
جافا
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");