Closed ram1505 closed 7 years ago
Here is the Heroku log
2017-03-17T07:08:14.727211+00:00 heroku[router]: at=info method=POST path="/redbot/facebook" host=xxxx.herokuapp.com request_id=ed0a7606-xxxxxxxxxxx fwd="173.x.x.x" dyno=web.1 connect=1ms service=3ms status=500 bytes=232 protocol=https 2017-03-17T07:08:14.731115+00:00 app[web.1]: TypeError: Cannot read property 'replace' of undefined 2017-03-17T07:08:14.731131+00:00 app[web.1]: at fixer (/app/node_modules/node-red/node_modules/node-red-contrib-chatbot/lib/facebook/messenger-bot.js:92:20) 2017-03-17T07:08:14.731133+00:00 app[web.1]: at /app/node_modules/node-red/node_modules/node-red-contrib-chatbot/lib/facebook/messenger-bot.js:111:36 2017-03-17T07:08:14.731134+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2017-03-17T07:08:14.731135+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:131:13) 2017-03-17T07:08:14.731135+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3) 2017-03-17T07:08:14.731136+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2017-03-17T07:08:14.731137+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:277:22 2017-03-17T07:08:14.731137+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12) 2017-03-17T07:08:14.731138+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:271:10) 2017-03-17T07:08:14.731139+00:00 app[web.1]: at expressInit (/app/node_modules/express/lib/middleware/init.js:33:5) 2017-03-17T07:08:14.731140+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2017-03-17T07:08:14.731140+00:00 app[web.1]: at trim_prefix (/app/node_modules/express/lib/router/index.js:312:13) 2017-03-17T07:08:14.731141+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:280:7 2017-03-17T07:08:14.731142+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12) 2017-03-17T07:08:14.731142+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:271:10) 2017-03-17T07:08:14.731143+00:00 app[web.1]: at query (/app/node_modules/express/lib/middleware/query.js:44:5) 2017-03-17T07:08:14.731144+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2017-03-17T07:08:14.731144+00:00 app[web.1]: at trim_prefix (/app/node_modules/express/lib/router/index.js:312:13) 2017-03-17T07:08:14.731145+00:00 app[web.1]: at /app/node_modules/express/lib/router/index.js:280:7 2017-03-17T07:08:14.731146+00:00 app[web.1]: at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12) 2017-03-17T07:08:14.731146+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/index.js:271:10) 2017-03-17T07:08:14.731147+00:00 app[web.1]: at Function.handle (/app/node_modules/express/lib/router/index.js:176:3)
@ram1505 I've disabled the token verification, can you try this?
npm install node-red-contrib-chatbot@0.6.20-beta-2
Is this the same as the 0.6.20 just released? I'm getting the following now:
2017-03-17T15:19:24.694180+00:00 heroku[router]: at=info method=POST path="/redbot/facebook" host=xyz.herokuapp.com request_id=8f6xxxxxxxx fwd="17x.x.x" dyno=web.1 connect=0ms service=1ms status=200 bytes=216 protocol=https
However, I don't see any debug messages showing up in Node-red.
@ram1505 yes.
This line in the log is the call from Facebook to the reverse proxy of Heroku, it should proxy the call to an internal address/port of the dyno inside Heroku.
This is why the web hook for Facebook is mounted on the same address/port of Node-RED otherwise you will never be able to use the Facebook webhook and access the Node-RED control panel at the same time (Heroku afaik just redirects one port)
Question: do you see the Node-RED panel? Are you able to access? If not can you check that Node-RED is running on the port where Heroku is supposed to redirect the call (it's stored in a ENV variable)
In 0.6.20 I've added a test endpoint, If you call this
I see this {"status":"ok"}
when I call /redbot/facebook/test
I do see the Node-RED interface. I did configure the entire app flow with facebook in/ out and text message. Here is the flow that I am using in my Heroku Node RED instance with no success.
[{"id":"bc8f75d5.ae5ff8","type":"chatbot-rivescript","z":"55550ca.455b9f4","name":"","script":"! version = 2.0\n+ hello bot\n- Hello human!\n\n","x":343.5,"y":241,"wires":[["4a70199.171b3e8"],[]]}]
If I type https://appname.herokuapp.com/redbot/facebook, I get "Error, wrong validation token". When I type https://appname.herokuapp.com/redbot/facebook/test, I get {"status":"ok"}.
On the Heroku log, I see the following: Webhook URL: http://localhost:46227/redbot/facebook
Just to confirm, I've already checked the Messages check box in the Webhook Field in Facebook.
Is this the only node in the flow? A basic flow for a responder should look like
With a receiver and a sender.
If you wire a debug node to the receiver and you call the https://appname.herokuapp.com/redbot/facebook/test do you get something in the debug console?
This is the only flow in my entire Node Red instance.
I get no response when I wire the debug to receiver/ sender.
EDIT: To be precise, on Node-RED's debug screen, I get no response. However, on the Heroku CLI, I get the following: 2017-03-17T16:31:53.353433+00:00 heroku[router]: at=info method=GET path="/redbot/facebook/test" host=xxxx.herokuapp.com request_id=1xxxxxxxxxxxxxxxxxxx fwd="11x.x.x" dyno=web.1 connect=0ms service=1ms status=304 bytes=144 protocol=http
Can password protecting the Node-RED cause an issue?
@ram1505 the password could be a reason, can you try removing it?
@ram1505 thinking again on this, the password is not responsible otherwise it would block also the /test endpoint. For some reason the body of the request disappears in Heroku. I saw that installing node-red in heroku is not trivial, someone propose wrappers to do it, is there anything that differs from a normal configuration in your machine?
I'm using wrapper based https://elements.heroku.com/buttons/joeartsea/node-red-heroku
OK, I tried Bluemix and I can now get the following on Node-RED debug console:
object chatId: null messageId: "not-a-valid-message-id" userId: null firstName: "Test user first name" lastName: "Test user last name" authorized: true transport: "facebook" message: "This is a test message (will not work with a Facebook Sender node)"
However, I still cannot send/ receive any messages via the FB messenger.
Any idea why this is happening to me and how can I get it working?
OK, now on Heroku, I can get feedback from Node-RED debug when I visit https://myapp.herokuapp.com/redbot/facebook/test.
However, when I try to chat via the FB messenger, I get no response on the NR debug, however, on the command line, I can see something like this each time I type something on FB messenger.
2017-03-20T01:11:47.114466+00:00 heroku[router]: at=info method=POST path="/red/flows" host=my-app.herokuapp.com request_id=xxxxxxxxxxxxxxxxxd fwd="xxx.xxx.xxx.xxx" dyno=web.1 connect=1ms service=37ms status=200 bytes=244 protocol=https
What am I doing wrong? I'm struggling with this since last Friday. I'm getting stuck consistently at the same place on Bluemix as well as on Heroku.
One thing I noticed is, on Heroku, when I save the flow, on CLI, I see
2017-03-20T01:11:47.084931+00:00 app[web.1]: ------ Facebook Webhook ---------------- 2017-03-20T01:11:47.087042+00:00 app[web.1]: Webhook URL: http://localhost:14598/redbot/facebook 2017-03-20T01:11:47.087128+00:00 app[web.1]: Verify token is: secret
whereas, on Bluemix, the webhook url is not on 14598 port.
@ram1505 every time you type a message in the Messenger chat, if the page/webhook was configured correctly, you should see a POST call to /redbot/facebook and not /red/flows. Where this /red/flows comes from?
Were you able to make it work locally? Here is explained how to test FB Messenger locally http://javascript-jedi.com/facebook-messenger-chatbot-redbot/
It works on localhost with ngrok. Even on local host, I can only get one way communication work with Facebook. I can send messages via Messenger and I can get those messages to appear on Node Red debug. However, if I use Rivescript to have a response given to the Messenger, I don't get the response to show up in Messenger. I tried the same flow with Telegram and it works perfectly.
Finally it worked with Bluemix! The problem I was facing was because of the httpStatic page as well as the httpAdmin page. After removing both and leaving node-red running on the root, I can successfully get 2 way communication to work.
That is a good news, good to know for the future.
Facebook send/ receive is not working when I use Heroku. I receive status OK when I visit https://mysite.herokuapp.com/redbot/facebook/_status