אירועים

אירועים הם התראות שהנציג יכול לשלוח ולקבל. יש שלושה סוגים של אירועים:

אירועים שנוצרו על ידי השרת

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

למידע על אפשרויות העיצוב והערך, ראו ServerEvent.

פג התוקף של ההודעה; הביטול בוצע בהצלחה

התוקף של ההודעה פג והיא בוטלה בהצלחה. האירוע הזה יכול להיות טריגר טוב לאסטרטגיה החלופית שלכם להעברת הודעות.

{
  "phoneNumber": [phone number of recipient that the original message was intended for] ,
  "messageId": [RCS message ID of the message],
  "agentId": [bot ID],
  "eventType": "TTL_EXPIRATION_REVOKED",
  "eventId": [unique ID generated by the RBM platform],
  "sendTime": [time at which the server sent this event]
}

פג התוקף של ההודעה; הביטול נכשל

התוקף של ההודעה פג, אבל היא לא בוטלה.

{
  "phoneNumber": [phone number of recipient that the original message was intended for] ,
  "messageId": [RCS message ID of the message],
  "agentId": [bot ID],
  "eventType": "TTL_EXPIRATION_REVOKE_FAILED",
  "eventId": [unique ID generated by the RBM platform],
  "sendTime": [time at which the server sent this event]
}

ההודעה לא מובטחת.

  • אם ההודעה נמסרה, תקבלו אירוע DELIVERED ב-webhook.
  • אם ההודעה לא נמסרה, אפשר להשתמש ב-API לביטול כדי לשלוח בקשת ביטול.

אם ההודעה היא זמנית, כמו סיסמה חד-פעמית (OTP) או התראה על הונאה, מומלץ לשלוח אותה דרך ערוץ חלופי כמו SMS, גם אם הפעולה הזו גורמת לשליחת הודעות כפולות למשתמש.

אירועים שנוצרו על ידי משתמשים

כמו בהודעות למשתמשים ובבדיקות של יכולות, הנציג מקבל את אירועי המשתמשים כקובץ JSON.

למידע על אפשרויות העיצוב והערך, ראו UserEvent.

המשתמש מקבל הודעה דרך נציג תמיכה

האירוע הזה מציין שההודעה נמסרה.

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "eventType": "DELIVERED",
  "eventId": "EVENT_ID",
  "messageId": "MESSAGE_ID",
  "agentId": "AGENT_ID"
}

המשתמש קורא את ההודעה של הנציג

האירוע הזה מציין שהודעה נפתחה או אושרה.

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "eventType": "READ",
  "eventId": "EVENT_ID",
  "messageId": "MESSAGE_ID",
  "agentId": "AGENT_ID"
}

המשתמש מתחיל להקליד

האירוע הזה מצביע על כך שמשתמש מקליד.

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "eventType": "IS_TYPING",
  "eventId": "EVENT_ID",,
  "agentId": "AGENT_ID"
}

המשתמש שולח הודעת טקסט

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "text": "Hi",
  "eventId": "EVENT_ID",
  "agentId": "AGENT_ID"
}

המשתמש שולח קובץ

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "userFile": {
    "payload": {
      "mimeType": "image/gif",
      "fileSizeBytes": 127806,
      "fileUri": "https://storage.googleapis.com/copper_test/77ddb795-24ad-4607-96ae-b08b4d86406a/d2dcc67ab888d34ee272899c020b13402856f81597228322079eb007e8c9",
      "fileName": "4_animated.gif"
    }
  },
  "eventId": "EVENT_ID",,
  "agentId": "AGENT_ID"
}

המשתמש מקיש על הצעה לתשובה

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

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "eventId": "EVENT_ID",
  "agentId": "AGENT_ID",
  "suggestionResponse": {
    "postbackData": "postback_1234",
    "text": "Hello there!"
  }
}

המשתמש מקיש על הצעה לפעולה

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

{
  "senderPhoneNumber": "PHONE_NUMBER",
  "eventId": "EVENT_ID",
  "agentId": "AGENT_ID",
  "suggestionResponse": {
    "postbackData": "postback_1234"
  }
}

אירועים שנוצרו על ידי סוכן

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

למידע על אפשרויות העיצוב והערך, ראו phones.agentEvents.

הנציג שולח אירוע READ

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

הקוד הבא שולח אירוע READ לגבי הודעה עם ערך messageId תואם.

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_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('../libs/rbm_api_helper');

// Send the device an event to indicate that messageId has been read
rbmApiHelper.sendReadMessage('+12223334444', messageId);
הקוד הזה הוא קטע מתוך סוכן לדוגמה של RBM.

Java

import com.google.rbm.samples.lib.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" \
-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('../libs/rbm_api_helper');

// 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.samples.lib.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.