Created
February 17, 2012 06:36
-
-
Save mikebridge/1851316 to your computer and use it in GitHub Desktop.
Adapter from hubot to an A.L.I.C.E pandorabot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chat with hubie. | |
# | |
# hubie <anything> | |
# | |
# don't forget to set HUBOT_PANDORA_BOTID = <botid> | |
QS = require "querystring" | |
module.exports = (robot) -> | |
robot.hear /hubie[,\s]+(.*)/i, (msg) -> | |
user = msg.message.user.name | |
query = msg.match[1] | |
if query | |
botid = process.env.HUBOT_PANDORA_BOTID | |
if !botid | |
msg.send "Please set the HUBOT_PANDORA_BOTID" | |
return | |
data = QS.stringify botid: botid, custid: user, input: query | |
msg.http('http://www.pandorabots.com') | |
.path("/pandora/talk-xml") | |
.header("Content-Type", "application/x-www-form-urlencoded") | |
.post(data) (err, resp, body) -> | |
Parser = require("xml2js").Parser | |
(new Parser).parseString body, (err, json)-> | |
if (!json) | |
msg.send "Uh, oh, my brain is not connected. :(" | |
return | |
msg.send(json.that) |
Found bot id in the website url but it's still not working for me
http://demo.vhost.pandorabots.com/pandora/talk?botid=b0dafd24ee35a477
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Mike
How can I get a PANDORA_BOTID? I tried their website and send a request but only got a response asking me to try playground first and does not look like what you used in this gist.