jellyfangs / messenger-bot-tutorial

Facebook Messenger bot 15 minute tutorial
MIT License
1.88k stars 542 forks source link

Unable to subscribe app to heroku page #14

Open shurm opened 8 years ago

shurm commented 8 years ago

My issue is with setting up the app page.

When I try to setup the webhook url, it doesn't work.

More specifically, when I used create heroku to create my heroku app the following text appeared "Creating app... done, ancient-lake-88699 https://ancient-lake-88699.herokuapp.com/ | https://git.heroku.com/ancient-lake-88699.git"

So I assume that my CallBack URL should be "https://ancient-lake-88699.herokuapp.com/" or "https://ancient-lake-88699.herokuapp.com/webhook/"

I tried both but I kept getting the error message "The URL couldn't be validated. Callback verification failed with the following errors: HTTP Status Code = 503; HTTP Message = Service Unavailable"

It's bizarre because I went to my heroku dashboard and I can see a tab for "ancient-lake-88699" so I don't understand why this error is happening.

HELP ME! please...

I attached images of my command prompt and heroku dashboard.

heroku_dashboard

explaination

jellyfangs commented 8 years ago

When I try to load up the heroku link it shows the app is broken. Can you paste in what the heroku logs say?

shurm commented 8 years ago

Sure no problem. I tried to open my application and it said the same thing. so I went to view logs on heroku and copyed the text. I hope this help cause im still lost :(

heroku log

mcgingras commented 8 years ago

I'm having the same issue... was any conclusion made on how to solve this problem?

xbklairith commented 8 years ago

Remove all app.get and app.post except root path

app.get('/', function (req, res) {
    res.send('hello world i am a secret bot')
})

it should be ok, if not pls check on heroku

Marisha-Sahay commented 8 years ago

I did this but its still not working for me

neeraj87 commented 7 years ago

@shurm and @Marisha-Sahay I faced this same issue and here is what I did to solve it.

When I tried to run it locally using node index.js it gave me an error saying:

const express = require('express');
SyntaxError: Use of const in strict mode.

So I replaced all const in the code with var

After tha,t I ran it again locally and it gave an error saying: Cannot find module 'request', so I did

npm install request --save

After this, I ran it locally and it gave the message "Hello world, I am a chat bot". I deployed it to Heroku and ran it from there again and it gave the same message. So now the app is working on Heroku. I did the Facebook webhook setup again and it worked.

kostimarko commented 7 years ago

Hi what URL are you using? You should add /webhook/ to your FB URL

codename-47 commented 7 years ago

@neeraj87 I am getting the same problem. my code is running good and I am getting output in local port but when deployed to heroku, I am getting the error message(check the image). Is there something we need to change in the script before deploying it to Heroku? I have no prior knowledge to Heroku cloud. image

neeraj87 commented 7 years ago

@codename-47 few ways to debug.

  1. Have you included the procfile?
  2. install heroku toolbelt on your machine and print out logs: heroku logs --app appname
codename-47 commented 7 years ago

@neeraj87 Thanks. yes, I have included the procfile. However when I am using heroku logs --app appname, heroku is not recognising the app. (chatbot is my app name). Any comments on that? image

neeraj87 commented 7 years ago

On your app's dashboard in heroku, there is a More button near Open App which has View Logs option. Open your app, when it shows the application error then go back and View logs, it will show you the logs on heroku.

Regarding the screenshot above, have you first logged in heroku toolbelt from terminal? Also, are you the primary owner of the app or a collaborator?

codename-47 commented 7 years ago

@neeraj87 What connection string are you providing in the code? I have hardcoded it to my local machine port 5000. That might be the problem?

codename-47 commented 7 years ago

@neeraj87 @Marisha-Sahay @shurm it worked!!! We need to provide start script to "start": "node index.js" in package.json file. Thanks for all the help. image

neeraj87 commented 7 years ago

@codename-47 glad you got it figured out.

Eshpelin commented 6 years ago

Okay so, since I am having the exact same problem, here is what I have to show for now:

Error Received:

The URL couldn't be validated. Callback verification failed with the following errors: HTTP Status Code = 503; HTTP Message = Service Unavailable

Did definitely use:

.../webhook/

The package.json is also configured:

image

Now, the heroku dashboard shows that things are running, but I still get the error page too:

image

Application Page Error:

image

And, here is the latest log:

2018-02-14T23:21:54.685786+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2018-02-14T23:21:54.685947+00:00 app[web.1]: npm ERR!     npm bugs gui-webview
2018-02-14T23:21:54.686279+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2018-02-14T23:21:54.686621+00:00 app[web.1]: npm ERR!     npm owner ls gui-webview
2018-02-14T23:21:54.686965+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2018-02-14T23:21:54.695161+00:00 app[web.1]: 
2018-02-14T23:21:54.695468+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2018-02-14T23:21:54.695355+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2018-02-14T23:21:54.814625+00:00 heroku[web.1]: State changed from starting to crashed
2018-02-14T23:22:37.464232+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/webhook/?hub.mode=subscribe&hub.challenge=1669061154&hub.verify_token=connect123" host=gradconnect-signup-bot.herokuapp.com request_id=18da082a-629b-479a-8af7-49ed206fbbb1 fwd="69.171.225.21" dyno= connect= service= status=503 bytes= protocol=https
2018-02-14T23:28:58.183029+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gradconnect-signup-bot.herokuapp.com request_id=619e38e1-d6d5-4456-adb0-2a5572957fb0 fwd="45.127.50.230" dyno= connect= service= status=503 bytes= protocol=https

Any idea what I might still be doing wrong?