Build LINE Bot web application with Node.js and Heroku


In order to check the operation of the LINE Bot web application that using the LINE Messaging API, you need a server that can be accessed externally.
This post shares the creation procedure of LineBot web application using Heroku.

Basic flow

1. Heroku development environment

For web online development environment, Heroku + Cloud 9 is recommended.
Please refer to the following article for the procedure from Heroku’s account registration to “Hello World!”.
※ Note the domain “” generated above.

2. LINE Business account

Please refer to the following:

わずか5分。新LINE Messaging APIでbotを作ってみた手順全公開


① Be sure to set the following in the LINE Business account request setting.

② In “Webhook URL” setting of LINE Developers setting page, input: domain + ‘/webhook’ [] and save it.
※ webhook:The callBack process is created in Step 3.
Channel Secret and アクセストークン are required afterwards.

3.LINE Bot program creation

① Install necessary packages in Console.
> npm install @line/bot-sdk –s 
> npm install express –s

② Overwrite and save the contents of “app.js” created in 【1. Heroku development environment】.

③ Set defaultAccessToken and defaultSecret with Channel Secret and アクセストークン noted  in [2. LINE Business account] ,Alternatively, set CHANNEL_ACCESS_TOKEN and CHANNEL_SECRET to Heroku’s Settings / Config Variables.

④ Deploy source to Heroku with Console

4.Operation confirm with LINE application

Let’s add a friend from the QR code to 【2. LINE Business account】 LINE application and send a message.

Reference material

Line Messaging API
わずか5分。新LINE Messaging APIでbotを作ってみた手順全公開

Enjoy it!

Post Tagged with , , , ,