For this script, let's pass the number to the script on the command line. To get this argument, let's access the first member of the list ARGV. Ruby Copy the code to = ARGV.first Now we need to create an API client from the Twilio library and use it to send the message. Finish the code with the following lines: Ruby Copy the code client = Twilio::REST::Client.
=
Messages.create( to: to, messaging_service_sid: messaging_service_sid, body: "Hello from your Alpha Sender" ) puts "Message envoyé ! Message sid : #{message.sid}" 11-digit phone number format philippines Run the script on the command line, passing your own phone number ( in E.164 format ). You will then receive a message from your alphanumeric sender.-sms.rb +VOTRE_NUMERO_ICI Congratulations, you have successfully sent yourself a message from your alphanumeric sender! Discover messaging services In this article, you learned how to set up a Messaging Service using an alphanumeric sender and send a message using this service in Ruby.
You can check out the full code in this GitHub repo . Sending a message without a phone number is just one example of what a Messaging Service can do for you. You can also configure your Messaging Service to: Fall back to long code for countries where alphanumeric senders are not supported Select the appropriate number from the number pool for the country you are sending to using Geomatch Distribute messages across numbers in your group to handle sending larger message volumes Always use the same number for a specific end user with Sticky
Bash Copy the code ruby send
-
- Posts: 19
- Joined: Sun Dec 22, 2024 4:29 am