Allows Houston to receive texts via SMS and respond
In your Gemfile
, add:
gem "houston-twilio"
And in config/main.rb
, add:
use :twilio do
sid ENV["HOUSTON_TWILIO_SID"]
token ENV["HOUSTON_TWILIO_TOKEN"]
number ENV["HOUSTON_TWILIO_NUMBER"]
end
And then execute:
$ bundle
To use Houston::Twilio, find your Account SID and Auth Token on Twilio's Console and copy them to the use :twilio
block like this. You may also need to create a phone number for Houston.
use :twilio do
sid "AC00000000000000000000000000000000"
token "00000000000000000000000000000000"
number "+13145555755"
end
You can send texts from Houston with Houston::Twilio.send
:
Houston::Twilio.send "Hi! I'm Baymax, your personal healthcare companion.", to: "+12018880988"
Houston::Conversations.config do
listen_for("hurry up") { |e| e.reply "I am not fast" }
end
Houston can also respond to any texts that are sent to it. It does this by plugging those messages into Houston's Conversations system. To learn more about setting up—and responding to—listeners, see Houston::Conversations's README.
On Twilio's site, you will need to configure your phone number: Select "Webhook" as the way Twilio should handle incoming messages and enter this URL https://YOUR_HOUSTON_HOST/twilio/messages
.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request