• Stars
    star
    126
  • Rank 283,460 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LINESimulator

LINE Simulator for BOT developer

日本語はこちら

Are you getting tired using physical device for debug your LINE bot? Yes I am! This project contains simulator to boost your developer productivity.

Install from npm

If you just want to use it, install and run from npm.

npm install -g line-simulator
line-simulator

or for macOS,

sudo npm install -g line-simulator
sudo line-simulator

It will open a browser and start the service on port 8080. I recommend using Chrome as browser. When you stop it, Ctrl+C from the terminal.

Get it from GitHub

Prerequisits

  • LINE developer account
  • node.js
  • And of course your LINE bot app :)
  • This app is only tested in Chrome

Simulator setup

Use following commands to clone and install module. Then for Windows run npm start.

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

for MacOS, replace the last command as:

npm startMac

for Linux, replace the last command as:

npm startLinux

If you prefer using different browser, then open it and manully connect to http://localhost:8080

Run with Docker container

cd to the directory where you store the source code, then use the following commands to build docker image and run Simulator in the container.

docker image build --tag=linesimulator .
docker container run -d --rm -p 8080:8080 linesimulator

When container is running in the background, you can use your browser to visit http://localhost:8080.

For Bot API Server Address setting, if your bot server is running on the same host as Simulator container, you may use host.docker.internal instead of localhost to specify the server address.

How this works

This app works as LINE client simnulator, as well as LINE Platform simulator. All the request from your bot application shall come to this simulator, and it will redirect to LINE platform if necessary, otherwise it just returns the message to simulator UI.

It has two main features.

Debugging Experience

How to specify the simulator URL for bot application

  1. Follow the setup to run the simulator. By default it uses port 8080. If you dont' like it, change it in the source code.
  2. In your bot app, specify http://localhost:8080 as your LINE URL. This varies depending on which SDK you are using.

C#: Pass the URL for LineMessagingClient constructor.

var lineMessagingClient = new LineMessagingClient(accessToken, "http://localhost:8080");

Golang: Pass the URL for linebot.New

bot, err := linebot.New(
		channelSecret,
		channelToken,
		"http://localhost:8080"
	)

python: Pass the URL for linebot.LineBotApi constructor.

line_bot_api = LineBotApi(channel_access_token, "http://localhost:8080")

Node.js: for node.js it is slightly different. Specify the URL with /bot at the end for process.env.API_BASE_URL. You can do so in config or write it in the code, but you need to do so before you loda @line/bot-sdk module.

process.env.API_BASE_URL = "http://localhost:8080/";
const line = require('@line/bot-sdk');

How to use the simulator.

  1. Open Chrome and connect to http://localhost:8080
  2. You will see the connection page. Enter your Bot API URL, user id, channel secret and token, then click "connect". You can get UserId, ChannelSecret and ChannelToke from LINE Developer Portal
    settings.png
  3. In the chat bar, enter any text and hit "Enter" or click send icon.
    chatbar.png
  4. Depending on your implementaion, you can see reply.
    chatreply.png

Update settings

  1. Simply click gear icon.
  2. Change settings and click connect.

You can also specify any LINE user so this is useful to test with other user.

Send non-text

  1. Click "Right arrow" icon either in chatbar or in menu.
    more.png
  2. Use the more menu area to send any non-text data. You can send image, sticker, location or system messages.
    moremenu.png

See the JSON object

  1. Select any sent or replied area.
  2. You see JSON object.
    confirmjson.png
  3. Click close icon to close it.

LINE BOT POC

By using the simulator POC feature, you can quickly craft LINE Bot chat mock via UI only so that you don't have to write code to just show how it works to customers.

Start POC

  1. Click POC Mode button at login. If you already connected, you can click settings icon (gear) anytime to switch the mode.
    settings.png
  2. You see bot reply box in POC mode.
    botreply.png

Send message as user

  1. To send simple text message, use chatbox in the simulator to send the text.
    chatbar.png
  2. To send more complex message, use more menu button to send it.
    more.png
    moremenu.png

Send message as bot

  1. Use bot reply box. Select the type you want to send.
  2. For carousel or image carousel template, click "add new column" button first to start crafting the message.
    addnewcolumn.png
  3. You can add or delete the columns as you want.
  4. For template, you see the preview in the box and it update the value as you type.
    confirm.png

Delete or move the chat item

  1. If you want to delete or move the chat item, select the item in the simulator.
    chatitemmenu.png
  2. Click trash icon to delete, or arrows to move the chat item as you wish.

