Prototype for asking questions on a site, having it go out to an external messaging system, and getting the responses back to the user who asked the question.
Video demo: www.viddler.com/explore/remitaylor/videos/32/
NOTE: This isn’t 100% working, as Jabber::Simple doesn’t like to support multiple connections to the same GTalk server. If the code were ported to use xmpp4r, it should work fine.
This uses GTalk as the externam messaging system.
Run notvark.rb (Sinatra application) and be sure to set the following environment variables:
- USER
-
the GTalk bot username
- PASS
-
the password for the GTalk bot
- HOST
-
the path to the web server, eg. localhost:4567/
To set the recipients (the people who will be IM’d when a question is submitted), edit notvark.rb.
When you submit a question, you should receive an IM, eg.
“Q5: What is your favorite color?”
To reply with an answer, reply with something like:
“A5: Blue”
For questions to be processed, you need to be running the answer_daemon.rb in the background.
sudo gem install shotgun sinatra haml xmpp4r-simple httparty # and the datamapper gems shotgun config.ru