إرسال الأحداث

يرسل الوكيل أحداث الحالة إلى جهاز المستخدم لمحاكاة التفاعلات البشرية. بالنسبة إلى المستخدمين، تظهر هذه الأحداث كإشعارات بالقراءة أو مؤشرات كتابة، ما يؤكّد لهم أنّه يتم معالجة رسائلهم.

للاطّلاع على خيارات التنسيق والقيم الكاملة، يُرجى الرجوع إلى مرجع phones.agentEvents.

للاطّلاع على تفاصيل حول أحداث Webhook التي يتلقّاها برنامجك من منصة RBM، راجِع تلقّي الأحداث.

يرسل موظّف الدعم حدث READ

بالنسبة إلى المستخدمين، يظهر هذا الحدث كإشعار استلام لرسالة معيّنة. تتيح هذه الحالة للمستخدم معرفة أنّ منصة RBM قد سلّمت رسالته وأنّ الوكيل يعالجها.

يرسل الرمز التالي حدث 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);
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

جافا

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");
هذا الرمز هو مقتطف من وكيل نموذجي في 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)
هذا الرمز هو مقتطف من وكيل نموذجي في 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");
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

يرسل الوكيل حدث IS_TYPING

يظهر هذا الحدث للمستخدمين كمؤشر كتابة، ويُعلمهم بأنّ وكيلك يكتب رسالة. تنتهي صلاحية مؤشر الكتابة بعد فترة قصيرة (حوالي 20 ثانية) أو عندما يتلقّى جهاز المستخدم رسالة جديدة من الوكيل. يمكن أن يرسل برنامجك عدة أحداث 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!');
});
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.

جافا

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");
هذا الرمز هو مقتطف من وكيل نموذجي في 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')
هذا الرمز هو مقتطف من وكيل نموذجي في 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");
هذا الرمز هو مقتطف من وكيل نموذجي في RBM.