A kitchen-sink LINE bot example
Install npm dependencies:
npm install
Also, FFmpeg and ImageMagick should be installed to test image and video echoing.
Create .env file in the root folder with these variables.
CHANNEL_SECRET=YOUR_CHANNEL_SECRET
CHANNEL_ACCESS_TOKEN=YOUR_CHANNEL_ACCESS_TOKEN
BASE_URL=https://your.base.url # remove BASE_URL if you run it locally
PORT=80
npm start
With the configuration above, the webhook listens on https://your.base.url:80/callback
.
ngrok tunnels external requests to localhost, helps debugging local webhooks.
This example includes ngrok inside, and it just works if no BASE_URL
is
set. Make sure that other configurations are set correctly.
❯ npm start
...
It seems that BASE_URL is not set. Connecting to ngrok...
listening on https://ffffffff.ngrok.io/callback
The URL can be directly registered as the webhook URL in LINE Developers console.