Reputation: 742
Can't seem to get my Twilio rails app to send sms. Here's the controller configured to handle Twilio Smss:
When I play around with this using localtunnel hosting my Twilio number will receive smss and correctly create Sms class instances. But when it enters the else
block, it doesn't actually send a reply sms. The number is in @sms.from is a simple cell in the '+1xxxxxxxxxx' format. Any ideas why this doesn't work? I've checked their API and seem to be following it to the T.
class SmsController < ApplicationController
def index
end
def create
@sms = Sms.create(:from => params['From'], :body=> params['Body'], :to=>params["To"], :uri=>params['Uri'])
if Answer.exists?(params['Body'].to_i)
@answer = Answer.find(params['Body'].to_i)
binding.pry
@answer.upvote
else
@message = client.account.sms.messages.create(
:from => '+13473217539',
:to => @sms.from,
:body => "Sorry that wasn't a valid option"
)
puts @message
binding.pry
end
render :nothing => true
end
end
Upvotes: 0
Views: 501
Reputation: 1633
require 'rubygems'
require 'net/smtp'
require 'sendsms'
w2s = SendSms.new "username","password"
w2s.send "send number", "sms content"
Upvotes: 1
Reputation: 742
Found out the problem, this gem interferes with the Twilio client. Do NOT use it in development:
group :development, :test do
gem 'sms-spec'
Upvotes: 0