Save the chat

  1. In case you want to save the chat, click download icon on the menu.
    download.png
  2. It will be downloaded as json file. You can modify the json file if you want, and it adhere to LINE Messaging API format.

Load the chat

  1. To load the saved chat, click upload icon on the menu.
    upload.png
  2. Select the json file you saved before.

Common Features

At the moment, the simulator can:

  • Send text, image, location, sticker, system events.
  • Display text
  • Display image/video
  • Display buttons, confirm, carousel templates
  • Handle actions from templates

Change the simulator size

At the moment, you need to manually change the size. Just simply modify the value of css variables in public/css/site.css.

Zoom

  1. Click zoomin or zoomout in menu.
    zoom.png
  2. Confirm the only simulator zoomin/out.

When you need to zoom entire page, simply use browser zoom feature.

Keyboard

You can simulate how keyboard hides the chat window.

  1. Click keyboard icon either in chatbar or in menu.
    keyboard.png
  2. You see keyboard is appearing in the chat. You cannot type via keyboard as this is just an image.
    withkeyboard.png

Rich Menu

You can simulate how Rich Menu works. The default rich menu set in developer console cannot be simulated.

  1. Click rich menu icon in menu.
    richmenu.png
  2. You see rich menu if the user has one, otherwise see the alert.
    withrichmenu.png
  3. Click the menu again to hide it.

Feature to be added

  • Datetime Picker
  • URL actions
  • Simulator choice such as iPhone X/iPhone 8/Xperia XZ1 etc.

More Repositories

1

line-bot-sdk-csharp

SDK of the LINE Messaging API for C#
C#
38
star
2

line-richmenus-manager

LINE Rich Menus Manager
TypeScript
25
star
3

UCWA2.0-CS

C# library for UCWA 2.0
C#
24
star
4

CRMLinqPadDriverWebAPI

This is LINQPad driver which enables you to connect to your Microsoft Dynamics CRM organization and run LINQ queries against Web API endpoint.
C#
23
star
5

line-login-sdk-csharp

LINE Login SDK for C# and MVC Authentication Middleware
JavaScript
15
star
6

LINEChannelConnector

LINE Channel Connector for BotBuilder
C#
11
star
7

clova-simulator

clova simulator for CEK
JavaScript
11
star
8

LINEBotDeveloperUtil

LINE Bot Development Utilities
CSS
9
star
9

Microsoft.PowerBI.PowerShell

PowerShell mobule for PowerBI
PowerShell
8
star
10

LINE-LIFF-Sample

LINE Developer Bootcamp - LIFF 開発入門 で使ったサンプル
JavaScript
8
star
11

CRMLinqPadDriver

LINQPad driver for Microsoft Dynamics 365 (CRM)
C#
6
star
12

line-pay-csharp

LINE Pay SDK for .NET Core C#
C#
5
star
13

botbuilderv4completeguide

Microsoft Bot Framework v4 完全制覇ブログのサンプルコード https://qiita.com/kenakamu/items/6dc043cfc1f199032883
5
star
14

Microsoft.ADAL.PowerShell

PowerShell module wrapping Azure Active Directory Authentication Library (ADAL)
PowerShell
5
star
15

generator-line-bot

yeoman template for LINE Bot
C#
4
star
16

UCWABot

UCWA 2.0 sample which connects to BotFramework via DirectLine
C#
4
star
17

decode2016-CRM-App

C#
3
star
18

BotWithDevOps-Blog-sample

C#
3
star
19

vsts-tasks

PowerShell
3
star
20

APIM-Load-Balancer-for-AOAI

APIM Load Balancer for AOAI
Bicep
2
star
21

RulesEngineOnFunction

C#
2
star
22

ContactTracker

C#
2
star
23

clova-cek-sdk-csharp

clova-cek-sdk-csharp
C#
2
star
24

Activity-Tracker-UWP

UWP version of Activity Tracker, which uses Web API/SOAP depeding on the CRM version.
C#
2
star
25

decode2019ai02

de:code 2019 AI02 サンプルコード
C#
1
star
26

ignite-ui-app

Ignite UI sample app
TypeScript
1
star
27

line-pay-csharp-demo

LINE Pay C# SDK のハンズオンデモ
C#
1
star
28

DragonBoard_96BoardStarterKit_Sample

Dragon Board 410c Windows 10 IoT Core with 96 Board Starter Kit sample
C#
1
star