auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const axios = require("axios")
if(steps.trigger.event.method !== "POST") return; // dont trigger this when the request type is not POST
if(!steps.trigger.event.headers["user-agent"].includes("Pinglik Uptimer")) return; // ignore requests that are not sent from Pinglik Uptimer
if(!steps.trigger.event.body.monitor_name) return;
if(!steps.trigger.event.body.monitor_link) return;
let request = steps.trigger.event.body
let color = 16777215 // defauld color - white
let title = `${request.monitor_name} is ${request.type}!`
let url = request.monitor_link
let description = request.message // default notification message (you can also build your own)
let timestamp = request.timestamp // currect timestamp
let footer = `This monitor is owned by ${request.monitor_owner_tag} (${request.monitor_owner_id})`
// embed color
if(request.type == "online") color = 65331 // green when its online
if(request.type == "offline") color = 16747520 // orange when its offline
if(request.type == "down") color = 15413039 // red when its down
// more info how to build your custom Discord webhook message - https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html
let body = {
"username": "Pinglik Uptimer",
"avatar_url": "https://uptimer.pinglik.eu/img/logo.png",
"embeds": [
{
"author": {
"name": "Pinglik Uptimer",
"url": "https://uptimer.pinglik.eu",
"icon_url": "https://uptimer.pinglik.eu/img/logo.png"
},
"title": title,
"url": url,
"description": description,
"color": color,
"timestamp": timestamp,
"footer": {
"text": footer,
"icon_url": "https://uptimer.pinglik.eu/img/logo.png"
}
}
],
}
// make POST request to Discord webhook - send your notification embed to Discord
const resp = await axios({
method: "POST",
url: process.env.notification_webhook + "?wait=true", // Go to https://pipedream.com/settings/env-vars and add your webhook url as notification_webhook
data: JSON.stringify(body),
headers: {
"Content-Type": "application/json",
},
});
this.message = resp.data; // return message body if it was sent to Discord