שליחת הודעות

נציגי RBM מתקשרים עם משתמשים באמצעות שליחה וקבלה של הודעות. כדי לשלוח הודעות למשתמשים, נציג השירות שולח בקשות להודעות אל RCS Business Messaging API. בקשה אחת יכולה לכלול טקסט, כרטיסים עשירים, קובצי מדיה ו-PDF, וגם הצעות לתשובות והצעות לפעולות.

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

  • אם שולחים הודעה למשתמש שהמכשיר שלו לא תומך ב-RCS או שלא מופעל בו RCS, פלטפורמת RBM מחזירה את השגיאה 404 NOT_FOUND. במקרה כזה, אפשר לנסות להגיע למשתמש באמצעות שיטות הגיבוי שהוגדרו בתשתית.
  • אם אתם שולחים הודעה למשתמש RCS ברשת שבה הסוכן שלכם עדיין לא הושק, או ברשת שבה תנועת ה-RCS לא הופעלה, פלטפורמת RBM מחזירה שגיאה 404 NOT_FOUND.
  • אם שולחים הודעה עם תכונות שהמכשיר של המשתמש לא תומך בהן, פלטפורמת RBM מחזירה שגיאה 400 INVALID_ARGUMENT ולא מעבירה את ההודעה.

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

הנמען לא מחובר

פלטפורמת RBM עדיין מקבלת הודעה למסירה אם הנמען לא מחובר לאינטרנט. מתקבלת תגובה 200 OK, ופלטפורמת RBM שומרת את ההודעה ומנסה לשלוח אותה מחדש במשך 30 יום. אין צורך לבקש מ-RBM לשלוח את ההודעה שוב.

פרוטוקול RBM מוחק הודעות שלא נמסרו 30 יום אחרי שהן נשלחו.

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

הגדרת תפוגה להודעות

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

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

  • expireTime: השעה המדויקת לפי שעון UTC שבה ההודעה תפוג.
  • ttl(time to live): משך הזמן עד שתוקף ההודעה יפוג.

אפשרויות העיצוב והערכים מפורטות במאמר AgentMessage.

אחרי שהתוקף של ההודעה פג, פלטפורמת RBM מפסיקה לנסות למסור את ההודעה, והיא מבוטלת אוטומטית. עם זאת, במקרים נדירים, יכול להיות שהשיטה הזו לא תצליח. לדוגמה, ה-API יכול להפעיל את הביטול בזמן שפלטפורמת RBM הייתה בתהליך של מסירת ההודעה. כדי לוודא שההודעה שפג תוקפה בוטלה בהצלחה, RBM ישלח אירוע של התראה ל-webhook שלכם.

הערך המקסימלי של ttl ושל expireTime הוא 15 ימים אחרי שליחת ההודעה.

אין ערך מינימלי ל-ttl ול-expireTime, אבל מומלץ להגדיר לפחות 10 שניות אחרי שליחת ההודעה כדי להקטין באופן משמעותי את הסיכוי לקבל התראה על ביטול ועל מסירה.

הגדרת סוג התנועה של ההודעה

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

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

כדי להגדיר את סוג תנועת ההודעות, צריך להקצות את הערך המתאים של messageTrafficType לכל הודעה בהתאם לתוכן שלה. ‫RBM תומך בסוגי התנועה הבאים.

סוג תנועה תוכן ההודעה תרחיש לדוגמה לשימוש בנציג
AUTHENTICATION לאימות הודעות. OTP
TRANSACTION הודעות לגבי שירותים או מוצרים קיימים של משתמש. לדוגמה: אישורים, קבלות על תשלומים או פרטי הזמנה. עסקה או שימוש רב
PROMOTION להודעות שיווקיות כמו מבצעים, הנחות, הודעות או תוכן שיווקי אחר. מבצע או רב-שימושי
SERVICEREQUEST לגבי הודעות על שירותים שהמשתמש ביקש באופן מפורש. סיסמה חד-פעמית, טרנזקציה, קידום מכירות או שימוש רב
ACKNOWLEDGEMENT הודעות שמשמשות לאישור פעולה של משתמש – במיוחד בקשה לביטול הרשמה. זהו אישור לכך שהבקשה של המשתמש התקבלה והיא נמצאת בתהליך עיבוד. סיסמה חד-פעמית, טרנזקציה, קידום מכירות או שימוש רב

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

תרחיש לדוגמה לשימוש בנציג סוג תנועה שמוגדר כברירת מחדל
OTP AUTHENTICATION
עסקאות TRANSACTION
שיווקי PROMOTION
לשימוש רב MESSAGE_TRAFFIC_TYPE_UNSPECIFIED

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

מגבלות על גודל ההודעות

הגודל המקסימלי של המחרוזת המלאה של AgentMessage הוא 250KB. חלק הטקסט של ההודעה מוגבל ל-3,072 תווים.

הגודל המקסימלי של קובץ שאפשר לשלוח דרך RBM הוא 100MB. מידע נוסף זמין במאמר בנושא קבצים של מדיה ו-PDF.

טקסט

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

דוגמה

הקוד הבא שולח הודעת טקסט רגילה. הנחיות לגבי פורמט ואפשרויות ערכים מפורטות במאמר בנושא phones.agentMessages.create.

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!"
  },
  "messageTrafficType": "PROMOTION"
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
};

// Send a simple message to the device
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Send simple text message to user
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444"
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create a simple RBM text message
message_text = messages.TextMessage('Hello, world!')

# Send text message to the device
messages.MessageCluster().append_message(message_text).send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                             projectId);

rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

תוכן של הודעה בסיסית – המרה של SMS

ספקי הסלולר הציגו מודלים לחיוב כדי לתמוך בהעברת הודעות SMS ל-RBM. הודעת RBM שמכילה עד 160 תווים בקידוד UTF-8 נקראת הודעה בסיסית.

כשיוצרים בקשה לשליחת הודעה בסיסית, חשוב לזכור שתווים נספרים כבייט אחד (UTF-8). אם שולחים הודעה שמכילה תווים מיוחדים כמו אמוג'י או מערכת תווים מרובת בייטים, כל תו נחשב כ-2 עד 4 תווים בקידוד UTF-8 או יותר.

כדי לבדוק את האורך של הטקסט, מזינים אותו בתיבה:

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

חשוב לדעת שלקוח RCS עשוי לאפשר למשתמש להשבית את התצוגה המקדימה של הקישור.

סיסמאות חד-פעמיות לאימות משתמשים

אתם יכולים להשתמש ב-RBM כדי לשלוח סיסמאות חד-פעמיות (OTP) לאימות אוטומטי של משתמשים באמצעות SMS Retriever API. אין API ייעודי לקריאת סיסמאות חד-פעמיות שמגיעות דרך RBM.

איך זה עובד ב-Android

באפליקציות ל-Android שנרשמו ל-SMS Retriever API, ה-API מאזין להודעת RBM בפורמט הנכון. ההודעה הזו צריכה להכיל גם את הסיסמה החד-פעמית וגם גיבוב ייחודי שמזהה את האפליקציה שלכם.

כשמתקבלת הודעת RBM בפורמט הנכון, ה-API של SMS Retriever מעבד אותה בדיוק כמו שהוא מעבד קוד אימות חד-פעמי ב-SMS. אחרי שהגיבוב תואם לאפליקציה שלכם, הסיסמה החד-פעמית מחולצת ומועברת לאפליקציה לצורך אימות אוטומטי של המשתמש.

  • הודעת טקסט לדוגמה ב-RBM לאימות משתמש: Your code is <OTP> <app hash>.
  • לדוגמה: Your code is 123456 M8tue43FGT.

מידע נוסף על SMS Retriever ועל ממשקי API קשורים זמין במסמכי התיעוד של SMS Retriever. פרטים על אימות אוטומטי של משתמשים באפליקציות שרשומות ב-SMS Retriever API מופיעים בתרשים הזרימה הזה.

איך זה עובד ב-iOS

ב-iOS, הטיפול המובנה בסיסמאות חד-פעמיות במערכת מזהה באופן אוטומטי סיסמאות חד-פעמיות של RBM ומציע אותן למילוי אוטומטי, בדיוק כמו סיסמאות חד-פעמיות ב-SMS. לא נדרש שילוב ספציפי של API כדי שאפליקציית iOS תוכל לקרוא את הסיסמה החד-פעמית.

קובצי מדיה ו-PDF

כששולחים הודעה עם תמונה, סרטון, אודיו או קובץ PDF, הנציג חייב לספק כתובת URL שזמינה לכל לתוכן או להעלות את הקובץ ישירות. בקבצי מדיה, אפשר גם לציין תמונה ממוזערת שתאפשר למשתמשים לראות תצוגה מקדימה של התוכן לפני שהם לוחצים עליו. לקובצי אודיו, ווידג'ט האודיו שמוגדר כברירת מחדל משמש כ-placeholder.

פלטפורמת RBM שומרת קבצים במטמון למשך 60 ימים, וה-API מחזיר מזהה קובץ שהנציג יכול לכלול בהודעות למשתמשים. אחרי 60 יום, RBM מסיר קבצים מהמטמון.

כשמציינים קבצים לפי כתובת URL, מומלץ להגדיר את הערך של contentMessage.forceRefresh ל-false. הגדרת הערך contentMessage.forceRefresh ל-true מאלצת את RBM לאחזר תוכן חדש מכתובת ה-URL שצוינה, גם אם התוכן של כתובת ה-URL נמצא במטמון, וכך משפרת את זמני מסירת ההודעות למשתמשים.

במאמר בנושא שיטות מומלצות מפורטות המלצות ומגבלות לגבי גודל הקובץ.

דוגמה לכתובת URL של קובץ

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "contentInfo": {
      "fileUrl": "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif",
      "forceRefresh": false
    }
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

let params = {
   fileUrl: 'http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif',
   msisdn: '+12223334444',
};

// Send an image/video to a device
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.AgentContentMessage;
import com.google.api.services.rcsbusinessmessaging.v1.model.AgentMessage;
import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   String fileUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif";

   // create media only message
   AgentContentMessage agentContentMessage = new AgentContentMessage();
   agentContentMessage.setContentInfo(new ContentInfo().setFileUrl(fileUrl));

   // attach content to message
   AgentMessage agentMessage = new AgentMessage();
   agentMessage.setContentMessage(agentContentMessage);

   rbmApiHelper.sendAgentMessage(agentMessage, "+12223334444");
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create media file attachment
file_message = messages.FileMessage('http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif')

messages.MessageCluster().append_message(file_message).send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

string fileUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif";

// Create content info with the file url
ContentInfo contentInfo = new ContentInfo
{
    FileUrl = fileUrl
};

// Attach content info to a message
AgentContentMessage agentContentMessage = new AgentContentMessage
{
    ContentInfo = contentInfo,
};

// Attach content to message
AgentMessage agentMessage = new AgentMessage
{
    ContentMessage = agentContentMessage
};

rbmApiHelper.SendAgentMessage(agentMessage, "+12223334444");
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

אפשרות אחרת היא להעלות את המדיה לפני ששולחים אותה בהודעה באמצעות files.create.

דוגמה להעלאת קובץ

