Skip to content

Commit

Permalink
✨ Add Google Chat webhooks notifications (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoherzog authored Oct 17, 2023
1 parent b917b03 commit cb78cff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/helpers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const sendNotification = async (config: UpptimeConfig, text: string) => {
{ channel: notification.channel, text },
{ headers: { Authorization: `Bearer ${getSecret("SLACK_BOT_ACCESS_TOKEN")}` } }
);
} else if (notification.type === "googlechat") {
console.log("[debug] Sending Google Chat notification");
const webhookUrl = getSecret("GOOGLE_CHAT_WEBHOOK_URL");
if (webhookUrl) await axios.post(webhookUrl, { "text": text });
} else if (notification.type === "discord") {
console.log("[debug] Sending Discord notification");
const webhookUrl = getSecret("DISCORD_WEBHOOK_URL");
Expand Down
12 changes: 12 additions & 0 deletions src/helpers/notifme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ export const sendNotification = async (message: string) => {
}
console.log("Finished sending Discord");
}
if (getSecret("NOTIFICATION_GOOGLE_CHAT_WEBHOOK_URL")) {
console.log("Sending Google Chat");
try {
await axios.post(getSecret("NOTIFICATION_GOOGLE_CHAT_WEBHOOK_URL") as string, {
text: message,
});
console.log("Success Google Chat");
} catch (error) {
console.log("Got an error", error);
}
console.log("Finished sending Google Chat");
}
if (
getSecret("NOTIFICATION_ZULIP_MESSAGE_URL") &&
getSecret("NOTIFICATION_ZULIP_API_EMAIL") &&
Expand Down

0 comments on commit cb78cff

Please sign in to comment.