AnthonyGalli.com
AnthonyGalli.com

Reputation: 2866

Twilio::REST::RequestError: The 'To' number is not a valid phone number

For whatever reason textris gem is removing the "+". How can I stop this?

class UserTexter < Textris::Base
  default :from => "+15616005697"

  def welcome(user)
    @user = user
    text :to => '+' + @user.number # I've also tried hardcoding "+447576912465"
  end
end

console

UserTexter.welcome(u)
+447576912465 # See it has the plus in it
  Rendered user_texter/welcome.text.erb (0.2ms)
=> #<Textris::Message:0x007fbbffc12ee8
 @action=:welcome,
 @content="Welcome to our system!",
 @from_name="L.T.C.",
 @from_phone="17864206788",
 @texter=UserTexter,
 @to=["447576912465"]> # but then it doesn't show here
[18] pry(main)> UserTexter.welcome(u).deliver
+[+447576912465]
  Rendered user_texter/welcome.text.erb (0.6ms)
Twilio::REST::RequestError: The 'To' number 447576912465 is not a valid phone number. # hence why I get the error here
from /Users/galli01anthony/.rvm/gems/ruby-2.1.3/gems/twilio-ruby-4.11.1/lib/twilio-ruby/rest/base_client.rb:125:in `connect_and_send'

welcome_text.erb

<p>Test Text</p>

How can I fix this? What is the root of the problem? I'm using the twilio gem to connect to Twilio API.

Upvotes: 1

Views: 2862

Answers (1)

anmolakhilesh
anmolakhilesh

Reputation: 1683

Check if your Twilio account is in Trial Mode.

If your account is in Trial Mode, you can only send SMS messages to verified numbers.

Upvotes: 3

Related Questions