What this solves
Earlier I wrote a post about using Uptime Kuma to monitor whether sites and services are running properly. I later found out it supports LINE notifications, so I'm taking the chance to document the application process here.
To use LINE notifications in Uptime Kuma, we need to obtain a user ID and access token from the LINE Messaging API

Sign in / register a LINE Bot developer account
Create a new chat group > Create a new channel

Fill in the required fields > Channel type > Messaging API
Submit.

Switch to the Basic settings tab

Scroll to the bottom of the page and copy the user ID we'll use later

Switch to the Messaging API tab

Scroll to the bottom and click the Issue button

After clicking Issue, the LINE bot's access token is generated — copy it

Back at the top of the Messaging API tab, scan the provided QR code with your phone and add the bot as a friend

Paste the user ID and token into Uptime Kuma's notification settings, then click Test — a test message should arrive in your LINE app

How LINE push messaging works
We can also learn how various community push integrations are wired up by reading Uptime Kuma's source. Looking at the code, you just need to send your message payload to LINE's API and it pushes it to the user. However, LINE enforces CORS restrictions. Sending from the backend avoids the CORS issue. Alternatively, open a browser to LINE's API endpoint and run the following in the console:
fetch("https://api.line.me/v2/bot/message/push", {
body: JSON.stringify( {
"to": 'your line bot id', // linebot id
"messages": [
{
"type": "text",
"text": "Test Successful!"
}
]
}), // must match 'Content-Type' header
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin', // include, same-origin, *omit
headers: {
'content-type': 'application/json',
'Authorization':'Bearer api token' // api token
},
method: 'POST', // *GET, POST, PUT, DELETE, etc.
})
.then(response => response.json()) // 輸出成 json
Your LINE app will then receive the message from the bot.





























Comments