LINE API
LINE Messaging API
Here is the step for setup a LINE bot and using it in LibreNMS.
-
Use your real LINE account register in developer protal.
-
Add a new channel, choose
Messaging API
and continue fill up the forms, note thatChannel name
cannot edit later. -
Go to "Messaging API" tab of your channel, here listing some important value.
Bot basic ID
andQR code
is your LINE bot's ID and QR code.Channel access token (long-lived)
, will use it in LibreNMS, keep it safe.
-
Use your real Line account add your LINE bot as a friend.
-
Recipient ID can be
groupID
,userID
orroomID
, it will be used in LibreNMS to send message to a group or a user. Use the following NodeJS program andngrok
for temporally https webhook to listen it. -
Run the program and using
ngrok
expose port to public$ node index.js $ ngrok http 3000
-
Go to "Messaging API" tab of your channel, fill up Webhook URL to
https://<your ngrok domain>/webhook
-
If you want to let LINE bot send message to a yourself, use your real account to send a message to your LINE bot. Program will print out the
userID
in console.sample value:
{"type":"user","userId":"U527xxxxxxxxxxxxxxxxxxxxxxxxxc0ee"}
-
If you want to let LINE bot send message to a group, do the following steps.
- Add your LINE bot into group
- Use your real account to send a message to group
Program will print out the
groupID
in console, it will be Recipient ID, keep it safe.sample value:
{"type":"group","groupId":"Ce51xxxxxxxxxxxxxxxxxxxxxxxxxx6ef","userId":"U527xxxxxxxxxxxxxxxxxxxxxxxxxc0ee"} ```
Example:
Config | Example |
---|---|
Access token | fhJ9vH2fsxxxxxxxxxxxxxxxxxxxxlFU= |
Recipient (groupID, userID or roomID) | Ce51xxxxxxxxxxxxxxxxxxxxxxxxxx6ef |