Confuse in "Setup the Bot"
Do I need to "create an environmental variable" and is "for local development" means OPTIONAL? If this step is not optional but essential, how to done the step "config var access at runtime"?
And the next problem is how to "Add a function to echo back messages"?
In the first image under Setup the Bot, there's this line of code:
const token = "<PAGE_ACCESS_TOKEN>"
The tutorial advises you not to do it. It works, but it's not good programming practice to have credentials within the source code. Ergo, discard that line. Do not add it to your index.js file.
Now, type heroku config:set FB_PAGE_ACCESS_TOKEN=fake-access-token-dhsa09uji4mlkasdfsd in the terminal from your working directory.
You get the token from
developers.facebook.com/apps --> appID --> messenger (generate & save a token from your FB page).
Heroku now has your page token as an environmental variable. To access the token during runtime, add the following line to your index.js file
const token = process.env.FB_PAGE_ACCESS_TOKEN
Accessing the token through an environmental variable is a better programming practice. I'm not quite sure, but I think it has something to do with security.
To add a function to echo back messages, copy-paste jw84's code into your index.js file.