This will run every 5 minutes and send a Slack message if a website url returns a non-200 response.
Integrations
Help and guides
Get started
Run this command in your terminal to create a new project using this template.
This will run every 5 minutes and send a Slack message if a website url returns a non-200 response.
Integrations
Help and guides
Get started
Run this command in your terminal to create a new project using this template.
This template contains a Scheduled Trigger that will run every 5 minutes and send a Slack message if a website url returns a non-200 response:
new Trigger({
// Give your Trigger a stable ID
id: "scheduled-healthcheck",
name: "Scheduled Healthcheck",
// Trigger every 5 minutes, see https://docs.trigger.dev/triggers/scheduled
on: scheduleEvent({
rateOf: { minutes: 5 },
}),
// The run functions gets called every 5 minutes
async run(event, ctx) {
// Fetch the website using generic fetch, see https://docs.trigger.dev/functions/fetch
const response = await ctx.fetch("๐งโโ๏ธ", WEBSITE_URL, {
method: "GET",
retry: {
enabled: false, // Disable retrying
},
});
// If the website is down (or we are in a test run), send a message to Slack
if (!response.ok || ctx.isTest) {
// Post a message to Slack, see https://docs.trigger.dev/integrations/apis/slack/actions/post-message
await slack.postMessage("๐ค", {
channelName: "health-checks",
text: `๐ญ ${WEBSITE_URL} is down!`,
});
}
},
}).listen();
WEBSITE_URL
environment variable.Be sure to check out more over on our docs