إرسال الرسائل

تتواصل وكالات RBM مع المستخدمين من خلال إرسال الرسائل واستلامها. لإرسال رسائل إلى المستخدمين، يرسل الوكيل طلبات رسائل إلى واجهة برمجة التطبيقات RCS Business Messaging. يمكن أن يتضمّن طلب واحد نصًا وبطاقات تفاعلية وملفات وسائط وملفات PDF، بالإضافة إلى ردود مقترَحة وإجراءات مقترَحة.

ستعرض منصة RBM أخطاءً في حالات معيّنة لمساعدتك في إدارة عملية تسليم الرسائل:

  • إذا أرسلت رسالة إلى مستخدم لا يتيح جهازه ميزة 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: الوقت الدقيق الذي تنتهي فيه صلاحية الرسالة بالتوقيت العالمي المنسّق
  • ttl(مدة البقاء): هي المدة الزمنية التي تنتهي فيها صلاحية الرسالة.

للاطّلاع على خيارات التنسيق والقيمة، يُرجى الرجوع إلى AgentMessage.

بعد انتهاء صلاحية الرسالة، تتوقف منصة RBM عن محاولة تسليمها، ويتم إبطالها تلقائيًا. ومع ذلك، قد يتعذّر ذلك في حالات نادرة. على سبيل المثال، يمكن أن تؤدي واجهة برمجة التطبيقات إلى إبطال الرسالة أثناء عملية تسليمها من خلال منصة RBM. للتأكّد مما إذا تم إبطال الرسالة المنتهية الصلاحية بنجاح، سيرسل RBM حدث إشعار إلى رابط الويب الخاص بك.

الحدّ الأقصى لقيمة 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، سيحدث خطأ.

الحدود القصوى لحجم الرسائل

يبلغ الحد الأقصى لحجم السلسلة الكاملة التي تم تحويلها إلى JSON AgentMessage ‏250 كيلوبايت. يبلغ الحد الأقصى لعدد الأحرف في الجزء النصي من الرسالة 3072 حرفًا.

الحد الأقصى لحجم الملف الذي يمكن إرساله من خلال RBM هو 100 ميغابايت. راجِع مقالة ملفات الوسائط وملفات 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.

محتوى الرسالة الأساسية - تحويل الرسائل القصيرة

قدّمت شركات الاتصالات نماذج فوترة لإتاحة نقل الرسائل القصيرة إلى ميزة "مراسلة المؤسسات من خلال خدمات الاتصالات التفاعلية (RBM)". تُعرف رسالة RBM التي تحتوي على ما يصل إلى 160 حرفًا بترميز UTF-8 باسم "رسالة أساسية".

عند إنشاء طلب لإرسال رسالة أساسية، تذكَّر أنّ الأحرف يتم احتسابها على أنّها بايت واحد (UTF-8). في حال إرسال رسالة تحتوي على أحرف خاصة، مثل رموز إيموجي أو مجموعة أحرف متعددة البايت، سيتم احتساب كل حرف على أنّه 2 إلى 4 أحرف UTF-8 أو أكثر.

أدخِل بعض النص في المربّع للتحقّق من طوله:

قد توفّر برامج RCS معاينات للروابط. إذا كانت رسالة RBM نصية فقط تتضمّن عنوان URL لموقع إلكتروني يحتوي على علامات openGraph، قد يتم عرض صورة معاينة توحي بأنّ المحتوى أكثر تفصيلاً.

يُرجى العِلم أنّ عميل RCS قد يسمح للمستخدم بإيقاف معاينات الروابط.

كلمات المرور التي تُستخدَم لمرة واحدة لإثبات هوية المستخدم

يمكنك استخدام RBM لإرسال كلمات مرور صالحة لمرة واحدة (OTP) من أجل التحقّق التلقائي من هوية المستخدم باستخدام واجهة برمجة التطبيقات SMS Retriever API. لا تتوفّر واجهة برمجة تطبيقات مخصّصة لقراءة كلمات المرور لمرة واحدة التي تصل من خلال RBM.

طريقة عملها على Android

بالنسبة إلى تطبيقات Android التي تم تسجيلها باستخدام SMS Retriever API، تستمع واجهة برمجة التطبيقات إلى رسالة RBM منسَّقة بشكل صحيح. يجب أن تحتوي هذه الرسالة على كل من كلمة المرور لمرة واحدة والتجزئة الفريدة التي تحدّد تطبيقك.

عند تلقّي رسالة RBM بالتنسيق الصحيح، تعالجها واجهة برمجة التطبيقات SMS Retriever API كما تعالج كلمة المرور لمرة واحدة عبر الرسائل القصيرة. بعد مطابقة التجزئة مع تطبيقك، يتم استخراج كلمة المرور الصالحة لمرة واحدة وإعادة توجيهها إلى تطبيقك لإجراء عملية التحقّق التلقائي من المستخدم.

  • نموذج رسالة نصية قصيرة من RBM للتحقّق من هوية المستخدم: Your code is <OTP> <app hash>.
  • مثلاً: Your code is 123456 M8tue43FGT.

