Build LINE Bot web application with Node.js and Heroku


To confirm the operation of LINE Bot web application with Node.js + Heroku using the LINE Messaging API, it is necessary to put it on the server.
This time, we make a LineBot web application using free [Heroku].

Basic flow

1.Heroku account

For Web online development, we recommend Heroku + Cloud 9.
Please refer to the following article ↓ ↓ for the procedure from Heroku’s account registration to “Hello World!”.
Awesome Node.js development environment with Heroku and Cloud9
Make a note of the above produced domain「」

2.LINE Business account

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

① Be sure to set the LINE Business account リクエスト設定
・Webhook送信 「利用する
・自動応答メッセージ 「利用しない

② LINE Developers setting page
・Edit “Webhook URL” setting with: domain in [1. Heroku account]  + ‘/ webhook’
 ⇒Input「」 and save.
 webhook : Process of callBack created in step 3.
・Make a note of the Channel Secret and アクセストークン in the page.

3.LINE Bot program creation

  • Install necessary package in Console

>npm install @line/bot-sdk –s 

>npm install express –s



① In the DefaultAccessToken and defaultSecret,

Overwrite it with the noted Channel Secret and access token in [2.LINE Business account]
 Or  add the variable by Heroku >Config Variables
  CHANNEL_ACCESS_TOKEN ⇒ 「アクセストークン」noted in STEP 2
  CHANNEL_SECRET ⇒ 「Channel Secret」noted in STEP 2

  • Deploy edited source to Heroku in Console

  • Confirm with LINE application
    Let’s add a friend from QR code to LINE application and send a message.

Enjoy it!


Line Messaging API

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

Post Tagged with , , , ,