LINE API
LINE Messaging API
These are the steps to set up a LINE bot for LibreNMS.
-
Register your real LINE account in the developer portal.
-
Add a new channel and choose
Messaging API. Then complete the forms. You cannot changeChannel namelater. -
Open the "Messaging API" tab of your channel. This tab holds some important values.
Bot basic IDandQR codeare the ID and the QR code of your LINE bot.Channel access token (long-lived)goes into LibreNMS. Keep it secret.
-
Add your LINE bot as a friend from your real LINE account.
-
The recipient ID is a
groupID, auserID, or aroomID. LibreNMS uses this ID to send a message to a group or a user. To find it, use the NodeJS program below withngrokas a temporary HTTPS webhook. -
Run the program. Then make the port public with
ngrok.$ node index.js $ ngrok http 3000 -
Open the "Messaging API" tab of your channel. Set the Webhook URL to
https://<your ngrok domain>/webhook. -
To send a message to yourself, send a message to your LINE bot from your real account. The program then prints the
userIDin the console.sample value:
{"type":"user","userId":"U527xxxxxxxxxxxxxxxxxxxxxxxxxc0ee"} -
To send a message to a group, do these steps.
- Add your LINE bot to the group.
- Send a message to the group from your real account.
The program then prints the
groupIDin the console. This value is the recipient ID. Keep it secret.sample value:
{"type":"group","groupId":"Ce51xxxxxxxxxxxxxxxxxxxxxxxxxx6ef","userId":"U527xxxxxxxxxxxxxxxxxxxxxxxxxc0ee"} ```
Example:
| Config | Example |
|---|---|
| Access token | fhJ9vH2fsxxxxxxxxxxxxxxxxxxxxlFU= |
| Recipient (groupID, userID or roomID) | Ce51xxxxxxxxxxxxxxxxxxxxxxxxxx6ef |