لمزيد من المعلومات حول SMS Retriever وواجهات برمجة التطبيقات ذات الصلة، يُرجى الاطّلاع على مستندات SMS Retriever. لمعرفة تفاصيل حول التأكّد التلقائي من هوية المستخدم في التطبيقات المسجّلة باستخدام واجهة برمجة التطبيقات SMS Retriever API، يُرجى الاطّلاع على مخطّط سير العمل هذا.

طريقة عمل الميزة على أجهزة iOS

بالنسبة إلى أجهزة iOS، تتعرّف ميزة معالجة كلمات المرور لمرة واحدة (OTP) المضمّنة في النظام تلقائيًا على كلمات المرور لمرة واحدة (OTP) من خلال خدمة &quot;المراسلة الغنية&quot; (RBM) وتقترحها لملء الحقول تلقائيًا، تمامًا مثل كلمات المرور لمرة واحدة (OTP) المستلمة عبر الرسائل القصيرة. لا يلزم إجراء أي عملية دمج محدّدة لواجهة برمجة التطبيقات كي يتمكّن تطبيق iOS من قراءة كلمة المرور الصالحة لمرة واحدة.

ملفات الوسائط وملفات PDF

عند إرسال رسالة تتضمّن صورة أو فيديو أو ملفًا صوتيًا أو ملف PDF، يجب أن يقدّم الوكيل عنوان URL متاحًا للجميع للمحتوى أو أن يحمّل الملف مباشرةً. بالنسبة إلى ملفات الوسائط، يمكنك أيضًا تحديد صورة مصغّرة تتيح للمستخدمين معاينة المحتوى قبل النقر عليه. بالنسبة إلى الملفات الصوتية، يتم استخدام أداة الصوت التلقائية كعنصر نائب.

تخزّن منصة RBM الملفات مؤقتًا لمدة 60 يومًا، وتعرض واجهة برمجة التطبيقات رقم تعريف ملف يمكن أن يدرجه وكيلك في الرسائل التي يرسلها إلى المستخدمين. بعد 60 يومًا، يزيل RBM الملفات من ذاكرة التخزين المؤقت.

عند تحديد الملفات من خلال عنوان URL، من أفضل الممارسات ضبط contentMessage.forceRefresh على false. يؤدي ضبط contentMessage.forceRefresh على true إلى فرض جلب "المراسلة التفاعلية" لمحتوى جديد من عنوان 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.

نوع الوسائط نوع المستند الإضافة متوافق مع البطاقات التفاعلية
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 نعم
الصورة/gif GIF ‎.gif نعم
الصورة/png PNG ‎.png نعم
video/h263 فيديو H263 .h263 نعم
video/m4v فيديو M4V ‎.m4v نعم
الفيديو/mp4 فيديو MP4 ‎.mp4 نعم
video/mpeg4 فيديو MPEG-4 ‫‎.mp4 و‎.m4p نعم
video/mpeg فيديو MPEG .mpeg نعم
video/webm فيديو WEBM ‎.webm نعم

اقتراحات

يرسل الوكيل اقتراحات (ردود مقترَحة وإجراءات مقترَحة) في قوائم شرائح الاقتراحات (الحدّ الأقصى هو 11 اقتراحًا) أو في البطاقات التفاعلية (الحدّ الأقصى هو أربعة اقتراحات).

يجب ألا يزيد عدد أحرف كل اقتراح عن 25 حرفًا.

الردود المقترَحة

ترشد الردود المقترَحة المستخدمين خلال المحادثات من خلال تقديم ردود يعرف وكيلك كيفية التفاعل معها.

عندما ينقر المستخدم على ردّ مقترَح، يتلقّى الوكيل حدثًا يحتوي على نص الردّ وبيانات الإرجاع. يبلغ الحد الأقصى لعدد الأحرف في الحمولة 2048 حرفًا.

مثال

يرسل الرمز التالي نصًا يتضمّن ردّين مقترَحَين. للاطّلاع على خيارات التنسيق والقيمة، يُرجى الرجوع إلى 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 احتياطي لكل إجراء مقترَح (2048 حرفًا كحد أقصى). سيتم فتح عنوان 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 باستخدام WebView.

مثال

يرسل الرمز التالي إجراء فتح عنوان 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 باستخدام WebView

يؤدي إجراء "فتح عنوان URL باستخدام طريقة عرض الويب" إلى تحميل صفحة الويب المحدّدة داخل تطبيق المراسلة باستخدام محرّك العرض التابع للمتصفّح التلقائي. يتيح ذلك للمستخدم التفاعل مع صفحة الويب بدون مغادرة محادثة RBM. إذا كان جهاز المستخدم لا يتوافق مع عروض الويب، سيتم فتح صفحة الويب في متصفّح المستخدم بدلاً من ذلك. لتفعيل عروض الويب، يُرجى الاطّلاع على OpenURLApplication.

