Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Google Chat Notifications Webhook Support #229

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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