שליחת אירועים

הסוכן שולח אירועי סטטוס למכשיר של המשתמש כדי לדמות אינטראקציות אנושיות. האירועים האלה מוצגים למשתמשים כאישורי קריאה או כסימני כתיבה, כדי להבטיח שההודעות שלהם יעברו עיבוד.

אפשרויות העיצוב והערכים המלאות מפורטות במאמר בנושא 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.

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");
הקוד הזה הוא קטע מנציג לדוגמה של 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.

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");
הקוד הזה הוא קטע מנציג לדוגמה של 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.