הקוד הבא מעלה קובץ וידאו וקובץ תמונה ממוזערת, ואז שולח את שני הקבצים בהודעה. אפשרויות העיצוב והערכים מפורטות במאמרים בנושא files.create וAgentContentMessage.

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/upload/v1/files?agentId=AGENT_ID" \
-H "Content-Type: video/mp4" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \
--upload-file "FULL_PATH_TO_VIDEO_MEDIA_FILE"

# Capture server-specified video file name from response body JSON


curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/upload/v1/files?agentId=AGENT_ID" \
-H "Content-Type: image/jpeg" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \
--upload-file "FULL_PATH_TO_THUMBNAIL_MEDIA_FILE"

# Capture server-specified image file name from response body JSON


curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "uploadedRbmFile": {
      "fileName": "SERVER-SPECIFIED_VIDEO_FILE_NAME",
      "thumbnailName": "SERVER-SPECIFIED_THUMBNAIL_FILE_NAME"
    }
  }
}'

סוגי מדיה נתמכים

‫RBM תומך בסוגי המדיה הבאים. לתמונות ממוזערות, המערכת תומכת רק בפורמטים image/jpeg,‏ image/jpg,‏ image/gif ו-image/png.

סוג מדיה סוג המסמך Extension עובד עם כרטיסים מתקדמים
application/ogg אודיו OGG ‎.ogx לא
application/pdf PDF ‎.pdf‎ לא
audio/aac אודיו בפורמט AAC ‫‎.aac לא
audio/mp3 MP3 ‎.mp3 לא
audio/mpeg MPEG audio ‎.mpeg לא
audio/mpg MPG ‎.mp3 לא
audio/mp4 אודיו MP4 ‎.mp4 לא
audio/mp4-latm אודיו בפורמט MP4-latm ‎.mp4 לא
audio/3gpp אודיו 3GPP ‫‎.3gp לא
image/jpeg JPEG ‫‎.jpeg,‏ ‎.jpg כן
image/gif GIF ‎.gif כן
image/png PNG ‎.png‎ כן
video/h263 סרטון H263 ‫‎.h263 כן
video/m4v סרטון M4V ‎.m4v כן
video/mp4 סרטון MP4 ‎.mp4 כן
video/mpeg4 סרטון MPEG-4 ‫‎.mp4, .m4p כן
video/mpeg סרטון MPEG ‎.mpeg כן
video/webm סרטון WEBM ‎.webm כן

הצעות

הנציג שולח הצעות (תשובות מוכנות מראש ופעולות מוצעות) ברשימות של צ'יפים עם הצעות (עד 11 הצעות) או בכרטיסים מתקדמים (עד 4 הצעות).

כל הצעה יכולה לכלול עד 25 תווים.

הצעות לתשובות

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

כשמשתמש מקיש על הצעה לתשובה, הנציג מקבל אירוע שמכיל את הטקסט של התשובה ואת נתוני ה-postback. המטען הייעודי (payload) יכול לכלול עד 2,048 תווים.

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!",
    "suggestions": [
      {
        "reply": {
          "text": "Suggestion #1",
          "postbackData": "suggestion_1"
        }
      },
      {
        "reply": {
          "text": "Suggestion #2",
          "postbackData": "suggestion_2"
        }
      }
    ]
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

let suggestions = [
   {
      reply: {
         'text': 'Suggestion #1',
         'postbackData': 'suggestion_1',
      },
   },
   {
      reply: {
         'text': 'Suggestion #2',
         'postbackData': 'suggestion_2',
      },
   },
];

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
   suggestions: suggestions,
};

// Send a simple message with suggestion chips to the device
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;
import com.google.rbm.SuggestionHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();
   suggestions.add(
      new SuggestionHelper("Suggestion #1", "suggestion_1").getSuggestedReply());

   suggestions.add(
      new SuggestionHelper("Suggestion #2", "suggestion_2").getSuggestedReply());

   // Send simple text message to user
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create text message to send to user
text_msg = messages.TextMessage('Hello, world!')
cluster = messages.MessageCluster().append_message(text_msg)

# Append suggested replies for the message to send to the user
cluster.append_suggestion_chip(messages.SuggestedReply('Suggestion #1', 'reply:suggestion_1'))
cluster.append_suggestion_chip(messages.SuggestedReply('Suggestion #2', 'reply:suggestion_2'))

# Send a simple message with suggestion chips to the device
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                             projectId);

List<Suggestion> suggestions = new List<Suggestion>
{
   // Create suggestion chips
   new SuggestionHelper("Suggestion #1", "suggestion_1").SuggestedReply(),
   new SuggestionHelper("Suggestion #2", "suggestion_2").SuggestedReply()
};

// Send simple text message with suggestions to user
rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
   suggestions
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

הצעות לפעולות

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

לכל פעולה מוצעת, אפשר לספק כתובת URL חלופית (עד 2,048 תווים). כתובת ה-URL הזו תיפתח בחלון דפדפן חדש אם המכשיר של המשתמש לא תומך בפעולה המוצעת.

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

אפשרויות העיצוב והערכים מפורטות במאמר בנושא SuggestedAction.

חיוג מספר

הפעולה 'חיוג' מנחה את המשתמש לחייג מספר טלפון שצוין על ידי הנציג. מספרי טלפון יכולים לכלול רק ספרות (0-9), סימן פלוס (+), כוכבית (*) וסולמית (#). יש תמיכה בפורמט הבינלאומי E.164 (לדוגמה, +14155555555), אבל הוא לא נדרש. כלומר, גם +14155555555 וגם 1011 הם ערכים תקינים.

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!",
    "suggestions": [
      {
        "action": {
          "text": "Call",
          "postbackData": "postback_data_1234",
          "fallbackUrl": "https://www.google.com/contact/",
          "dialAction": {
            "phoneNumber": "+15556667777"
          }
        }
      }
    ]
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Define a dial suggested action
let suggestions = [
   {
      action: {
         text: 'Call',
         postbackData: 'postback_data_1234',
         dialAction: {
            phoneNumber: '+15556667777'
         }
      }
   },
];

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
   suggestions: suggestions,
};

// Send a simple message with a dial suggested action
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.DialAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();

   // creating a dial suggested action
   DialAction dialAction = new DialAction();
   dialAction.setPhoneNumber("+15556667777");

   // creating a suggested action based on a dial action
   SuggestedAction suggestedAction = new SuggestedAction();
   suggestedAction.setText("Call");
   suggestedAction.setPostbackData("postback_data_1234");
   suggestedAction.setDialAction(dialAction);

   // attaching action to a suggestion
   Suggestion suggestion = new Suggestion();
   suggestion.setAction(suggestedAction);

   suggestions.add(suggestion);

   // Send simple text message with the suggestion action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create a dial suggested action
suggestions = [
      messages.DialAction('Call', 'reply:postback_data_1234', '+15556667777')
]

# Create text message to send to user
text_msg = messages.TextMessage('Hello, world!')
cluster = messages.MessageCluster().append_message(text_msg)

# Append suggestions for the message to send to the user
for suggestion in suggestions:
    cluster.append_suggestion_chip(suggestion)

# Send a simple message with suggested action to the device
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Create a dial an agent suggested action
DialAction dialAction = new DialAction
{
    PhoneNumber = "+15556667777"
};

// Creating a suggested action based on a dial action
SuggestedAction suggestedAction = new SuggestedAction
{
    Text = "Call",
    PostbackData = "postback_data_1234",
    DialAction = dialAction
};

// Attach action to a suggestion
Suggestion suggestion = new Suggestion
{
    Action = suggestedAction
};

List<Suggestion> suggestions = new List<Suggestion>
{
    suggestion
};

rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
    suggestions
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

הצגת מיקום

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

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!",
    "suggestions": [
      {
        "action": {
          "text": "View map",
          "postbackData": "postback_data_1234",
          "fallbackUrl": "https://www.google.com/maps/@37.4220188,-122.0844786,15z",
          "viewLocationAction": {
            "latLong": {
              "latitude": "37.4220188",
              "longitude": "-122.0844786"
            },
            "label": "Googleplex"
          }
        }
      }
    ]
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Define a view location suggested action
let suggestions = [
   {
      action: {
         text: 'View map',
         postbackData: 'postback_data_1234',
         viewLocationAction: {
            latLong: {
               latitude: 37.4220188,
               longitude: -122.0844786
            },
            label: 'Googleplex'
         }
      }
   },
];

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
   suggestions: suggestions,
};

// Send a simple message with a view location suggested action
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.ViewLocationAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();

   // creating a view location suggested action
   ViewLocationAction viewLocationAction = new ViewLocationAction();
   viewLocationAction.setQuery("Googleplex, Mountain View, CA");

   // creating a suggested action based on a view location action
   SuggestedAction suggestedAction = new SuggestedAction();
   suggestedAction.setText("View map");
   suggestedAction.setPostbackData("postback_data_1234");
   suggestedAction.setViewLocationAction(viewLocationAction);

   // attaching action to a suggestion
   Suggestion suggestion = new Suggestion();
   suggestion.setAction(suggestedAction);

   suggestions.add(suggestion);

   // Send simple text message with the suggestion action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create a view location suggested action
suggestions = [
      messages.ViewLocationAction('View map',
            'reply:postback_data_1234',
            query='Googleplex, Mountain View, CA')
]

# Create text message to send to user
text_msg = messages.TextMessage('Hello, world!')
cluster = messages.MessageCluster().append_message(text_msg)

# Append suggestions for the message to send to the user
for suggestion in suggestions:
    cluster.append_suggestion_chip(suggestion)

# Send a simple message with suggested action to the device
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// create an view location action
ViewLocationAction viewLocationAction = new ViewLocationAction
{
    Query = "Googleplex Mountain View, CA"
};

// Attach the view location action to a suggested action
SuggestedAction suggestedAction = new SuggestedAction
{
    ViewLocationAction = viewLocationAction,
    Text = "View map",
    PostbackData = "postback_data_1234"
};

// Attach the action to a suggestion object
Suggestion suggestion = new Suggestion
{
    Action = suggestedAction
};

List<Suggestion> suggestions = new List<Suggestion>
{
    suggestion
};

rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
    suggestions
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

שיתוף מיקום

פעולת שיתוף המיקום מאפשרת למשתמש לשתף מיקום עם הנציג. המשתמש יכול לשתף את המיקום הנוכחי שלו או מיקום שהוא בחר באופן ידני מתוך אפליקציית מפות Google.

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!",
    "suggestions": [
      {
        "action": {
          "text": "Share your location",
          "postbackData": "postback_data_1234",
          "shareLocationAction": {}
        }
      }
    ]
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Define a share location suggested action
let suggestions = [
   {
      action: {
         text: 'Share your location',
         postbackData: 'postback_data_1234',
         shareLocationAction: {
         }
      }
   },
];

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
   suggestions: suggestions,
};

// Send a simple message with a share location suggested action
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.ShareLocationAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();

   // creating a share location suggested action
   ShareLocationAction shareLocationAction = new ShareLocationAction();

   // creating a suggested action based on a share location action
   SuggestedAction suggestedAction = new SuggestedAction();
   suggestedAction.setText("Share location");
   suggestedAction.setPostbackData("postback_data_1234");
   suggestedAction.setShareLocationAction(shareLocationAction);

   // attaching action to a suggestion
   Suggestion suggestion = new Suggestion();
   suggestion.setAction(suggestedAction);

   suggestions.add(suggestion);

   // Send simple text message with the suggestion action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create a share location suggested action
