简体   繁体   中英

Add Post support to Hubot

I am trying to add the http-post-say.coffee script to a hubot app which is hosted on Heroku.

The documentation indicates that once you add the script then it creates the '/hubot/say' route which accepts post requests in the following format.

curl -X POST http://localhost:8080/hubot/say -d message=lala -d room='#dev'

I added the script and modified the url but I received the following error: Cannot POST /hubot/say

My next step was to add some dependencies. I noticed that other apps using robot.router.post had these dependencies.

"htmlparser": "1.7.6",
"connect": "2.3.4",
"connect_router": "1.8.6",
"scoped-http-client": "0.9.7"

I deployed my changes but I still receive Cannot POST /hubot/say when I try to hit that route.

Is there anything that I'm missing? I'm not very familiar with Node.js or hubot.

To load a built-in script in Hubot, you must add it to hubot-scripts.json , eg:

["http-post-say.coffee"]

(Since the script itself looks fine and it sounds like you've pushed to Heroku (restarting Hubot) it's the only thing I can think of that would explain it not working.)

You have to understand that once you push your code on to heroku and make it run there, the URL no longer would be localhost but the actual heroku URL related to the machine that was created when you did heroku create .

The URL should look something like:

curl -X POST `http://herokumachinename/hubot/say -d message=lala -d room='#dev'`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM