אירועים

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

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

פלטפורמת 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&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.