RBM temsilcileri, mesaj gönderip alarak kullanıcılarla iletişim kurar. Temsilciniz, kullanıcılara mesaj göndermek için RCS Business Messaging API'ye mesaj istekleri gönderir. Tek bir istekte metin, rich card'lar, medya ve PDF dosyalarının yanı sıra önerilen yanıtlar ve önerilen işlemler yer alabilir.
RBM platformu, mesaj teslimini yönetmenize yardımcı olmak için belirli durumlarda hatalar döndürür:
- Cihazı RCS'yi desteklemeyen veya RCS'nin etkin olmadığı bir kullanıcıya mesaj gönderirseniz RBM platformu 404 NOT_FOUND hatası döndürür. Bu durumda, altyapınızda tanımlanan yedek yöntemlerle kullanıcıya ulaşmayı deneyebilirsiniz.
- Temsilcinizin henüz kullanıma sunulmadığı veya RCS trafiğinin etkinleştirilmediği bir ağda bir RCS kullanıcısına mesaj gönderirseniz RBM platformu 404 NOT_FOUND hatası döndürür.
- Kullanıcının cihazının desteklemediği özelliklerle bir mesaj gönderirseniz RBM platformu 400 INVALID_ARGUMENT hatasını döndürür ve mesajınızı teslim etmez.
Çok kanallı mesajlaşma stratejinizin bir parçası olarak, makul bir süre sonra teslim edilmeyen mesajları iptal etmeniz ve farklı bir kanal üzerinden göndermeniz önerilir. İletileri önceden tanımlanmış bir zamanda otomatik olarak iptal etmek için ileti geçerlilik süresi ayarlayın.
Alıcı internete bağlı değil
Alıcı çevrimdışı olsa bile RBM platformu, teslimat için mesaj kabul etmeye devam eder. 200 OK yanıtı alırsınız ve RBM platformu mesajı 30 gün boyunca bekletip yeniden teslim etmeyi dener. RBM'den mesajı tekrar göndermesini istemenize gerek yoktur.
RBM, teslim edilmeyen mesajları gönderildikten 30 gün sonra siler.
Aracınızın kullanım alanına bağlı olarak, bu 30 günlük zaman aşımı süresinden önce teslim edilmemiş bir mesajı iptal etmek isteyebilirsiniz. İptal işlemi, çevrimdışı kullanıcıların tekrar internete bağlandıklarında eski bir mesaj almasını önleyebilir. Bir mesajı iptal etmenin birden fazla yolu vardır:
- İptal işlemini tetiklemek için iptal isteği gönderin.
- İletiyi uygun zamanda otomatik olarak iptal etmek için ileti geçerlilik bitiş tarihi belirleyin.
İleti için geçerlilik bitiş tarihi belirleme
Temsilcinizin mesajı zamana duyarlı mı? Örneğin, tek kullanımlık şifreler yalnızca kısa bir süre için geçerlidir. Sınırlı süreli tekliflerin süresi dolar. Randevu hatırlatıcıları da randevu tarihinden sonra alakalı değildir. İletilerin zamanında ve alakalı kalması için ileti geçerliliğini ayarlayın. Bu, çevrimdışı kullanıcıların tekrar internete bağlandıklarında eski içerik almasını önleyebilir. Son kullanma tarihi, yedek mesajlaşma stratejinizi devreye sokmak için de iyi bir ipucudur. Böylece kullanıcılar ihtiyaç duydukları bilgileri zamanında alabilir.
İletinin geçerlilik süresini ayarlamak için aracı mesajında aşağıdaki alanlardan birini belirtin:
expireTime
: İletinin süresinin dolduğu UTC cinsinden tam saat.ttl
(geçerlilik süresi): İletinin süresinin dolmasına kadar geçen süre.
Biçimlendirme ve değer seçenekleri için AgentMessage
bölümüne bakın.
Mesajın süresi dolduğunda RBM platformu mesajı teslim etmeyi durdurur ve mesaj otomatik olarak iptal edilir. Ancak bu durum nadiren başarısız olabilir. Örneğin, API, RBM platformu mesajı iletme sürecindeyken iptal işlemini tetikleyebilir. RBM, süresi dolmuş mesajın başarıyla iptal edilip edilmediğini onaylamak için webhook'unuza bir bildirim etkinliği gönderir.
ttl
ve expireTime
için maksimum değer, mesaj gönderildikten sonraki 15 gündür.
ttl
ve expireTime
için minimum değer olmasa da hem iptal hem de teslimat bildirimi alma olasılığını önemli ölçüde azaltmak için mesaj gönderildikten sonra en az 10 saniye beklenmesi önerilir.
İleti trafiği türünü ayarlama
RBM API, iletileri sınıflandırmak için messageTrafficType
alanını içerir.
Temsilci kullanım alanları, temsilci davranışını ve hangi işletme kurallarının geçerli olduğunu tanımlamaya devam ederken messageTrafficType
, mesaj içeriğinin daha ayrıntılı şekilde sınıflandırılmasına olanak tanır. Sonuç olarak, tek bir temsilcinin birden fazla kullanım alanını yönetmesi mümkün olacaktır. Mevcut aracı kullanım alanları veya iş kuralları şu anda bu durumdan etkilenmemektedir.
Bu alan isteğe bağlıdır ancak alan zorunlu hale geldiğinde hata almamak için şimdi ayarlamanız önerilir.
İleti trafiği türünü ayarlamak için içeriğine göre her iletiye uygun
messageTrafficType
değerini atayın. RBM aşağıdaki trafik türlerini destekler.
Trafik türü | Mesaj içeriği | Temsilci kullanım alanı |
---|---|---|
AUTHENTICATION |
Kimlik doğrulama iletileri için. | OTP |
TRANSACTION |
Kullanıcının mevcut hizmetleri veya ürünleriyle ilgili mesajlar Örneğin: onaylar, ödeme makbuzları veya rezervasyon ayrıntıları. | İşlem veya çoklu kullanım |
PROMOTION |
Teklifler, indirimler, duyurular veya diğer tanıtım amaçlı içerikler gibi tanıtım mesajları için. | Promosyon amaçlı veya çok kullanımlı |
SERVICEREQUEST |
Kullanıcının açıkça talep ettiği hizmetlerle ilgili mesajlar | OTP, Transactional, Promotional, or Multi-use |
ACKNOWLEDGEMENT |
Kullanıcının işlemini (özellikle abonelikten çıkma isteği) onaylamak için kullanılan mesajlar Bu e-posta, kullanıcının isteğinin alındığını ve işleme alındığını onaylar. | OTP, Transactional, Promotional, or Multi-use |
Trafik türü ayarlanmamışsa sistem, aracının kullanım alanı için varsayılan türü atar.
Temsilci kullanım alanı | Varsayılan trafik türü |
---|---|
OTP | AUTHENTICATION |
İşlemsel (Transactional) | TRANSACTION |
Tanıtım amaçlı | PROMOTION |
Çok kullanımlı | MESSAGE_TRAFFIC_TYPE_UNSPECIFIED |
Çok kullanımlı aracıların varsayılan trafik türü yoktur. Her ileti için trafik türünü içeriğine göre açıkça ayarlamanız gerekir. MESSAGE_TRAFFIC_TYPE_UNSPECIFIED
değerini değiştirmezseniz hata oluşur.
İleti boyutu sınırları
Dizgeleştirilmiş AgentMessage'ın maksimum boyutu 250 KB'tır. İletinin metin kısmı 3.072 karakterle sınırlıdır.
RBM üzerinden gönderilebilecek maksimum dosya boyutu 100 MB'tır. Daha fazla bilgi için Medya ve PDF dosyaları başlıklı makaleyi inceleyin.
Metin
En basit mesajlar metinden oluşur. Kısa mesajlar, görsel, karmaşık etkileşim veya yanıt gerektirmeden bilgi iletmek için en uygun yöntemdir.
Örnek
Aşağıdaki kod, düz metin mesajı gönderir. Biçimlendirme ve değer seçenekleri için phones.agentMessages.create
bölümüne bakın.
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); });
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(); }
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')
C#
using RCSBusinessMessaging; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); rbmApiHelper.SendTextMessage( "Hello, world!", "+12223334444", );
Temel mesaj içeriği - SMS dönüşümü
Operatörler, SMS mesajlarının RBM'ye taşınmasını desteklemek için faturalandırma modelleri kullanmaya başladı. En fazla 160 UTF-8 karakteri içeren RBM mesajına Temel Mesaj adı verilir.
Temel Mesaj gönderme isteği oluştururken karakterlerin 1 bayt (UTF-8) olarak sayıldığını unutmayın. Emoji veya çok baytlı karakter kümesi gibi özel karakterler içeren bir mesaj gönderirseniz her karakter 2-4 UTF-8 karakteri veya daha fazla olarak sayılır.
Uzunluğunu kontrol etmek için kutuya metin girin:
Temel mesaj içeriği ve bağlantı önizlemeleri
RCS istemcileri, bağlantı önizlemelerini uygulayabilir. Yalnızca metin içeren bir RBM mesajında Open Graph etiketleri olan bir web sitesinin URL'si varsa daha zengin içerik izlenimi veren bir önizleme resmi gösterilebilir.
RCS istemcisinin, kullanıcının bağlantı önizlemelerini devre dışı bırakmasına izin verebileceğini unutmayın.
Kullanıcı doğrulaması için tek kullanımlık şifreler
SMS Retriever API ile otomatik kullanıcı doğrulaması için tek kullanımlık şifreler (OTP'ler) göndermek üzere RBM'yi kullanabilirsiniz. RBM üzerinden gelen tek kullanımlık şifreleri okumak için özel bir API yoktur.
Android'de işleyiş şekli
SMS Retriever API'ye kaydedilmiş Android uygulamalarında API, doğru biçimlendirilmiş bir RBM mesajını dinler. Bu mesaj hem OTP'yi hem de uygulamanızı tanımlayan benzersiz bir karma içermelidir.
Doğru biçimde bir RBM mesajı alındığında SMS Retriever API, bu mesajı SMS OTP gibi işler. Karma, uygulamanızla eşleştirildikten sonra OTP çıkarılır ve otomatik kullanıcı doğrulaması için uygulamanıza iletilir.
- Kullanıcı doğrulaması için örnek RBM kısa mesajı:
Your code is <OTP> <app hash>.
- Örnek:
Your code is 123456 M8tue43FGT.
SMS Retriever ve ilgili API'ler hakkında daha fazla bilgi edinmek için SMS Retriever belgelerine bakın. SMS Retriever API'ye kaydedilen uygulamalarda otomatik kullanıcı doğrulaması hakkında ayrıntılı bilgi için bu akış şemasına bakın.
iOS'te işleyiş şekli
iOS'te sistemin yerleşik OTP işleme özelliği, SMS OTP'leri gibi otomatik doldurma için RBM OTP'lerini otomatik olarak algılayıp önerir. iOS uygulamasının OTP'yi okuması için özel bir API entegrasyonu gerekmez.
Medya ve PDF dosyaları
Resim, video, ses veya PDF dosyası içeren bir mesaj gönderdiğinizde temsilciniz, içeriğin herkese açık bir URL'sini sağlamalı ya da dosyayı doğrudan yüklemelidir. Medya dosyaları için, kullanıcıların içeriği tıklamadan önce önizlemesini sağlayan bir küçük resim de belirtebilirsiniz. Ses dosyaları için varsayılan ses widget'ı yer tutucu olarak kullanılır.
RBM platformu, dosyaları 60 gün boyunca önbelleğe alır ve API, temsilcinizin kullanıcılara gönderdiği iletilere ekleyebileceği bir dosya kimliği döndürür. RBM, 60 gün sonra dosyaları önbellekten kaldırır.
Dosyaları URL'ye göre belirtirken contentMessage.forceRefresh
değerini false
olarak ayarlamak en iyi uygulamadır. contentMessage.forceRefresh
ayarını true
olarak ayarlamak, URL içeriği önbelleğe alınmış olsa bile RBM'nin belirtilen URL'den yeni içerik getirmesine neden olur. Bu da kullanıcılar için mesaj teslim sürelerini uzatır.
Dosya boyutu önerileri ve sınırları için en iyi uygulamalara göz atın.
Dosya URL'si örneği
Aşağıdaki kod bir resim gönderir. Biçimlendirme ve değer seçenekleri için AgentContentMessage
bölümüne bakın.
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); });
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(); }
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')
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");
Alternatif olarak, medyayı files.create
iletisiyle göndermeden önce yükleyebilirsiniz.
Dosya yükleme örneği
Aşağıdaki kod, bir video dosyası ve bir küçük resim dosyası yükler, ardından her iki dosyayı da mesaj olarak gönderir. Biçimlendirme ve değer seçenekleri için files.create
ve AgentContentMessage
bölümlerine bakın.
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" } } }'
Desteklenen medya türleri
RBM aşağıdaki medya türlerini destekler. Küçük resimler için yalnızca image/jpeg, image/jpg, image/gif ve image/png desteklenir.
Medya türü | Doküman türü | Uzantı | Zengin kartlarla çalışma |
---|---|---|---|
application/ogg | OGG ses | .ogx | Hayır |
application/pdf | Hayır | ||
audio/aac | AAC ses | .aac | Hayır |
ses/mp3 | MP3 ses biçimi | .mp3 | Hayır |
ses/mpeg | MPEG ses | .mpeg | Hayır |
ses/mpg | MPG ses | .mp3 | Hayır |
ses/mp4 | MP4 ses biçimi | .mp4 | Hayır |
ses/mp4-latm | MP4-latm ses | .mp4 | Hayır |
ses/3gpp | 3GPP ses | .3gp | Hayır |
image/jpeg | JPEG | .jpeg, .jpg | Evet |
image/gif | GIF | .gif | Evet |
image/png | PNG | .png | Evet |
video/h263 | H263 video | .h263 | Evet |
video/m4v | M4V video | .m4v | Evet |
video/mp4 | MP4 video | .mp4 | Evet |
video/mpeg4 | MPEG-4 video | .mp4, .m4p | Evet |
video/mpeg | MPEG videosu | .mpeg | Evet |
video/webm | WEBM videosu | .webm | Evet |
Öneriler
Aracı, öneri çipi listelerinde (en fazla 11 öneri) veya zengin kartlarda (en fazla dört öneri) öneriler (önerilen yanıtlar ve önerilen işlemler) gönderir.
Her öneri en fazla 25 karakter uzunluğunda olabilir.
Önerilen yanıtlar
Önerilen yanıtlar, kullanıcılara temsilcinizin nasıl tepki vereceğini bildiği yanıtlar sunarak sohbetlerde yol gösterir.
Kullanıcı, önerilen bir yanıta dokunduğunda temsilciniz, yanıtın metnini ve geri gönderme verilerini içeren bir etkinlik alır. Yük en fazla 2.048 karakter uzunluğunda olabilir.
Örnek
Aşağıdaki kod, iki önerilen yanıt içeren bir metin gönderir. Biçimlendirme ve değer seçenekleri için SuggestedReply
başlıklı makaleyi inceleyin.
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); });
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(); }
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')
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 );
Önerilen işlemler
Önerilen işlemler, kullanıcıların cihazlarının yerleşik işlevlerinden yararlanarak sohbetlerde yol gösterir. Aracınız, kullanıcıların bir numarayı aramalarını, haritada bir konumu açmalarını, konum paylaşmalarını, bir URL'yi açmalarını veya takvim etkinliği oluşturmalarını önerebilir.
Her önerilen işlem için isteğe bağlı olarak bir yedek URL (en fazla 2.048 karakter) sağlayabilirsiniz. Bu URL, kullanıcının cihazı önerilen işlemi desteklemiyorsa yeni bir tarayıcı penceresinde açılır.
Kullanıcı, önerilen bir işleme dokunduğunda aracınız, işlemin geri gönderme verilerini içeren bir etkinlik alır.
Biçimlendirme ve değer seçenekleri için SuggestedAction
bölümüne bakın.
Numara çevir
Çevirme işlemi, kullanıcıyı aracınız tarafından belirtilen bir telefon numarasını çevirmeye yönlendirir.
Telefon numaraları yalnızca rakam (0-9
), artı işareti (+
), yıldız işareti (*
) ve diyezi (#
) içerebilir. E.164 uluslararası biçimi (örneğin, +14155555555
) desteklenir ancak zorunlu değildir. Yani hem +14155555555
hem de 1011
geçerli girişlerdir.
Örnek
Aşağıdaki kod, arama işlemi gönderir. Biçimlendirme ve değer seçenekleri için DialAction
bölümüne bakın.
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); });
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(); }
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')
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 );
Konum görüntüleme
Konumu görüntüle işlemi, kullanıcının varsayılan harita uygulamasında bir konum gösterir. Konumu enlem ve boylam değerleriyle veya kullanıcının mevcut konumuna dayalı bir sorguyla belirtebilirsiniz. Harita uygulamasında gösterilen raptiye için özel bir etiket de ayarlayabilirsiniz.
Örnek
Aşağıdaki kod, bir görüntüleme konumu işlemi gönderir. Biçimlendirme ve değer seçenekleri için ViewLocationAction
bölümüne bakın.
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); });
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(); }
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')
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 );
Konum paylaşın
Konum paylaşma işlemi, kullanıcının konumunu temsilcinizle paylaşmasına olanak tanır. Kullanıcı, Haritalar uygulamasında mevcut konumunu veya manuel olarak seçtiği bir konumu paylaşabilir.
Örnek
Aşağıdaki kod, konum paylaşma işlemini gönderir. Biçimlendirme ve değer seçenekleri için ShareLocationAction
bölümüne bakın.
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); });
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(); }
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')
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 );
URL açma
URL Aç işlemi, kullanıcıları temsilciniz tarafından belirtilen bir web sayfasına yönlendirmenize olanak tanır. Web sayfası varsayılan olarak kullanıcının tarayıcısında açılır. Kullanıcı, web sayfası için varsayılan bir uygulama yapılandırdıysa bunun yerine bu uygulama açılır. Bu durumda, önerilen işlem düğmesindeki simge, uygulamanın simgesi olur.
URL açma işlemi, entegre web görünümlerini de destekler. URL'yi web görünümüyle açma başlıklı makaleyi inceleyin.
Örnek
Aşağıdaki kod, açık URL işlemi gönderir. Biçimlendirme ve değer seçenekleri için OpenUrlAction
bölümüne bakın.
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); });
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(); }
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')
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 );
URL'yi web görünümüyle açma
Open URL with webview (URL'yi web görünümüyle aç) işlemi, belirtilen web sayfasını varsayılan tarayıcınızın oluşturma motoruyla birlikte mesajlaşma uygulamasına yükler. Bu, kullanıcının RBM görüşmesinden ayrılmadan web sayfasıyla etkileşimde bulunmasına olanak tanır. Kullanıcının cihazı web görünümlerini desteklemiyorsa web sayfası kullanıcının tarayıcısında açılır. Web görünümlerini etkinleştirmek için OpenURLApplication
başlıklı makaleyi inceleyin.
WebView'ların üç görüntüleme modu vardır. Biçimlendirme ve değer seçenekleri için WebviewViewMode
bölümüne bakın.
- Tam: Web sayfası tam ekranı kaplar.
- Yarım: Web sayfası, ekranın yarısını kaplar.
- Uzun: Web sayfası, ekranın dörtte üçünü kaplar.
Örnek
Aşağıdaki kod, web görünümü işlemiyle bir URL açma isteği gönderir. Biçimlendirme ve değer seçenekleri için OpenURLAction
başlıklı makaleyi inceleyin.
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; }
Takvim etkinliği oluşturma
Takvim etkinliği oluşturma işlemi, kullanıcının takvim uygulamasını açar ve belirtilen bilgilerle yeni bir etkinlik oluşturmaya başlar.
Takvim etkinliği başlığı gereklidir. En fazla 100 karakter uzunluğunda olabilir. Takvim etkinliği açıklaması isteğe bağlıdır ve en fazla 500 karakter uzunluğunda olabilir.
Örnek
Aşağıdaki kod, takvim etkinliği oluşturma işlemini gönderir. Biçimlendirme ve değer seçenekleri için CreateCalendarEventAction
başlıklı makaleyi inceleyin.
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); });
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(); }
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')
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 );
Öneri çipi listesi
Temsilciniz, kullanıcıların sonraki işlemlerine rehberlik etmek için iletilerle birlikte öneri çipi listeleri gönderir. Çip listesi yalnızca ilişkili mesaj ileti dizisinin en altında olduğunda gösterilir. Görüşmedeki sonraki mesajlar (kullanıcıdan veya temsilcinizden gelen) çip listesinin üzerine yazılır.
Listedeki çipler önerilen yanıtlar ve önerilen işlemlerdir.
Çip listeleri en fazla 11 öneri çipi içerir ve her çip etiketi en fazla 25 karakter olabilir.
Biçimlendirme ve değer seçenekleri için AgentContentMessage
bölümüne bakın.
Zengin kartlar
İlgili bilgilerin, medyanın veya önerilerin bir bölümünü göndermeniz gerektiğinde zengin kart göndermelisiniz. Zengin kartlar, temsilcinizin tek bir mesajda birden fazla bilgi birimi göndermesine olanak tanır.
Zengin kartlar aşağıdaki öğeleri içerebilir:
- Resim veya video
- Başlık metni
- Açıklama metni
- Önerilen yanıtlar ve önerilen işlemler (en fazla 4)
Zengin kartlar, listelenen tüm öğeleri içerebilir ancak geçerli olması için kartta en az bir resim, video veya başlık bulunmalıdır. Zengin kart en fazla dört önerilen işlem ve önerilen yanıt içerebilir.
Aracılarınız, zengin kart bandında birden fazla zengin kartı birlikte gönderebilir.
Zengin kart yükünün maksimum boyutu 250 KB'tır. Medya dosyası boyutu önerileri ve sınırları için en iyi uygulamaları inceleyin.
Zengin kart spesifikasyonlarını Zengin kartlar bölümünde bulabilirsiniz.
Kart yüksekliği
Kartlar, içeriklerine uyacak şekilde dikey olarak genişler. Zengin kartların yüksekliği en az 112 DP, en fazla 344 DP olmalıdır. Bir kartın içeriği, minimum kart yüksekliğini dolduracak kadar büyük değilse kart genişler ve ek yüksekliği boşlukla doldurur.
Rich kartlardaki medya, üç yükseklikten birine uygun olmalıdır:
- Kısa: 112 DP
- Orta: 168 DP
- Yüksek: 264 DP
Seçilen yüksekliğe göre medya, karttaki boyutlara uymuyorsa medya önizlemesi, medyayı yakınlaştırıp kırparak seçilir.
Örnek
Aşağıdaki kod, resim ve önerilen yanıtlar içeren bir zengin kart gönderir. Biçimlendirme ve değer seçenekleri için RichCard
bölümüne bakın.
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); });
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(); }
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')
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");
Zengin kart bantları
Kullanıcıya aralarından seçim yapabileceği birden fazla seçenek sunmanız gerektiğinde zengin kart içeren bir dönen öğe kullanın. Bantlar, birden fazla zengin kartı bir araya getirerek kullanıcıların öğeleri karşılaştırmasına ve her birine ayrı ayrı tepki vermesine olanak tanır.
Döngüler en az iki, en fazla on zengin kart içerebilir. Bantlardaki zengin kartlar, içerik ve yükseklik açısından genel zengin kart koşullarına uygun olmalıdır. Carousel spesifikasyonlarını Zengin kartlar bölümünde bulabilirsiniz.
Zengin kart rulosu yükünün maksimum boyutu 250 KB'tır. Medya dosyası boyutu önerileri ve sınırları için en iyi uygulamaları inceleyin.
Kısaltma
Zengin kartlarda olduğu gibi, kartların son kullanıcılara nasıl görüneceğini etkileyen birçok faktör (ör. ekran çözünürlüğü, piksel yoğunluğu ve kullanıcı tercihleri) vardır. Ancak bantta, ilk birkaç kartın yüksekliği banttaki tüm kartların yüksekliğini tanımlar ve kart yüksekliği başlık, açıklama ve öneri kesmesini etkiler.
Bir cihaz, ekran kısıtlamaları veya kart yüksekliği nedeniyle bir kartın tüm öğelerini görüntüleyemiyorsa RBM, aşağıdaki mantığı kullanarak kartı cihazda görüntülenebilecek şekilde kısaltır:
- Açıklamayı tek satıra indirin.
- Başlığı tek satıra indirin.
- Tanımlanan listenin sonundan başlayarak karta sığmayan önerileri atlayın.
- Açıklamayı atlayın.
- Başlığı atlayın.
Başlıkların ve açıklamaların kısaltılmaması için bunları mümkün olduğunca kısa tutun. Dikey medya için başlık ve açıklama ya da bir öneri kullanın. Orta medya için en fazla iki öneri kullanın. Kısa medya için en fazla üç öneri kullanın. Dört öneri sığdırmak için karta medya eklemeyin.
Kartların içerik boyutunu ve uzunluğunu yaklaşık olarak eşit tutun. Gerekirse sonraki kartlarda kısaltma olmaması için karoseli daha büyük kartlarla doldurun.
Örnek
Aşağıdaki kod, zengin kart bandı gönderir. Biçimlendirme ve değer seçenekleri için RichCard
bölümüne bakın.
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); });
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(); }
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')
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);