日本語はこちら
Are you getting tired using physical device for debug your LINE bot? Yes I am! This project contains simulator to boost your developer productivity.
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.
- LINE developer account
- node.js
- And of course your LINE bot app :)
- This app is only tested in Chrome
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
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.
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: LINE simulator to improve debugging experience.
- LINE Bot POC: Quickly craft mock via UI
- Follow the setup to run the simulator. By default it uses port 8080. If you dont' like it, change it in the source code.
- 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');
- Open Chrome and connect to http://localhost:8080
- 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
- In the chat bar, enter any text and hit "Enter" or click send icon.
- Depending on your implementaion, you can see reply.
- Simply click gear icon.
- Change settings and click connect.
You can also specify any LINE user so this is useful to test with other user.
- Click "Right arrow" icon either in chatbar or in menu.
- Use the more menu area to send any non-text data. You can send image, sticker, location or system messages.
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.
- Click POC Mode button at login. If you already connected, you can click settings icon (gear) anytime to switch the mode.
- You see bot reply box in POC mode.
- To send simple text message, use chatbox in the simulator to send the text.
- To send more complex message, use more menu button to send it.
- Use bot reply box. Select the type you want to send.
- For carousel or image carousel template, click "add new column" button first to start crafting the message.
- You can add or delete the columns as you want.
- For template, you see the preview in the box and it update the value as you type.
- If you want to delete or move the chat item, select the item in the simulator.
- Click trash icon to delete, or arrows to move the chat item as you wish.
- In case you want to save the chat, click download icon on the menu.
- It will be downloaded as json file. You can modify the json file if you want, and it adhere to LINE Messaging API format.
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
At the moment, you need to manually change the size. Just simply modify the value of css variables in public/css/site.css.
When you need to zoom entire page, simply use browser zoom feature.
You can simulate how keyboard hides the chat window.
- Click keyboard icon either in chatbar or in menu.
- You see keyboard is appearing in the chat. You cannot type via keyboard as this is just an image.
You can simulate how Rich Menu works. The default rich menu set in developer console cannot be simulated.
- Click rich menu icon in menu.
- You see rich menu if the user has one, otherwise see the alert.
- Click the menu again to hide it.
- Datetime Picker
- URL actions
- Simulator choice such as iPhone X/iPhone 8/Xperia XZ1 etc.