تتضمّن عروض الويب ثلاثة أوضاع عرض. للاطّلاع على خيارات التنسيق والقيمة، يُرجى الرجوع إلى WebviewViewMode.

  • ملء الشاشة: تشغل صفحة الويب الشاشة بأكملها
  • نصف الشاشة: تشغل صفحة الويب نصف الشاشة
  • طويل: تشغل صفحة الويب ثلاثة أرباع الشاشة
مثال

يرسل الرمز التالي إجراء "فتح عنوان URL باستخدام WebView". للاطّلاع على خيارات التنسيق والقيمة، يُرجى الانتقال إلى 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 كحد أقصى)

يمكن أن تحتوي البطاقة التفاعلية على كل العناصر المدرَجة، ولكن يجب أن تحتوي البطاقة على صورة أو فيديو أو عنوان واحد على الأقل لتكون صالحة. يمكن أن تحتوي البطاقة التفاعلية على أربعة إجراءات مقترَحة وردود مقترَحة كحد أقصى.

يمكن أن يرسل وكيلك عدة بطاقات تفاعلية معًا في لوحة عرض دوّارة للبطاقات التفاعلية.

يبلغ الحد الأقصى لحجم حمولة البطاقة التفاعلية 250 كيلوبايت. يمكنك الاطّلاع على أفضل الممارسات للحصول على اقتراحات بشأن حجم ملفات الوسائط وحدودها.

يمكنك الاطّلاع على مواصفات البطاقات التفاعلية في مقالة البطاقات التفاعلية.

ارتفاع البطاقة

تتوسّع البطاقات عموديًا لتلائم محتواها. يبلغ الحد الأدنى لارتفاع البطاقات التفاعلية 112 وحدة بكسل مستقلة (DP) والحد الأقصى 344 وحدة بكسل مستقلة (DP). إذا لم يكن محتوى البطاقة كبيرًا بما يكفي لملء الحد الأدنى لطول البطاقة، يتم توسيع البطاقة وملء المساحة الإضافية بمساحة بيضاء.

يجب أن يتناسب ارتفاع الوسائط في البطاقات التفاعلية مع أحد الارتفاعات الثلاثة التالية:

  • قصيرة: 112 وحدة بكسل مستقلة الكثافة
  • متوسطة: 168 وحدة بكسل مستقلة الكثافة
  • طويلة: 264 وحدة بكسل مستقلة الكثافة

إذا لم تتناسب الوسائط مع الأبعاد داخل البطاقة بالنظر إلى الارتفاع المحدّد، يتم اختيار معاينة الوسائط من خلال تكبير الوسائط واقتصاصها.

مثال

ترسل التعليمة البرمجية التالية بطاقة تفاعلية تتضمّن صورة وردودًا مقترَحة. للاطّلاع على خيارات التنسيق والقيمة، يُرجى الرجوع إلى 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.

لوحات العرض الدوّارة للبطاقات التفاعلية

عندما تحتاج إلى عرض خيارات متعددة للمستخدم للاختيار من بينها، استخدِم لوحة عرض دوّارة للبطاقات التفاعلية. تجمع منصات العرض الدوّارة بين عدة بطاقات تفاعلية، ما يتيح للمستخدمين مقارنة العناصر والتفاعل مع كل عنصر على حدة.

يمكن أن تحتوي لوحات العرض الدوّارة على بطاقتَين من البطاقات التفاعلية كحدّ أدنى و10 بطاقات كحدّ أقصى. يجب أن تتوافق البطاقات الغنية بصريًا ضمن لوحات العرض الدوّارة مع المتطلبات العامة للبطاقات الغنية بصريًا من حيث المحتوى والارتفاع. يمكنك الاطّلاع على مواصفات لوحة العرض الدوّارة في البطاقات التفاعلية.

يبلغ الحد الأقصى لحجم حمولة منصة العرض الدوّارة للبطاقات التفاعلية 250 كيلوبايت. يمكنك الاطّلاع على أفضل الممارسات للحصول على اقتراحات بشأن حجم ملفات الوسائط وحدودها.

كما هو الحال مع البطاقات التفاعلية، تؤثر عوامل عديدة (مثل دقة الشاشة وكثافة البكسل وإعدادات المستخدم المفضّلة) في طريقة ظهور البطاقات للمستخدمين النهائيين. في منصّة العرض الدوّارة، يحدّد ارتفاع البطاقات القليلة الأولى ارتفاع جميع البطاقات في منصّة العرض الدوّارة، ويؤثّر ارتفاع البطاقة في اقتطاع العنوان والوصف والاقتراح.

إذا تعذّر على الجهاز عرض جميع عناصر البطاقة بسبب قيود العرض أو ارتفاع البطاقة، سيقتطع 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.