Sending an SMS using the Nexmo gem

require 'nexmo'

client = Nexmo::Client.new(key: 'API_key', secret: 'API_secret')
response = client.send_message(from: 'Ruby', to: '447724xxxxxx', text: 'Hello world')

if response['messages'][0]['status'] == '0'
  puts "Sent message #{response['messages'][0]['message-id']}"
else
  puts "Error: #{response['messages'][0]['error-text']}"
end

Resources