Build LINE Bot web application with Node.js and Heroku

Overview

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「https://myapp.herokuapp.com」

2.LINE Business account

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

① 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「https://myapp.herokuapp.com/webhook」 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

 

Notice:

① 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!

reference

Line Messaging API

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

Related Post

利用Tesforce高效地进行Apex Test Class编程 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...
利用Heroku Connect进行Postgres与Salesforce的数据同步... 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...
用Node.js编写MangoDB+Salesforce的Heroku Scheduler batc... 在之前的文章中,我介绍过了《通过APIs(JSForce)访问Salesforce数据》. 本篇文章将继续介绍,有关如何使用Node.js为MangoDB到Salesforce的数据同步编写Heroku Scheduler batch,如下图所示。 ※我丝毫不怀疑实现MangoDB和Salesforce的数据同步会有其他不同的实现方式,如Enrico Murru所写的《 Lightning Connect Custom Adapters and MongoDB》以及《 Powering Salesforce Lightning Connect with MongoDB》,在今后的文...
Node.js中的加密解密字符串 试用了下Node.js下的字符串加密解密模块~ 网络上也有很多参考代码。例如: 参照:http://qiita.com/sckm/items/232914af2959eefe505e https://gist.github.com/5db74af24c4ee31a3100 执行了下,出错了。 https://gist.github.com/5db74af24c4ee31a3100 嗯。。搞不懂,'aes192'算法用'base64'的话行不通? 尝试了各种各样的代码总之以下代码是没问题了。 https://gist.github.com/5db74af24c...

Post Tagged with , , , ,