@@ -256,6 +256,27 @@ describe('TwilioMessaging.sendMessage', () => {
256
256
} )
257
257
} )
258
258
259
+ it ( 'should send RCS with messaging service and scheduled send' , async ( ) => {
260
+ nock ( 'https://api.twilio.com' ) . post ( `/2010-04-01/Accounts/${ defaultSettings . accountSID } /Messages.json` , "To=%2B1234567890&SendAt=2025-12-31T23%3A59%3A59Z&MessagingServiceSid=MG5555555555bbbbbb5555555555bbbbbb&Body=Scheduled+message+with+media&MediaUrl=https%3A%2F%2Fexample.com%2Fscheduled-image.png" ) . reply ( 200 , {
261
+ sid : 'SM1234567890abcdef1234567890abcdef' ,
262
+ status : 'scheduled'
263
+ } )
264
+
265
+ await testDestination . testAction ( 'sendMessage' , {
266
+ settings : defaultSettings ,
267
+ mapping : {
268
+ channel : CHANNELS . RCS ,
269
+ senderType : SENDER_TYPE . MESSAGING_SERVICE ,
270
+ toPhoneNumber : '+1234567890' ,
271
+ messagingServiceSid : 'Scheduled Service [MG5555555555bbbbbb5555555555bbbbbb]' ,
272
+ contentTemplateType : 'Inline' ,
273
+ inlineBody : 'Scheduled message with media' ,
274
+ inlineMediaUrls : [ 'https://example.com/scheduled-image.png' ] ,
275
+ sendAt : '2025-12-31T23:59:59Z'
276
+ }
277
+ } )
278
+ } )
279
+
259
280
it ( 'should throw error for invalid phone number format' , async ( ) => {
260
281
await expect (
261
282
testDestination . testAction ( 'sendMessage' , {
@@ -320,4 +341,52 @@ describe('TwilioMessaging.sendMessage', () => {
320
341
} )
321
342
) . rejects . toThrow ( PayloadValidationError )
322
343
} )
344
+
345
+ it ( 'should throw error if RCS send attempted with a phone number (i.e without a Messaging Service)' , async ( ) => {
346
+ await expect (
347
+ testDestination . testAction ( 'sendMessage' , {
348
+ settings : defaultSettings ,
349
+ mapping : {
350
+ channel : CHANNELS . RCS ,
351
+ senderType : SENDER_TYPE . PHONE_NUMBER ,
352
+ toPhoneNumber : '+1234567890' ,
353
+ fromPhoneNumber : '+19876543210' ,
354
+ contentTemplateType : 'Inline' ,
355
+ inlineBody : 'Hello World!'
356
+ }
357
+ } )
358
+ ) . rejects . toThrow ( "The root value is missing the required field 'messagingServiceSid'. The root value must match \"then\" schema." )
359
+ } )
360
+
361
+ it ( 'should send RCS messsage with tags' , async ( ) => {
362
+ const body = "To=%2B1234567890&SendAt=2025-12-31T23%3A59%3A59Z&MessagingServiceSid=MG5555555555bbbbbb5555555555bbbbbb&Body=Scheduled+message+with+media&MediaUrl=https%3A%2F%2Fexample.com%2Fscheduled-image.png&Tags=%7B%22campaign_name%22%3A%22Spring+Sale+2022%22%2C%22message_type%22%3A%22cart_abandoned%22%2C%22number_tag%22%3A%2212345%22%2C%22boolean_tag%22%3A%22true%22%7D"
363
+ nock ( 'https://api.twilio.com' )
364
+ . post ( `/2010-04-01/Accounts/${ defaultSettings . accountSID } /Messages.json` , body )
365
+ . reply ( 200 , {
366
+ sid : 'SM1234567890abcdef1234567890abcdef' ,
367
+ status : 'sent'
368
+ } )
369
+
370
+ await testDestination . testAction ( 'sendMessage' , {
371
+ settings : defaultSettings ,
372
+ mapping : {
373
+ channel : CHANNELS . RCS ,
374
+ senderType : SENDER_TYPE . MESSAGING_SERVICE ,
375
+ toPhoneNumber : '+1234567890' ,
376
+ messagingServiceSid : 'Scheduled Service [MG5555555555bbbbbb5555555555bbbbbb]' ,
377
+ contentTemplateType : 'Inline' ,
378
+ inlineBody : 'Scheduled message with media' ,
379
+ inlineMediaUrls : [ 'https://example.com/scheduled-image.png' ] ,
380
+ sendAt : '2025-12-31T23:59:59Z' ,
381
+ tags : {
382
+ campaign_name : 'Spring Sale 2022' ,
383
+ message_type : 'cart_abandoned' ,
384
+ number_tag : 12345 ,
385
+ boolean_tag : true ,
386
+ null_tag : null ,
387
+ empty_string_tag : ''
388
+ }
389
+ }
390
+ } )
391
+ } )
323
392
} )
0 commit comments