diff options
| author | mokha <mokha@cisco.com> | 2018-04-27 11:15:00 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2018-04-27 11:15:00 -0600 |
| commit | b86b1ad7f2fd3d0c5d7947393e27ab8a005a2b00 (patch) | |
| tree | a973e3daa5a209f761831215244013f68badc42f | |
| parent | a5e011651a7233921ccceec5f1a94a8282f8d2e6 (diff) | |
start ngrok tunnel.
| -rw-r--r-- | incognito.gemspec | 7 | ||||
| -rw-r--r-- | lib/incognito/cli/sms_command.rb | 2 | ||||
| -rw-r--r-- | lib/incognito/sms_server.rb | 25 |
3 files changed, 30 insertions, 4 deletions
diff --git a/incognito.gemspec b/incognito.gemspec index 38d2055..7534551 100644 --- a/incognito.gemspec +++ b/incognito.gemspec @@ -22,10 +22,11 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "dotenv", "~> 2.2" - spec.add_dependency "twilio-ruby", "~> 5.8" - spec.add_dependency "thor", "~> 0.20" - spec.add_dependency "sinatra", "~> 2.0" + spec.add_dependency "ngrok-tunnel", "~> 2.1" spec.add_dependency "puma", "~> 3.11" + spec.add_dependency "sinatra", "~> 2.0" + spec.add_dependency "thor", "~> 0.20" + spec.add_dependency "twilio-ruby", "~> 5.8" spec.add_development_dependency "bundler", "~> 1.16" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "minitest", "~> 5.0" diff --git a/lib/incognito/cli/sms_command.rb b/lib/incognito/cli/sms_command.rb index 98fdf9f..6b5db48 100644 --- a/lib/incognito/cli/sms_command.rb +++ b/lib/incognito/cli/sms_command.rb @@ -26,7 +26,7 @@ module Incognito def server require 'incognito/sms_server' SmsServer.set :shell, self - SmsServer.run! + SmsServer.boot_up! end private diff --git a/lib/incognito/sms_server.rb b/lib/incognito/sms_server.rb index 485ef6b..b918d97 100644 --- a/lib/incognito/sms_server.rb +++ b/lib/incognito/sms_server.rb @@ -1,11 +1,14 @@ require 'sinatra' require 'sinatra/base' +require 'ngrok/tunnel' class SmsServer < Sinatra::Base + PORT=ENV.fetch("PORT", 4567) configure do disable :logging set :server, :puma set :shell, $shell + set :port, PORT end get '/' do @@ -25,6 +28,28 @@ class SmsServer < Sinatra::Base end end + def self.boot_up! + Ngrok::Tunnel.start(addr: "localhost:#{PORT}") + puts "***" * 10 + banner = <<-BANNER +Configure your webhook URL +For Twilio to know where to look, you need to configure your Twilio phone number +to call your webhook URL whenever a new message comes in. + +1. Log into twilio.com and go to the Numbers page in the Console. +2. Click on your SMS-enabled phone number. +3. Find the Messaging section. The default “CONFIGURE WITH” is what you’ll need: "Webhooks/TwiML." +4. In the “A MESSAGE COMES IN” section, select "Webhook" and paste in the URL you want to use: +#{Ngrok::Tunnel.ngrok_url_https} +5. Set the HTTP verb to GET. + + + BANNER + puts banner + puts "***" * 10 + run! + end + private def shell |