suggestions = [
      messages.ShareLocationAction('Share location',
            'reply:postback_data_1234')
]

# Create text message to send to user
text_msg = messages.TextMessage('Hello, world!')
cluster = messages.MessageCluster().append_message(text_msg)

# Append suggestions for the message to send to the user
for suggestion in suggestions:
    cluster.append_suggestion_chip(suggestion)

# Send a simple message with suggested action to the device
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Create a share location action
ShareLocationAction shareLocationAction = new ShareLocationAction();

// Attach the share location action to a suggested action
SuggestedAction suggestedAction = new SuggestedAction
{
    ShareLocationAction = shareLocationAction,
    Text = "Share location",
    PostbackData = "postback_data_1234"
};

// Attach the action to a suggestion object
Suggestion suggestion = new Suggestion
{
    Action = suggestedAction
};

List<Suggestion> suggestions = new List<Suggestion>
{
    suggestion
};

rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
    suggestions
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

פתיחת כתובת URL

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

הפעולה Open URL תומכת גם בתצוגות אינטרנט משולבות. מידע נוסף זמין במאמר פתיחת כתובת URL באמצעות תצוגת אינטרנט.

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!",
    "suggestions": [
      {
        "action": {
          "text": "Open Google",
          "postbackData": "postback_data_1234",
          "openUrlAction": {
            "url": "https://www.google.com"
          }
        }
      }
    ]
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Define an open URL suggested action
let suggestions = [
   {
      action: {
         text: 'Open Google',
         postbackData: 'postback_data_1234',
         openUrlAction: {
            url: 'https://www.google.com'
         }
      }
   },
];

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
   suggestions: suggestions,
};

// Send a simple message with an open URL suggested action
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.OpenUrlAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();

   // creating an open url suggested action
   OpenUrlAction openUrlAction = new OpenUrlAction();
   openUrlAction.setUrl("https://www.google.com");

   // creating a suggested action based on an open url action
   SuggestedAction suggestedAction = new SuggestedAction();
   suggestedAction.setText("Open Google");
   suggestedAction.setPostbackData("postback_data_1234");
   suggestedAction.setOpenUrlAction(openUrlAction);

   // attaching action to a suggestion
   Suggestion suggestion = new Suggestion();
   suggestion.setAction(suggestedAction);

   suggestions.add(suggestion);

   // Send simple text message with the suggestion action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create an open url suggested action
suggestions = [
      messages.OpenUrlAction('Open Google',
            'reply:postback_data_1234',
            'https://www.google.com')
]

# Create text message to send to user
text_msg = messages.TextMessage('Hello, world!')
cluster = messages.MessageCluster().append_message(text_msg)

# Append suggestions for the message to send to the user
for suggestion in suggestions:
    cluster.append_suggestion_chip(suggestion)

# Send a simple message with suggested action to the device
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Create an open url action
OpenUrlAction openUrlAction = new OpenUrlAction
{
    Url = "https://www.google.com"
};

// Attach the open url action to a suggested action
SuggestedAction suggestedAction = new SuggestedAction
{
    OpenUrlAction = openUrlAction,
    Text = "Open Google",
    PostbackData = "postback_data_1234"
};

// Attach the action to a suggestion object
Suggestion suggestion = new Suggestion
{
    Action = suggestedAction
};

List<Suggestion> suggestions = new List<Suggestion>
{
    suggestion
};

rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
    suggestions
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

פתיחת כתובת URL באמצעות תצוגת אינטרנט

הפעולה 'פתיחת כתובת URL באמצעות תצוגת אינטרנט' טוענת את דף האינטרנט שצוין בתוך אפליקציית ההודעות, באמצעות מנוע העיבוד של דפדפן ברירת המחדל. כך המשתמש יכול ליצור אינטראקציה עם דף האינטרנט בלי לצאת מהשיחה ב-RBM. אם המכשיר של המשתמש לא תומך בתצוגות אינטרנט, דף האינטרנט ייפתח בדפדפן של המשתמש. כדי להפעיל את תצוגות האינטרנט, אפשר לעיין במאמר בנושא OpenURLApplication.

לתצוגות אינטרנט יש שלושה מצבי תצוגה. אפשרויות העיצוב והערכים מפורטות במאמר בנושא WebviewViewMode.

  • מלא: דף האינטרנט מוצג במסך מלא
  • חצי: דף האינטרנט מוצג בחצי מהמסך
  • גבוה: דף האינטרנט תופס שלושה רבעים מהמסך
דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
 "contentMessage": {
   "text": "Hello, world!",
   "suggestions": [
     {
       "action": {
         "text": "Open Google",
         "postbackData": "postback_data_1234",
         "openUrlAction": {
           "url": "https://www.google.com",
           "application": "WEBVIEW",
           "webviewViewMode": "FULL",
           "description": "Accessibility description"
         }
       }
     }
   ]
 }
}'

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.OpenUrlAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;

  
try {
  
   String URL = "https://www.google.com";
  
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();
  
   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();

   // Create suggestion to view webpage in full mode
   Suggestion viewInFullMode =  getUrlActionInWebview(URL, "FULL")
   suggestions.add(viewInFullMode);
  
   // create suggestion to view webpage in half mode
   Suggestion viewInHalfMode =  getUrlActionInWebview(URL, "HALF")
   suggestions.add(viewInHalfMode);
     
   // create suggestion to view webpage in tall mode
   Suggestion viewInTallMode =  getUrlActionInWebview(URL, "TALL")
   suggestions.add(viewInTallMode);
     
   // Send simple text message with the suggested action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}

  /**
    * Creates a suggested action to open URL in webview.
    *
    * @return a suggestion object for an open URL in webview action .
    */
    private Suggestion getUrlActionInWebview(String url,
                                             String viewMode) {
      // create an open url action
      OpenUrlAction openUrlAction = new OpenUrlAction();
      openUrlAction.setUrl(url);
      openUrlAction.setApplication("WEBVIEW");
      openUrlAction.setWebviewViewMode(viewMode);
      openUrlAction.setDescription("Accessibility description");
     
      // attach the open url action to a suggested action
      SuggestedAction suggestedAction = new SuggestedAction();
      suggestedAction.setOpenUrlAction(openUrlAction);
      suggestedAction.setText('display_text');
      suggestedAction.setPostbackData('postback_data_123');
     
      // attach the action to a suggestion object
      Suggestion suggestion = new Suggestion();
      suggestion.setAction(suggestedAction);
     
      return suggestion;
    }

יצירת אירוע ביומן

הפעולה 'יצירת אירוע ביומן' פותחת את אפליקציית היומן של המשתמש ומתחילה ליצור אירוע חדש עם המידע שצוין.

חובה להזין שם לאירוע ביומן. האורך המקסימלי הוא 100 תווים. התיאור של האירוע ביומן הוא אופציונלי והאורך שלו מוגבל ל-500 תווים.

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "text": "Hello, world!",
    "suggestions": [
      {
        "action": {
          "text": "Save to calendar",
          "postbackData": "postback_data_1234",
          "fallbackUrl": "https://www.google.com/calendar",
          "createCalendarEventAction": {
            "startTime": "2020-06-30T19:00:00Z",
            "endTime": "2020-06-30T20:00:00Z",
            "title": "My calendar event",
            "description": "Description of the calendar event"
          }
        }
      }
    ]
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Define a create calendar event suggested action
let suggestions = [
   {
      action: {
         text: 'Save to calendar',
         postbackData: 'postback_data_1234',
         createCalendarEventAction: {
            startTime: '2020-06-30T19:00:00Z',
            endTime: '2020-06-30T20:00:00Z',
            title: 'My calendar event',
            description: 'Description of the calendar event',
         },
      }
   },
];

let params = {
   messageText: 'Hello, world!',
   msisdn: '+12223334444',
   suggestions: suggestions,
};

// Send a simple message with a create calendar event suggested action
rbmApiHelper.sendMessage(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.CreateCalendarEventAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.SuggestedAction;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();

   // creating a create calendar event suggested action
   CreateCalendarEventAction createCalendarEventAction = new CreateCalendarEventAction();
   calendarEventAction.setTitle("My calendar event");
   calendarEventAction.setDescription("Description of the calendar event");
   calendarEventAction.setStartTime("2020-06-30T19:00:00Z");
   calendarEventAction.setEndTime("2020-06-30T20:00:00Z");

   // creating a suggested action based on a create calendar event action
   SuggestedAction suggestedAction = new SuggestedAction();
   suggestedAction.setText("Save to calendar");
   suggestedAction.setPostbackData("postback_data_1234");
   suggestedAction.setCreateCalendarEventAction(createCalendarEventAction);

   // attaching action to a suggestion
   Suggestion suggestion = new Suggestion();
   suggestion.setAction(suggestedAction);

   suggestions.add(suggestion);

   // Send simple text message with the suggestion action
   rbmApiHelper.sendTextMessage(
      "Hello, world!",
      "+12223334444",
      suggestions
   );
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Create a calendar event suggested action
suggestions = [
      messages.CreateCalendarEventAction('Save to Calendar',
                             'reply:postback_data_1234',
                             '2020-06-30T19:00:00Z',
                             '2020-06-30T20:00:00Z',
                             'My calendar event',
                             'Description of the calendar event')

]

# Create text message to send to user
text_msg = messages.TextMessage('Hello, world!')
cluster = messages.MessageCluster().append_message(text_msg)

# Append suggestions for the message to send to the user
for suggestion in suggestions:
    cluster.append_suggestion_chip(suggestion)

# Send a simple message with suggested action to the device
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Create a calendar event action
CreateCalendarEventAction calendarEventAction = new CreateCalendarEventAction
{
    Title = "My calendar event",
    Description = "Description of the calendar event",
    StartTime = "2020-06-30T19:00:00Z",
    EndTime = "2020-06-30T20:00:00Z"
};

// Attach the calendar event action to a suggested action
SuggestedAction suggestedAction = new SuggestedAction
{
    CreateCalendarEventAction = calendarEventAction,
    Text = "Save to calendar",
    PostbackData = "postback_data_1234"
};

// Attach the action to a suggestion object
Suggestion suggestion = new Suggestion
{
    Action = suggestedAction
};

List<Suggestion> suggestions = new List<Suggestion>
{
    suggestion
};

rbmApiHelper.SendTextMessage(
    "Hello, world!",
    "+12223334444",
    suggestions
);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

רשימת הצעות קשורות

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

הצ'יפים ברשימה הם הצעות לתשובות והצעות לפעולות.

רשימות הצ'יפים יכולות להכיל עד 11 צ'יפים של הצעות, וכל תווית של צ'יפ יכולה להכיל עד 25 תווים.

אפשרויות העיצוב והערכים מפורטות במאמר בנושא AgentContentMessage.

כרטיסים מתקדמים

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

כרטיסים עשירים יכולים להכיל את הפריטים הבאים:

  • תמונה או סרטון
  • טקסט כותרת
  • טקסט תיאור
  • הצעות לתשובות והצעות לפעולות (עד 4)

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

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

הגודל המקסימלי של מטען ייעודי (payload) של כרטיס עשיר הוא 250 KB. במאמר בנושא שיטות מומלצות מפורטות המלצות ומגבלות לגבי גודל קובצי מדיה.

מפרט הצ'אט האינטראקטיבי מופיע במאמר בנושא צ'אטים אינטראקטיביים.

גובה הכרטיס

הכרטיסים מתרחבים אנכית כדי להתאים לתוכן שלהם. הגובה המינימלי של כרטיסים עשירים הוא 112 DP והגובה המקסימלי הוא 344 DP. אם התוכן של כרטיס מסוים לא מספיק גדול כדי למלא את הגובה המינימלי של הכרטיס, הכרטיס יתרחב וימלא את הגובה הנוסף ברווח לבן.

המדיה בכרטיסים עשירים צריכה להתאים לאחד משלושה גבהים:

  • נמוך: 112 DP
  • בינוני: 168 DP
  • גבוה: 264 DP

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

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "richCard": {
      "standaloneCard": {
        "thumbnailImageAlignment": "RIGHT",
        "cardOrientation": "VERTICAL",
        "cardContent": {
          "title": "Hello, world!",
          "description": "RBM is awesome!",
          "media": {
            "height": "TALL",
            "contentInfo":{
              "fileUrl": "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif",
              "forceRefresh": false
            }
          },
          "suggestions": [
            {
              "reply": {
                "text": "Suggestion #1",
                "postbackData": "suggestion_1"
              }
            },
            {
              "reply": {
                "text": "Suggestion #2",
                "postbackData": "suggestion_2"
              }
            }
          ]
        }
      }
    }
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Suggested replies to be used in the card
let suggestions = [
   {
      reply: {
         'text': 'Suggestion #1',
         'postbackData': 'suggestion_1',
      },
   },
   {
      reply: {
         'text': 'Suggestion #2',
         'postbackData': 'suggestion_2',
      },
   },
];

// Image to be displayed by the card
let imageUrl = 'http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif';

// Definition of the card parameters
let params = {
   messageText: 'Hello, world!',
   messageDescription: 'RBM is awesome!',
   msisdn: '+12223334444',
   suggestions: suggestions,
   imageUrl: imageUrl,
   height: 'TALL',
};

// Send rich card to device
rbmApiHelper.sendRichCard(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.StandaloneCard;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.cards.CardOrientation;
import com.google.rbm.cards.MediaHeight;
import com.google.rbm.RbmApiHelper;
import com.google.rbm.SuggestionHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Create suggestions for chip list
   List<Suggestion> suggestions = new ArrayList<Suggestion>();
   suggestions.add(
      new SuggestionHelper("Suggestion #1", "suggestion_1").getSuggestedReply());

   suggestions.add(
      new SuggestionHelper("Suggestion #2", "suggestion_2").getSuggestedReply());

   String imageUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif";

   // Create a standalone rich card to send to the user
   StandaloneCard standaloneCard = rbmApiHelper.createStandaloneCard(
       "Hello, world!",
       "RBM is awesome!",
       imageUrl,
       MediaHeight.MEDIUM,
       CardOrientation.VERTICAL,
       suggestions
   );

   rbmApiHelper.sendStandaloneCard(standaloneCard, "+12223334444");
} catch(Exception e) {
   e.printStackTrace();
}
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Suggested replies to be used in the card
suggestions = [
      messages.SuggestedReply('Suggestion #1', 'reply:suggestion_1'),
      messages.SuggestedReply('Suggestion #2', 'reply:suggestion_2')
]

# Image to be displayed by the card
image_url = 'http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif';

# Define rich card structure
rich_card = messages.StandaloneCard('VERTICAL',
                                    'Hello, world!',
                                    'RBM is awesome!',
                                    suggestions,
                                    image_url,
                                    None,
                                    None,
                                    'MEDIUM')

# Append rich card and send to the user
cluster = messages.MessageCluster().append_message(rich_card)
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;
using RCSBusinessMessaging.Cards;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                             projectId);

List<Suggestion> suggestions = new List<Suggestion>
{
   // Create suggestion chips
   new SuggestionHelper("Suggestion #1", "suggestion_1").SuggestedReply(),
   new SuggestionHelper("Suggestion #2", "suggestion_2").SuggestedReply()
};

string imageUrl = "http://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif";

// Create rich card with suggestions
StandaloneCard standaloneCard = rbmApiHelper.CreateStandaloneCard(
   "Hello, world!",
   "RBM is awesome",
   imageUrl,
   MediaHeight.TALL,
   CardOrientation.VERTICAL,
   suggestions
);

// Send rich card to user
rbmApiHelper.SendStandaloneCard(standaloneCard, "+12223334444");
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

קרוסלות של כרטיסים מתקדמים

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

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

הגודל המקסימלי של מטען ייעודי (payload) של קרוסלת כרטיסים עשירים הוא 250KB. במאמר בנושא שיטות מומלצות מפורטות המלצות ומגבלות לגבי גודל קובצי מדיה.

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

אם מכשיר לא יכול להציג את כל הרכיבים של כרטיס בגלל מגבלות תצוגה או גובה הכרטיס, RBM חותך את הכרטיס עד שהוא יכול להציג אותו במכשיר, לפי הלוגיקה הבאה:

  1. לקצר את התיאור לשורה אחת.
  2. צריך לצמצם את הכותרת לשורה אחת.
  3. ההצעות שלא מתאימות לכרטיס יושמטו, החל מסוף הרשימה המוגדרת.
  4. לא לכלול את התיאור.
  5. לא לכלול את הכותרת.

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

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

דוגמה

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

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages?messageId=MESSAGE_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 '{
  "contentMessage": {
    "richCard": {
      "carouselCard": {
        "cardWidth": "MEDIUM",
        "cardContents": [
          {
            "title": "Card #1",
            "description": "The description for card #1",
            "suggestions": [
              {
                "reply": {
                  "text": "Card #1",
                  "postbackData": "card_1"
                }
              }
            ],
            "media": {
              "height": "MEDIUM",
              "contentInfo": {
                "fileUrl": "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg",
                "forceRefresh": false
              }
            }
          },
          {
            "title": "Card #2",
            "description": "The description for card #2",
            "suggestions": [
              {
                "reply": {
                  "text": "Card #2",
                  "postbackData": "card_2"
                }
              }
            ],
            "media": {
              "height": "MEDIUM",
              "contentInfo": {
                "fileUrl": "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg",
                "forceRefresh": false
              }
            }
          }
        ]
      }
    }
  }
}'

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Images for the carousel cards
let card1Image = 'https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg';
let card2Image = 'https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg';

