عامل شما رویدادهای وضعیت را به دستگاه کاربر ارسال میکند تا تعاملات انسانی را شبیهسازی کند. برای کاربران، این رویدادها به صورت رسیدهای خوانده شدن یا نشانگرهای تایپ نمایش داده میشوند و به آنها اطمینان میدهند که پیامهایشان در حال پردازش است.
برای قالببندی کامل و گزینههای مقداردهی، به مرجع phones.agentEvents مراجعه کنید.
برای جزئیات بیشتر در مورد رویدادهای وبهوک که نماینده شما از پلتفرم RBM دریافت میکند، به بخش رویدادهای دریافتی مراجعه کنید.
عامل یک رویداد READ ارسال میکند
برای کاربران، این رویداد به عنوان رسید خواندن یک پیام خاص ظاهر میشود. این به کاربر اطلاع میدهد که پلتفرم RBM پیام او را دریافت کرده و عامل در حال پردازش آن است.
کد زیر یک رویداد READ برای پیامی با messageId منطبق ارسال میکند.
حلقه
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' }"
نود جی اس
// 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");
پایتون
# 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)
سی شارپ
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 ارسال میکند.
حلقه
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', }"
نود جی اس
// 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");
پایتون
# 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')
سی شارپ
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");