Skip to content

Commit 8d60296

Browse files
authored
Adding failover snippet to messages examples (#117)
1 parent 3118cb8 commit 8d60296

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'dotenv/load'
2+
require 'vonage'
3+
4+
VONAGE_APPLICATION_ID = ENV['VONAGE_APPLICATION_ID']
5+
VONAGE_PRIVATE_KEY = ENV['VONAGE_PRIVATE_KEY']
6+
RCS_SENDER_ID = ENV['RCS_SENDER_ID']
7+
SMS_SENDER_ID = ENV['SMS_SENDER_ID']
8+
MESSAGES_TO_NUMBER = ENV['MESSAGES_TO_NUMBER']
9+
10+
client = Vonage::Client.new(
11+
application_id: VONAGE_APPLICATION_ID,
12+
private_key: VONAGE_PRIVATE_KEY
13+
)
14+
15+
rcs_message = client.messaging.rcs(
16+
to: MESSAGES_TO_NUMBER,
17+
from: RCS_SENDER_ID,
18+
type: 'text',
19+
message: 'This is an RCS text message sent via the Vonage Messages API'
20+
)
21+
22+
sms_message = client.messaging.sms(
23+
to: MESSAGES_TO_NUMBER,
24+
from: SMS_SENDER_ID,
25+
message: 'This is a failover SMS message in case the RCS message is rejected.'
26+
)
27+
28+
client.messaging.send(
29+
**rcs_message,
30+
failover: [sms_message]
31+
)

0 commit comments

Comments
 (0)