RCS for Business 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 istek metin, Zengin Kartlar, medya ve PDF dosyaları, Önerilen Yanıtlar ve önerilen eylemler içerebilir.
İşletmeler için RCS platformu, mesaj teslimini yönetmenize yardımcı olmak amacıyla belirli durumlarda hatalar döndürür:
- Cihazı RCS'yi desteklemeyen veya cihazında RCS etkin olmayan bir kullanıcıya mesaj gönderirseniz RCS for Business 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.
- Henüz temsilcinizin kullanıma sunulmadığı bir ağda veya RCS trafiğinin etkinleştirilmediği bir ağda bir RCS kullanıcısına mesaj gönderirseniz Business için RCS platformu 404 NOT_FOUND hatası döndürür.
- Kullanıcının cihazının desteklemediği özelliklerle bir mesaj gönderirseniz RCS for Business 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 en iyisidir. İ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
İşletmeler için RCS platformu, alıcı çevrimdışı olsa bile teslimat için mesaj kabul etmeye devam eder. 200 OK yanıtı alırsınız ve RCS for Business platformu mesajı tutar ve 30 gün boyunca yeniden teslim etmeyi dener. RCS for Business'tan mesajı tekrar göndermesini istemenize gerek yoktur.
İşletmeler için RCS, gönderildikten 30 gün sonra teslim edilmeyen tüm mesajları siler.
Aracınızın kullanım alanına bağlı olarak, 30 günlük zaman aşımı süresi dolmadan teslim edilmemiş bir mesajı iptal etmek isteyebilirsiniz. İptal işlemi, çevrimdışı kullanıcıların internete tekrar bağlandıklarında eski bir ileti almasını engelleyebilir. Bir mesajı geri almanın 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, kullanıcıların ihtiyaç duydukları bilgileri zamanında alabilmesi için yedek mesajlaşma stratejinizi devreye sokmak için de iyi bir ipucudur.
İletinin geçerlilik süresini ayarlamak için aracı mesajında aşağıdaki alanlardan birini belirtin:
expireTime: Mesajın süresinin dolduğu UTC cinsinden tam zaman.ttl(geçerlilik süresi): Mesajın süresinin dolması için gereken süre.
Biçimlendirme ve değer seçenekleri için AgentMessage bölümüne bakın.
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.
İletinin geçerlilik süresi (TTL)
Bir RCS for Business mesajı için TTL ayarladığınızda mesajın ne kadar süre boyunca geçerli ve teslim edilebilir olarak kabul edileceğini belirtirsiniz. İleti bu TTL süresi içinde kullanıcının cihazına başarıyla teslim edilmezse İşletmeler için RCS platformu otomatik olarak iptal etmeyi dener.
Mesaj iptali başlattığınızda, RCS for Business platformundan söz konusu mesajın teslim edilmeye çalışılmasını durdurmasını istersiniz. Ancak bu işlem yalnızca gelecekteki teslimat denemelerini etkiler. Kullanıcının cihazı mesajı başarıyla almışsa mesaj işlenir ve İş için RCS platformu, mesajı kullanıcının cihazından geri alamaz.
Bildirimlerle ilgili olarak şunları bekleyebilirsiniz:
TTL içinde teslim edilen mesaj: Kullanıcının cihazı TTL süresi dolmadan önce internete bağlanır ve mesajı alırsa
DELIVEREDbildirimi alırsınız. İleti başarıyla teslim edildiği için iptal bildirimi gönderilmez. Bu, en yaygın ve beklenen senaryodur.İleti, TTL süresi dolmadan teslim edilmedi: TTL süresi, ileti kullanıcının cihazına ulaşmadan önce dolarsa (ör. cihaz çevrimdışıysa) RCS for Business platformu iletiyi iptal etmeye çalışır. Mesajın teslimat kuyruğundan başarıyla kaldırıldığını belirten bir
TTL_EXPIRATION_REVOKEDbildirimi alırsınız. Bu durumda, kullanıcı mesajı almaz.
Sıra dışı durumları ele alma önerileri
Sistemimiz, RCS for Business mesajlarının teslimini ve TTL sürelerinin sona ermesini paralel olarak işler. Bu nedenle, çok nadir de olsa bildirimlerin zamanlamasının beklenmedik olduğu uç durumlarla karşılaşabilirsiniz. Örneğin, hem teslim hem de TTL bildirimi alabilir veya hiçbirini almayabilirsiniz.
RCS for Business mesaj bildirimlerini işleme yönelik önerilerimiz şunlardır:
DELIVEREDbildirimi: Bir ileti içinDELIVEREDbildirimi alırsanız iletinin kullanıcıya ulaştığı onaylanır. Bu iletiyle ilgili sonraki TTL bildirimlerini güvenle göz ardı edebilirsiniz.TTL_EXPIRATION_REVOKEDbildirimi:TTL_EXPIRATION_REVOKEDdurumuyla bir TTL bildirimi alırsanız İş için RCS sistemi, söz konusu mesajın teslimini denemeyi durdurur. Bu iletiyi teslim edilmemiş olarak değerlendirmeli ve gerekirse yedek stratejinize devam etmelisiniz.Diğer durumlarla ilgili TTL bildirimi: Diğer durumlarla ilgili bir TTL bildirimi alırsanız bu, iptal etme girişiminin sonuçsuz kaldığını gösterir.
- Tek kullanımlık şifreler (OTP'ler) gibi önemli mesajlar için yedek yönteminizi başlatın.
- Kritik olmayan iletiler için geri dönüşümün başlatılıp başlatılmayacağına karar verin.
- Bildirim yok: Nadir uç durumlarda sistem, TTL bildirimi gönderemeyebilir ve istemci de teslimat bildirimi oluşturamayabilir. Bu son derece nadir görülen bir durumdur.
Mesaj trafiği türünü ayarlama
RBM API, iletileri kategorize etmek 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 olur. 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 her iletiye içeriğine göre uygun messageTrafficType atayın. İşletmeler için RCS, 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, 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 tamamının maksimum boyutu 250 KB'tır. Mesajın metin kısmı 3.072 karakterle sınırlıdır.
Kullanıcıların beklenmedik veri tüketimini önlemek için İş için RCS üzerinden gönderilebilecek bir dosyanın maksimum boyutu 100 MiB'dir. Tek bir İş için RCS mesajındaki tüm medya ve PDF eklerinin toplam boyutu 100 MiB'i aşmamalıdır. (1 MiB = 1.048.576 bayt). 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 İşletmeler için RCS'ye taşınmasını desteklemek amacıyla faturalandırma modelleri kullanmaya başladı. En fazla 160 UTF-8 karakter içeren bir RCS for Business 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:
Kısa mesaj içeriği ve bağlantı önizlemeleri
RCS istemcileri, bağlantı önizlemelerini uygulayabilir. Yalnızca metin içeren bir RCS for Business mesajı, openGraph etiketleri olan bir web sitesinin URL'sini içeriyorsa istemci, daha zengin bir deneyim sunmak için önizleme (resim, başlık vb.) oluşturabilir. Örneğin, URL önizlemeli temel bir iletiye bakın.
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 seferlik şifreler (OTP'ler) göndermek üzere RCS for Business'ı kullanabilirsiniz. RCS for Business üzerinden gelen OTP'leri okumak için özel bir API yoktur.
Android'de işleyiş şekli
SMS Retriever API'ye kaydedilmiş Android uygulamaları için API, doğru biçimlendirilmiş bir RCS for Business mesajını dinler. Bu mesaj hem OTP'yi hem de uygulamanızı tanımlayan benzersiz bir karma içermelidir.
RCS for Business mesajı doğru biçimde 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 RCS for Business 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 belgelerini inceleyin. 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 tek kullanımlık şifre işleme özelliği, otomatik doldurma için SMS tek kullanımlık şifrelerinde olduğu gibi, RCS for Business tek kullanımlık şifrelerini otomatik olarak algılar ve ö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.
Gönderilebilecek bir dosyanın maksimum boyutu 100 MiB'tir. Tek bir mesajdaki tüm medya ve PDF eklerinin toplam boyutu 100 MiB'i aşmamalıdır.
Küçük resim özellikleri
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.
- Küçük resmin maksimum dosya boyutu 100 KB'tır. Optimum kullanıcı deneyimi için 50 KB veya daha az olmasını öneririz.
- Küçük resmin en boy oranı, orijinal dosyanın oranıyla eşleşmelidir.
Önbelleğe alma ve URL yönetimi
RCS for Business platformu, dosyaları 60 gün boyunca önbelleğe alır ve API, ajanınızın kullanıcılara gönderdiği mesajlara ekleyebileceği bir dosya kimliği döndürür. 60 gün sonra, İşletmeler için RCS 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 RCS for Business'ın belirtilen URL'den yeni içerik getirmesini zorlar. Bu da kullanıcılar için mesaj teslim sürelerini uzatır.
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 JSONcurl -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 JSONcurl -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
İşletmeler için RCS 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 | Evet (yalnızca Hindistan'da Google Mesajlar için) | ||
| 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ılarınız, ö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 sohbetlerde yol gösterir. Bu yanıtlar, aracınızın nasıl tepki vereceğini bildiği yanıtlardır.
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 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 eylemler
Önerilen işlemler, kullanıcıların cihazlarındaki yerleşik işlevlerden 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 diyez işareti (#) içerebilir. E.164 uluslararası standart (ö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şlemi 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'yi açma 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. Web sayfasının bir web görünümünde açılmasını da ayarlayabilirsiniz. Ayrıntılar için Open a URL with webview (Bir URL'yi web görünümüyle açma) başlıklı makaleyi inceleyin.
Yalnızca Google Mesajlar'da
Temel URL'yi gösterme: A2P mesajlaşmada şeffaflığı artırmak için Google Mesajlar, "URL aç" önerilen işlemlerinde temel URL adresini gösterir. Bu değişiklik, standart zengin kartlardaki ve zengin kart karusellerindeki önerilen işlemleri etkiler.
Web bağlantıları için uygulama simgesi gösterimi: Kullanıcı, web sayfası için varsayılan bir uygulama yapılandırdıysa tarayıcı veya web görünümü yerine bu uygulama açılır ve öneri düğmesinde uygulamanın simgesi gösterilir. Uygulama simgesinin Google Mesajlar'da görünmesi için tam ve doğrudan URL'yi sağlamanız gerekir. Kısaltılmış bir URL kullanıyorsanız bunun yerine varsayılan URL'yi aç simgesi gösterilir.
Ö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 sayede kullanıcı, İş için RCS görüşmesinden ayrılmadan web sayfasıyla etkileşimde bulunabilir. Kullanıcının cihazı WebView'ları desteklemiyorsa web sayfası bunun yerine 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 işlemi 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 çiplere önerilen yanıtlar ve önerilen işlemler dahildir.
Çip listeleri en fazla 11 öneri çipi içerir ve her çip etiketi en fazla 25 karakterden oluşabilir.
Biçimlendirme ve değer seçenekleri için AgentContentMessage bölümüne bakın.
Zengin kartlar
Zengin kartlar, medya, metin ve etkileşimli önerileri tek bir mesajda birleştirir. İlgili bilgileri (ör. bir ürünün resmi, adı ve fiyatı) sunmak ve kullanıcılara "Ayrıntıları göster" gibi net bir sonraki adım önerisiyle rehberlik etmek için idealdir.
Zengin kartlar aşağıdakileri içerebilir:
- Medya (resim, GIF veya video)
- Başlık metni
- Açıklama metni
- Önerilen yanıtlar ve önerilen işlemler (en fazla 4)
Bu alanların her biri isteğe bağlıdır ancak 1-3 arasındaki alanlardan en az biri zengin kartta yer almalıdır.
Birden fazla kart, yatay kaydırma bandında birlikte gönderilebilir.
Zengin kartın toplam yükünün 250 KB olduğunu unutmayın.
Teknik ayrıntıların tamamı için Zengin kartlar belgelerine bakın.
Kart yüksekliği
Zengin kartlar, içeriklerine uyacak şekilde dikey olarak genişler. Minimum yükseklikleri 112 DP, maksimum yükseklikleri ise 344 DP'dir. Kart içerikleri, minimum kart yüksekliğini dolduracak kadar büyük değilse kart genişler ve fazladan 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
Medya, seçilen yüksekliğe göre 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 ruloları
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, Zengin kart belgelerinde açıklandığı gibi içerik ve yükseklik açısından genel zengin kart şartlarına uygun olmalıdır. Bant düzeni ve özellikleri hakkında daha fazla bilgi için Bant dokümanlarına bakın.
Ö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/welcome-bot-sample-images/200.jpg", "forceRefresh": false } } }, { "title": "Card #2", "description": "The description for card #2", "suggestions": [ { "reply": { "text": "Card #2", "postbackData": "card_2" } } ], "media": { "height": "MEDIUM", "contentInfo": { "fileUrl": "https://storage.googleapis.com/welcome-bot-sample-images/201.jpg", "forceRefresh": false } } } ] } } } }'
Node.js
// Reference to RBM API helper const rbmApiHelper = require('@google/rcsbusinessmessaging'); // Images for the carousel cards let card1Image = 'https://storage.googleapis.com/welcome-bot-sample-images/200.jpg'; let card2Image = 'https://storage.googleapis.com/welcome-bot-sample-images/201.jpg'; // Define the card contents for a carousel with two cards, each with one suggested reply let cardContents = [ { title: 'Card #1', description: 'The description for card #1', suggestions: [ { reply: { text: 'Card #1', postbackData: 'card_1', } } ], media: { height: 'MEDIUM', contentInfo: { fileUrl: card1Image, forceRefresh: false, }, }, }, { title: 'Card #2', description: 'The description for card #2', suggestions: [ { reply: { text: 'Card #2', postbackData: 'card_2', } } ], media: { height: 'MEDIUM', contentInfo: { fileUrl: card2Image, forceRefresh: false, }, }, }, ]; // Definition of carousel card let params = { msisdn: '+12223334444', cardContents: cardContents, }; // Send the device the carousel card defined above rbmApiHelper.sendCarouselCard(params, function(response) { console.log(response); });
Java
import com.google.api.services.rcsbusinessmessaging.v1.model.CardContent; import com.google.api.services.rcsbusinessmessaging.v1.model.Suggestion; import com.google.rbm.cards.CardOrientation; import com.google.rbm.cards.CardWidth; import com.google.rbm.cards.MediaHeight; import com.google.rbm.RbmApiHelper; import com.google.rbm.SuggestionHelper; … try { // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(); List cardContents = new ArrayList(); // Images for the carousel cards String card1Image = "https://storage.googleapis.com/welcome-bot-sample-images/200.jpg"; // Create suggestions for first carousel card List card1Suggestions = new ArrayList(); card1Suggestions.add( new SuggestionHelper("Card #1", "card_1")); cardContents.add( new StandaloneCardHelper( "Card #1", "The description for card #1", card1Image, card1Suggestions) .getCardContent(MediaHeight.SHORT) ); // Images for the carousel cards String card2Image = "https://storage.googleapis.com/welcome-bot-sample-images/201.jpg"; // Create suggestions for second carousel card List card2Suggestions = new ArrayList(); card2Suggestions.add( new SuggestionHelper("Card #2", "card_2")); cardContents.add( new StandaloneCardHelper( "Card #2", "The description for card #2", card2Image, card2Suggestions) .getCardContent(MediaHeight.SHORT) ); // Send the carousel to the user rbmApiHelper.sendCarouselCards(cardContents, CardWidth.MEDIUM, "+12223334444"); } catch(Exception e) { e.printStackTrace(); }
Python
# Reference to RBM Python client helper and messaging object structure from rcs_business_messaging import rbm_service from rcs_business_messaging import messages # Images for the carousel cards card_image_1 = 'https://storage.googleapis.com/welcome-bot-sample-images/200.jpg'; card_image_2 = 'https://storage.googleapis.com/welcome-bot-sample-images/201.jpg'; # Suggested replies to be used in the cards suggestions1 = [ messages.SuggestedReply('Card #1', 'reply:card_1') ] suggestions2 = [ messages.SuggestedReply('Card #2', 'reply:card_2') ] # Define the card contents for a carousel with two cards, # each with one suggested reply card_contents = [] card_contents.append(messages.CardContent('Card #1', 'The description for card #1', card_image_1, 'MEDIUM', suggestions1)) card_contents.append(messages.CardContent('Card #2', 'The description for card #2', card_image_2, 'MEDIUM', suggestions2)) # Send the device the carousel card defined above carousel_card = messages.CarouselCard('MEDIUM', card_contents) cluster = messages.MessageCluster().append_message(carousel_card) cluster.send_to_msisdn('+12223334444')
C#
using Google.Apis.RCSBusinessMessaging.v1.Data; using RCSBusinessMessaging; using RCSBusinessMessaging.Cards; … // Create an instance of the RBM API helper RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation, projectId); // Image references to be used in the carousel cards string card1Image = "https://storage.googleapis.com/welcome-bot-sample-images/200.jpg"; string card2Image = "https://storage.googleapis.com/welcome-bot-sample-images/201.jpg"; // Suggestion chip lists to be used in carousel cards List<Suggestion> suggestions1 = new List<Suggestion> { new SuggestionHelper("Card #1", "card_1").SuggestedReply() }; List<Suggestion> suggestions2 = new List<Suggestion> { new SuggestionHelper("Card #2", "card_2").SuggestedReply() }; // Create the card content for the carousel List<CardContent> cardContents = new List<CardContent> { // Add items as card content new StandaloneCardHelper( "Card #1", "The description for card #1", card1Image, suggestions1).GetCardContent(), new StandaloneCardHelper( "Card #2", "The description for card #2", card2Image, suggestions2).GetCardContent() }; // Send the carousel to the user rbmApiHelper.SendCarouselCards(cardContents, CardWidth.MEDIUM, msisdn);