Nick: slack alerts

This commit is contained in:
Nicolas
2024-07-12 19:07:59 -04:00
parent 214a6ee608
commit fd18f2269b
4 changed files with 100 additions and 5 deletions
+23
View File
@@ -0,0 +1,23 @@
import axios from "axios";
export async function sendSlackWebhook(
message: string,
alertEveryone: boolean = false
) {
const webhookUrl = process.env.SLACK_WEBHOOK_URL;
const messagePrefix = alertEveryone ? "<!channel> " : "";
const payload = {
text: `${messagePrefix} ${message}`,
};
try {
const response = await axios.post(webhookUrl, payload, {
headers: {
"Content-Type": "application/json",
},
});
console.log("Webhook sent successfully:", response.data);
} catch (error) {
console.error("Error sending webhook:", error);
}
}