// Define the card contents for a carousel with two cards, each with one suggested reply
let cardContents = [
   {
      title: 'Card #1',
      description: 'The description for card #1',
      suggestions: [
         {
            reply: {
               text: 'Card #1',
               postbackData: 'card_1',
            }
         }
      ],
      media: {
         height: 'MEDIUM',
         contentInfo: {
            fileUrl: card1Image,
            forceRefresh: false,
         },
      },
   },
   {
      title: 'Card #2',
      description: 'The description for card #2',
      suggestions: [
         {
            reply: {
               text: 'Card #2',
               postbackData: 'card_2',
            }
         }
      ],
      media: {
         height: 'MEDIUM',
         contentInfo: {
            fileUrl: card2Image,
            forceRefresh: false,
         },
      },
   },
];

// Definition of carousel card
let params = {
   msisdn: '+12223334444',
   cardContents: cardContents,
};

// Send the device the carousel card defined above
rbmApiHelper.sendCarouselCard(params, function(response) {
   console.log(response);
});
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Java

import com.google.api.services.rcsbusinessmessaging.v1.model.CardContent;
import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion;
import com.google.rbm.cards.CardOrientation;
import com.google.rbm.cards.CardWidth;
import com.google.rbm.cards.MediaHeight;
import com.google.rbm.RbmApiHelper;
import com.google.rbm.SuggestionHelper;


