Skip to content

Instantly share code, notes, and snippets.

@DanyF-github
Created February 16, 2021 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyF-github/952e23ca0283c80d42458c30d3f96d89 to your computer and use it in GitHub Desktop.
Save DanyF-github/952e23ca0283c80d42458c30d3f96d89 to your computer and use it in GitHub Desktop.
require 'vonage'
module Web
module Controllers
module Home
class Create
include Web::Action
def call(params)
client = Vonage::Client.new(
application_id: ENV['VONAGE_APPLICATION_ID'],
private_key: ENV['VONAGE_PRIVATE_KEY']
)
response = client.voice.create(
to: [{
type: 'phone',
number: params[:number]
}],
from: {
type: 'phone',
number: ENV['VONAGE_NUMBER']
},
ncco: [{
action: 'talk',
text: params[:message],
language: params[:language]
}]
)
redirect_to '/success'
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment