2
5

More than 3 years have passed since last update.

ローカルでデバッグ&テスト可能なLINEチャットボット開発環境(Node.js Express LINESimulator )を作成する

Last updated at Posted at 2019-12-06

ローカルでデバッグ&テスト可能なLINEチャットボット開発環境(Node.js Express LINESimulator )を作成する

 
※本記事は最終的にQ&Aチャットボットを構築するための一部分となります。
本編はこちら

※前段の記事で作成したオウム返しチャットボットベースとなります。
まだ未作成の方はこちら

DEBUG環境を作成する

1.DEBUG環境を作成します

構成の追加からlaunch.jsonを生成します

image.png

DEBUG用の設定情報を追加します。DEBUG時はシュミレータに接続するように設定します。
"Channel_endpoint"の設定はDEBUG用の設定("http://localhost:8080/v2/bot/message/reply/" 固定)にしましょう。 

{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "プログラムの起動",
            "program": "${workspaceFolder}\\index.js",
             "env": {
                "Channel_endpoint":"http://localhost:8080/v2/bot/message/reply/"
              }
        }
    ]
}

 
 
 

2.LINEシュミレーターを準備します

LINEシミュレーターの導入はとても簡単

git clone https://github.com/kenakamu/LINESimulator ../LINESimulator
cd ..\LINESimulator\
npm install

  

 
LINEシミュレーターの起動はいつものコマンドで

npm start

  
 
 

BOTをDEBUGで起動しておきます
image.png

 
 

起動するとLINE設定情報を求めらるので、.envからコピーして設定を貼り付けます
設定を入力したらConnectします
image.png

 
 

接続がうまくいくとシュミレーターを使ってBOTとのやり取りが可能になります
これで開発効率が大幅に向上するはず
image.png

 
 

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5