Build LINE Bot web application with Node.js and Heroku

Overview

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!”.
Node.jsの快適な開発デプロイ環境を構築(Heroku+Cloud9)
※ Note the domain “https://myapp.herokuapp.com” generated above.

2. LINE Business account

Please refer to the following:

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

Note:

① Be sure to set the following in the LINE Business account request setting.
・Webhook送信:「利用する」.
・自動応答メッセージ:「利用しない」

② In “Webhook URL” setting of LINE Developers setting page, input: domain + ‘/webhook’ [http://myapp.herokuapp.com/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!

Related Post

Write Apex Test Classes efficiently with Tesforce 1.Why Tesforce The Test Classes are required to deploy Apex to a production environment or to be packaged and placed on Force.com AppExchange, it must provide at least 75% code coverage. That will be a huge workload to SFDC Developers if the project(application) include a lot of Apex Classes,the...
Synchronize data between Postgres and Salesforce v... Somtimes we need to built a Web App with standard open source stacks, like PHP, Node.js and Python,but manage and analytic data with Salesforce standard functions,like record CRUD,views and reports. Heroku Connect provides us a pretty simple solution for this case, that using bi-directional syn...
Write a Heroku Scheduler batch for MangoDB+Salesfo... In previous post,I had shared how to 《Access Salesforce data via APIs(JSForce) from Outside Service》. In this post I will share about how to write a Heroku Scheduler batch for synchronizing MangoDB data to Salesforce with Node.js, like the below outline picture. ※I have no doubt that there hav...
Encrypte & Decrypte string in Node.js I have tried to encrypte and decrypte string in Node.js recently. There has many code examples at Internet, eg: Reference:http://qiita.com/sckm/items/232914af2959eefe505e https://gist.github.com/5db74af24c4ee31a3100 Run it in console commond but the following error has occurred. https://gis...

Post Tagged with , , , ,