שליחת הודעות

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

פלטפורמת RCS for Business מחזירה שגיאות במצבים מסוימים כדי לעזור לכם לנהל את מסירת ההודעות:

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

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

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

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

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

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

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

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

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

  • expireTime: השעה המדויקת לפי שעון UTC שבה ההודעה תפוג.
  • ttl(time to live): אורך החיים (TTL) של ההודעה.

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

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

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

אורך החיים (TTL) של הודעה

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

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

אלה ההתראות שצפויות לכם:

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

  • ההודעה לא נמסרה לפני שפג התוקף של ה-TTL: אם פג התוקף של ה-TTL לפני שההודעה מגיעה למכשיר של המשתמש (לדוגמה, המכשיר לא מחובר לאינטרנט), פלטפורמת RCS for Business מנסה לבטל את ההודעה. תקבלו התראה TTL_EXPIRATION_REVOKED שההודעה הוסרה בהצלחה מתור ההמתנה למסירה. במקרה כזה, המשתמש לא יקבל את ההודעה.

המלצות לטיפול במקרים חריגים

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

אלה ההמלצות שלנו לטיפול בהתראות על הודעות לעסק ב-RCS for Business:

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

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

  • הודעה על TTL עם סטטוס אחר: אם קיבלתם הודעה על TTL עם סטטוס אחר, זה מצביע על ניסיון ביטול לא חד-משמעי.

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

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

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

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

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

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

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

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

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

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

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

כדי למנוע צריכת נתונים לא צפויה אצל המשתמשים, הגודל המקסימלי של קובץ שאפשר לשלוח באמצעות RCS for Business הוא 100MiB, והגודל הכולל של כל קובצי המדיה וקבצי ה-PDF המצורפים בהודעה אחת ב-RCS for Business לא יכול להיות גדול מ-100MiB. ‫(1 MiB = 1,048,576 בייטים). מידע נוסף זמין במאמר בנושא קבצים של מדיה ו-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 ל-RCS for Business. הודעה ב-RCS for Business שמכילה עד 160 תווים בקידוד UTF-8 נקראת הודעה בסיסית.

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

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

יכול להיות שיישומי RCS יציגו תצוגה מקדימה של קישורים. אם הודעת RCS for Business שכוללת טקסט בלבד מכילה כתובת URL לאתר עם תגי openGraph, הלקוח יכול ליצור תצוגה מקדימה (תמונה, שם וכו'), וכך לספק חוויה עשירה יותר. לדוגמה, אפשר לראות הודעה בסיסית עם תצוגה מקדימה של כתובת URL.

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

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

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

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

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

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

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

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

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

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

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

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

הגודל המקסימלי של קובץ שאפשר לשלוח הוא 100MiB, והגודל הכולל של כל קובצי המדיה וקובצי ה-PDF המצורפים בהודעה אחת לא יכול לחרוג מ-100MiB.

מפרט התמונות הממוזערות

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

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

שמירת נתונים במטמון וניהול כתובות URL

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

כשמציינים קבצים לפי כתובת URL, מומלץ להגדיר את הערך של contentMessage.forceRefresh ל-false. הגדרה של contentMessage.forceRefresh ל-true מאלצת את RCS לעסקים לאחזר תוכן חדש מכתובת ה-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"
    }
  }
}'

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

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

סוג מדיה סוג המסמך Extension עובד עם כרטיסי תצוגה עשירים
application/ogg אודיו OGG ‎.ogx לא
application/pdf PDF pdf. כן (רק ל-Google Messages בהודו)
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 תווים.

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

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

כשמשתמש לוחץ על הצעה לתשובה, הסוכן מקבל אירוע שמכיל את הטקסט של התשובה ואת נתוני הפוסטבק. המטען הייעודי (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 מאפשרת לכם להפנות משתמשים לדף אינטרנט שהסוכן שלכם מציין. כברירת מחדל, דף האינטרנט נפתח בדפדפן של המשתמש. אפשר גם להגדיר את דף האינטרנט כך שייפתח בתצוגת אינטרנט. פרטים נוספים זמינים במאמר בנושא פתיחת כתובת URL באמצעות WebView.

רק ב-Google Messages

הצגת כתובת ה-URL הבסיסית: כדי לשפר את השקיפות בהודעות A2P, באפליקציית Google Messages מוצגת כתובת ה-URL הבסיסית בהצעות לפעולות מסוג 'פתיחת כתובת URL'. השינוי הזה משפיע על הצעות לפעולות בכרטיסים מתקדמים רגילים ובקרוסלות של כרטיסים מתקדמים.

כרטיס עשיר עם ההצעה &#39;הצגת האתר&#39; וכתובת ה-URL שמוצגת מתחתיה.
כתובת URL בסיסית גלויה

הצגת סמל האפליקציה לקישורי אינטרנט: אם משתמש הגדיר אפליקציה כברירת מחדל לדף אינטרנט, האפליקציה הזו תיפתח במקום הדפדפן או תצוגת האינטרנט, ובכפתור ההצעה יוצג סמל האפליקציה. כדי שסמל האפליקציה יופיע ב-Google Messages, צריך לספק את כתובת ה-URL המלאה והישירה. אם משתמשים בכתובת 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 באמצעות WebView' טוענת את דף האינטרנט שצוין בתוך אפליקציית הודעות באמצעות מנוע העיבוד של דפדפן ברירת המחדל. כך המשתמש יכול ליצור אינטראקציה עם דף האינטרנט בלי לצאת מהשיחה עם העסק ב-RCS. אם המכשיר של המשתמש לא תומך בתצוגות אינטרנט, דף האינטרנט ייפתח בדפדפן של המשתמש במקום זאת. כדי להפעיל את WebView, אפשר לעיין במאמר בנושא 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.

צ'אטים אינטראקטיביים

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

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

כל אחד מהשדות האלה הוא אופציונלי, אבל צריך לכלול לפחות אחד מהשדות 1-3 בכרטיס העשיר.

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

הערה: המטען הייעודי הכולל של צ'אט אינטראקטיבי הוא 250KB.

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

גובה הכרטיס

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

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

  • Shorts: 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.

קרוסלות של צ'אטים אינטראקטיביים

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

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

דוגמה

הקוד הבא שולח קרוסלה של כרטיסים מתקדמים. אפשרויות העיצוב והערכים מפורטות במאמר 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/welcome-bot-sample-images/200.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/welcome-bot-sample-images/201.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/welcome-bot-sample-images/200.jpg';
let card2Image = 'https://storage.googleapis.com/welcome-bot-sample-images/201.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/welcome-bot-sample-images/200.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/welcome-bot-sample-images/201.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/welcome-bot-sample-images/200.jpg';
card_image_2 = 'https://storage.googleapis.com/welcome-bot-sample-images/201.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/welcome-bot-sample-images/200.jpg";
string card2Image = "https://storage.googleapis.com/welcome-bot-sample-images/201.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.