try {
            // Create an instance of the RBM API helper
            RbmApiHelper rbmApiHelper = new RbmApiHelper();

            List cardContents = new ArrayList();

            // Images for the carousel cards
            String card1Image = "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg";

            // Create suggestions for first carousel card
            List card1Suggestions = new ArrayList();
            card1Suggestions.add(
                new SuggestionHelper("Card #1", "card_1"));

            cardContents.add(
                new StandaloneCardHelper(
                    "Card #1",
                    "The description for card #1",
                    card1Image,
                    card1Suggestions)
                    .getCardContent(MediaHeight.SHORT)
            );

            // Images for the carousel cards
            String card2Image = "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg";

            // Create suggestions for second carousel card
            List card2Suggestions = new ArrayList();
            card2Suggestions.add(
                new SuggestionHelper("Card #2", "card_2"));

            cardContents.add(
                new StandaloneCardHelper(
                    "Card #2",
                    "The description for card #2",
                    card2Image,
                    card2Suggestions)
                    .getCardContent(MediaHeight.SHORT)
            );

            // Send the carousel to the user
            rbmApiHelper.sendCarouselCards(cardContents, CardWidth.MEDIUM, "+12223334444");
        } catch(Exception e) {
            e.printStackTrace();
        }
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
from rcs_business_messaging import messages

# Images for the carousel cards
card_image_1 = 'https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg';
card_image_2 = 'https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg';

# Suggested replies to be used in the cards
suggestions1 = [
      messages.SuggestedReply('Card #1', 'reply:card_1')
]

suggestions2 = [
      messages.SuggestedReply('Card #2', 'reply:card_2')
]

# Define the card contents for a carousel with two cards,
# each with one suggested reply
card_contents = []
card_contents.append(messages.CardContent('Card #1',
                                          'The description for card #1',
                                          card_image_1,
                                          'MEDIUM',
                                          suggestions1))

card_contents.append(messages.CardContent('Card #2',
                                          'The description for card #2',
                                          card_image_2,
                                          'MEDIUM',
                                          suggestions2))

# Send the device the carousel card defined above
carousel_card = messages.CarouselCard('MEDIUM', card_contents)
cluster = messages.MessageCluster().append_message(carousel_card)
cluster.send_to_msisdn('+12223334444')
הקוד הזה הוא קטע מנציג לדוגמה של RBM.

C#‎

using Google.Apis.RCSBusinessMessaging.v1.Data;
using RCSBusinessMessaging;
using RCSBusinessMessaging.Cards;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                             projectId);

// Image references to be used in the carousel cards
string card1Image = "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg";
string card2Image = "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg";

// Suggestion chip lists to be used in carousel cards
List<Suggestion> suggestions1 = new List<Suggestion>
{
   new SuggestionHelper("Card #1", "card_1").SuggestedReply()
};

List<Suggestion> suggestions2 = new List<Suggestion>
{
   new SuggestionHelper("Card #2", "card_2").SuggestedReply()
};

// Create the card content for the carousel
List<CardContent> cardContents = new List<CardContent>
{
   // Add items as card content
   new StandaloneCardHelper(
                    "Card #1",
                    "The description for card #1",
                    card1Image,
                    suggestions1).GetCardContent(),
   new StandaloneCardHelper(
                    "Card #2",
                    "The description for card #2",
                    card2Image,
                    suggestions2).GetCardContent()
};

// Send the carousel to the user
rbmApiHelper.SendCarouselCards(cardContents, CardWidth.MEDIUM, msisdn);
הקוד הזה הוא קטע מנציג לדוגמה של RBM.