Repository: hyperjumptech/monika
Pull request #523 (2021-11-08 06:04:52)

Add Google chat notification channel
# Monika Pull Request (PR)  

## What feature/issue does this PR add  
1. Closes issue #494 
2. Adds google chat as a notification channel

## How did you implement / how did you fix it  
1.  Add handling for type 'google-chat'
2. Add  json formatting specific for google chat.

## How to test  
1. Create a new notification of type 'google-chat'
2. Add the spaces/google chat bot and generate the url webhook like in the google instruction
3. Run monika and observe notifications on Google Chat space

startup message
![image](https://user-images.githubusercontent.com/964106/140691722-fcb98810-eee9-4d14-baa6-51834772bc15.png)

incident message
![image](https://user-images.githubusercontent.com/964106/140691862-fb79022d-a6ba-479b-b3a1-a28c3c7d2f4f.png)



dennypradipta: Also please check why the tests is failing :grinning: 
codecov[bot]: # [Codecov](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) Report
> Merging [#523](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) (267153f) into [main](https://codecov.io/gh/hyperjumptech/monika/commit/e12d51521a16178712473b392e3046b66719a4a7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) (e12d515) will **decrease** coverage by `0.23%`.
> The diff coverage is `32.00%`.

[![Impacted file tree graph](https://codecov.io/gh/hyperjumptech/monika/pull/523/graphs/tree.svg?width=650&height=150&src=pr&token=O3WVT7DP6F&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech)](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech)

```diff
@@            Coverage Diff             @@
##             main     #523      +/-   ##
==========================================
- Coverage   56.21%   55.98%   -0.24%     
==========================================
  Files          58       59       +1     
  Lines        1633     1654      +21     
  Branches      293      295       +2     
==========================================
+ Hits          918      926       +8     
- Misses        608      622      +14     
+ Partials      107      106       -1     
```


| [Impacted Files](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech) | Coverage Δ | |
|---|---|---|
| [src/components/config/validate.ts](https://codecov.io/gh/hyperjumptech/monika/pull/523/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvY29uZmlnL3ZhbGlkYXRlLnRz) | `72.65% <0.00%> (-1.16%)` | :arrow_down: |
| [src/components/notification/checker.ts](https://codecov.io/gh/hyperjumptech/monika/pull/523/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvbm90aWZpY2F0aW9uL2NoZWNrZXIudHM=) | `88.23% <ø> (ø)` | |
| [src/components/notification/channel/googlechat.ts](https://codecov.io/gh/hyperjumptech/monika/pull/523/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvbm90aWZpY2F0aW9uL2NoYW5uZWwvZ29vZ2xlY2hhdC50cw==) | `16.66% <16.66%> (ø)` | |
| [src/components/notification/index.ts](https://codecov.io/gh/hyperjumptech/monika/pull/523/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvbm90aWZpY2F0aW9uL2luZGV4LnRz) | `73.56% <100.00%> (+0.94%)` | :arrow_up: |
| [src/components/notification/validator.ts](https://codecov.io/gh/hyperjumptech/monika/pull/523/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2NvbXBvbmVudHMvbm90aWZpY2F0aW9uL3ZhbGlkYXRvci50cw==) | `100.00% <100.00%> (ø)` | |
| [src/index.ts](https://codecov.io/gh/hyperjumptech/monika/pull/523/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech#diff-c3JjL2luZGV4LnRz) | `56.46% <100.00%> (+1.79%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech). Last update [e12d515...267153f](https://codecov.io/gh/hyperjumptech/monika/pull/523?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hyperjumptech).


Patch:
diff --git a/docs/src/pages/guides/notifications.md b/docs/src/pages/guides/notifications.md
index b9935f80..f068adcf 100644
--- a/docs/src/pages/guides/notifications.md
+++ b/docs/src/pages/guides/notifications.md
@@ -9,19 +9,20 @@ Monika will send notifications to you whenever [alerts](https://hyperjumptech.gi
 
 At this moment, Monika support these channel of notifications (You can use just one or more):
 
-1. [SMTP](https://hyperjumptech.github.io/monika/guides/notifications#smtp)
-2. [Mailgun](https://hyperjumptech.github.io/monika/guides/notifications#mailgun)
-3. [SendGrid](https://hyperjumptech.github.io/monika/guides/notifications#sendgrid)
-4. [Webhook](https://hyperjumptech.github.io/monika/guides/notifications#webhook)
-5. [Slack](https://hyperjumptech.github.io/monika/guides/notifications#slack-incoming-webhook)
-6. [Telegram](https://hyperjumptech.github.io/monika/guides/notifications#telegram)
-7. [WhatsApp Business](https://hyperjumptech.github.io/monika/guides/notifications#whatsapp)
-8. [Microsoft Teams](https://hyperjumptech.github.io/monika/guides/notifications#microsoft-teams)
-9. [Discord](https://hyperjumptech.github.io/monika/guides/notifications#discord)
-10. [Monika Whatsapp Notifier](https://hyperjumptech.github.io/monika/guides/notifications#monika-whatsapp-notifier)
-11. [Facebook Workplace](https://hyperjumptech.github.io/monika/guides/notifications#facebook-workplace)
-12. [Desktop Notifications](https://hyperjumptech.github.io/monika/guides/notifications#desktop-notifications)
-13. [Lark Suite](https://hyperjumptech.github.io/monika/guides/notifications#larksuite-notifications)
+1. [Desktop Notifications](https://hyperjumptech.github.io/monika/guides/notifications#desktop-notifications)
+2. [Discord](https://hyperjumptech.github.io/monika/guides/notifications#discord)
+3. [Facebook Workplace](https://hyperjumptech.github.io/monika/guides/notifications#facebook-workplace)
+4. [Google Chat](https://https://hyperjumptech.github.io/monika/guides/notifications#Google-Chat)
+5. [Lark Suite](https://hyperjumptech.github.io/monika/guides/notifications#larksuite-notifications)
+6. [Mailgun](https://hyperjumptech.github.io/monika/guides/notifications#mailgun)
+7. [Microsoft Teams](https://hyperjumptech.github.io/monika/guides/notifications#microsoft-teams)
+8. [Monika Whatsapp Notifier](https://hyperjumptech.github.io/monika/guides/notifications#monika-whatsapp-notifier)
+9. [SendGrid](https://hyperjumptech.github.io/monika/guides/notifications#sendgrid)
+10. [Slack](https://hyperjumptech.github.io/monika/guides/notifications#slack-incoming-webhook)
+11. [SMTP](https://hyperjumptech.github.io/monika/guides/notifications#smtp)
+12. [Telegram](https://hyperjumptech.github.io/monika/guides/notifications#telegram)
+13. [Webhook](https://hyperjumptech.github.io/monika/guides/notifications#webhook)
+14. [WhatsApp Business](https://hyperjumptech.github.io/monika/guides/notifications#whatsapp)
 
 ## Configurations
 
@@ -62,41 +63,100 @@ notifications: [
 
 Note that every triggered alert will be sent to you through all the notifications you defined in the configuration file, e.g., if you added `webhook` and `smtp` settings, you will receive the alert messages through both.
 
-## SMTP
+## Desktop Notifications
 
-[SMTP (Simple Mail Transfer Protocol)](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) is a way to send email using the TCP/IP protocol. This is the easiest way to get notified when alerts are triggered. Use the following configuration to set up SMTP notification.
+Monika supports desktop notifications. Here are the prerequisites for enabling the desktop notifications:
+
+- macOS: Uses OSAScript (Apple Open Scripting Architecture). AppleScript 2.0 or later and macOS version 10.5 or later required.
+- Linux: Uses `notify-send` command. `notify-osd` or `libnotify-bin` required (Ubuntu should have this by default).
+- Windows: Uses Powershell. Refer to [Microsoft Official Documentation](https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/install/windows-powershell-system-requirements?view=powershell-7.1) for System Requirements.
 
 ```yml
-- id: unique-id-smtp
-  type: smtp
-  data:
-    recipients: [RECIPIENT_EMAIL_ADDRESS]
-    hostname: smtp.mail.com
-    port: 587
-    username: SMTP_USERNAME
-    password: SMTP_PASSWORD
+id: unique-id-monika-notif,
+type: desktop
 ```
 
-| Key        | Description                                                          | Example                                         |
-| ---------- | -------------------------------------------------------------------- | ----------------------------------------------- |
-| ID         | Notification identity number                                         | `Smtp12345`                                     |
-| Type       | Notification types                                                   | `smtp`                                          |
-| Recipients | An array of email addresses that will receive the e-mail from Monika | `["monika@testmail.com", "symon@testmail.com"]` |
-| Hostname   | The smtp host that you will be using for sending the email           | `smtp.gmail.com`                                |
-| Port       | The port allowed to be used for sending mail in your host            | `587`                                           |
-| Username   | Registered username on your smtp server                              | `yourusername@gmail.com`                        |
-| Password   | The password set for your username                                   | `thepasswordforyourusername`                    |
+## Discord
 
-### Example using Gmail SMTP
+Monika supports Discord. To enable notification via Discord, you must create a discord webhook first. More info at [Discord webhook documentation](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
 
-To use Gmail SMTP with Monika,
+```yml
+id: unique-id-webhook,
+type: discord,
+data:
+  url: https://YOUR_DISCORD_URL
+```
 
-1. You need to have a Gmail account.
-2. Use `smtp.gmail.com` for `hostname`.
-3. Use `587` for `port`.
-4. Use your Gmail address for `username`.
-5. Use your Gmail password for `password`.
-   1. If you have activated 2-Factor-Authentication (2FA), you need to [create an App Password from your Account Settings](https://support.google.com/accounts/answer/185833). Then use the app password for `password`.
+| Key  | Description                                                   | Example                                                        |
+| ---- | ------------------------------------------------------------- | -------------------------------------------------------------- |
+| ID   | Notification identity number                                  | `Discord12345`                                                 |
+| Type | Notification types                                            | `discord`                                                      |
+| Url  | The URL of the Discord Webhook that will receive notification | `https://discord.com/api/webhook/<webhook.id>/<webhook.token>` |
+
+## Facebook Workplace
+
+Monika supports Facebook Workplace. To enable notification via Workplace, you must create custom integration first. More info at [Facebook Workplace Custom Integrations](https://developers.facebook.com/docs/workplace/custom-integrations-new/)
+
+```yml
+{
+  'id': 'unique-workplace-id',
+  'type': 'workplace',
+  'data':
+    {
+      'thread_id': '12345678910',
+      'access_token': 'your_custom_integration_access_token',
+    },
+}
+```
+
+| Key         | Description                                     | Example                         |
+| ----------- | ----------------------------------------------- | ------------------------------- |
+| ID          | Notification identity number                    | `Workplace12345`                |
+| Type        | Notification types                              | `workplace`                     |
+| ThreadID    | It's located at thread url, in the last segment | `6367478493277649`              |
+| AccessToken | Workplace access token for custom integration   | `DQVJzYWtsdHRJRWIxUk9uOG5VV...` |
+
+## Google Chat
+
+You can send Monika notifications to your Google Chat. First you need to generate the url webhook for Monika to use. To create a webhook:
+
+1. Open Google Chat
+2. Go to the space to add notification
+3. Select **Manage webhook** from the top of the page
+4. Under Incoming webhook, click **Add another** if one already exist, in either case you need to provdie a name.
+5. Name the new webhook and **Save**
+6. Copy the URL in the webhook modal
+7. You will need the URL in your monika configuration
+
+For futher information check the Google Chat [documentations here](https://developers.google.com/chat/how-tos/webhooks)
+
+Example of Google Chat configuration may be something similar to below:
+
+```yaml
+notifications:
+  - id: myGoogleChatNotif
+    type: google-chat
+    data:
+      url: https://chat.googleapis.com/v1/spaces/XXXXX/messages?key=1122334455
+```
+
+## Larksuite Notifications
+
+If you use Larksuite, you can get Monika to send notifications to the Larksuite bots. You can create a webhook url, and then use it in the monika configuration.
+
+You can find more information on creating [webhooks here.](https://www.larksuite.com/hc/en-US/articles/360048487775-Workplace-Use-Lark-Flow-Webhook-Triggers)
+
+The Yaml config setup may look something like this:
+
+```yml
+notifications:
+  - id: lark-group-message
+    type: lark
+    data:
+      url: https://open.larksuite.com/open-apis/bot/v2/hook/your-webhook-key-here
+```
+
+Keep watch on these pages, new notification methods are being developed.
 
 ## Mailgun
 
@@ -126,6 +186,40 @@ Mailgun is an email notification delivery provided by Mailgun email service. To
 | Api Key    | Mailgun account api key, mailgun registered key to identify your account | `MAILGUN_API_KEY`                               |
 | Domain     | The domain to set in Mailgun                                             | `sandboxmail.mailgun.com`                       |
 
+## Microsoft Teams
+
+Monika supports sending notifications via Microsoft Teams. In order to be able to send notifications via Microsoft Teams, you may need to add Connectors and webhooks to your channel. Please refer to [Microsoft Teams Documentation](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using) to enable connectors and webhooks.
+
+```yml
+id: unique-id-teams
+type: teams
+data:
+  url: https://YOUR_TEAMS_WEBHOOK_URL
+```
+
+| Key  | Description                             | Example                                 |
+| ---- | --------------------------------------- | --------------------------------------- |
+| ID   | Notification identity number            | `Webhook12345`                          |
+| Type | Notification types                      | `webhook`                               |
+| Url  | The URL of your Microsoft Teams Webhook | `https://<company>.webhook.office.com/` |
+
+## Monika Whatsapp Notifier
+
+You can get a notification from Monika to your Whatsapp number without having a Whatsapp Business account. First, you must create a [Monika Whatsapp Notifier account](https://whatsapp.hyperjump.tech).
+
+```yml
+id: unique-id-monika-notif
+type: monika-notif
+data:
+  url: https://YOUR_MONIKA_NOTIF_URL
+```
+
+| Key  | Description                              | Example                                                            |
+| ---- | ---------------------------------------- | ------------------------------------------------------------------ |
+| ID   | Notification identity number             | `MonikaNotif12345`                                                 |
+| Type | Notification types                       | `monika-notif`                                                     |
+| Url  | The URL of the Monika Notif Webhook link | `https://whatsapp.hyperjump.tech/api/notify?token=<webhook.token>` |
+
 ## Sendgrid
 
 Similar to mailgun, sendgrid is also an email delivery service. Make sure you have a [sendgrid account](https://app.sendgrid.com/). To obtain your API key, refer to [sendgrid documentation](https://sendgrid.com/docs/ui/account-and-settings/api-keys/). Then put the API key in Monika's configuration as follows:
@@ -147,33 +241,6 @@ Similar to mailgun, sendgrid is also an email delivery service. Make sure you ha
 | Recipients | An array of email addresses that will receive the e-mail from Monika         | `["monika@testmail.com", "symon@testmail.com"]` |
 | Api Key    | Sendgrid account api key, sendgrid registered key to identify your account   | `70e34aba-0ea908325`                            |
 
-## Webhook
-
-Monika supports Webhook. To enable notification via Webhook.
-
-```yml
-- id: unique-id-webhook
-  type: webhook
-  data:
-    url: https://YOUR_WEBHOOK_URL
-```
-
-| Key  | Description                                                      | Example                           |
-| ---- | ---------------------------------------------------------------- | --------------------------------- |
-| ID   | Notification identity number                                     | `Webhook12345`                    |
-| Type | Notification types                                               | `webhook`                         |
-| Url  | The URL of the server that will receive the webhook notification | `https://yourwebsite.com/webhook` |
-
-Using the webhook type configuration, `Monika` will send a request with the following body:
-
-```js
-body: {
-  url: string
-  time: string
-  alert: string
-}
-```
-
 ## Slack Incoming Webhook
 
 Monika supports Slack Incoming Webhook. To enable notification via Slack, you must have a `Slack's Incoming Webhook URL`. Please consult to [Sending messages using Incoming Webhooks](https://api.slack.com/messaging/webhooks) documentation.
@@ -191,6 +258,42 @@ data:
 | Type | Notification types                     | `slack`                            |
 | Url  | The URL of your slack incoming webhook | `https://slackwebhook.com/channel` |
 
+## SMTP
+
+[SMTP (Simple Mail Transfer Protocol)](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) is a way to send email using the TCP/IP protocol. This is the easiest way to get notified when alerts are triggered. Use the following configuration to set up SMTP notification.
+
+```yml
+- id: unique-id-smtp
+  type: smtp
+  data:
+    recipients: [RECIPIENT_EMAIL_ADDRESS]
+    hostname: smtp.mail.com
+    port: 587
+    username: SMTP_USERNAME
+    password: SMTP_PASSWORD
+```
+
+| Key        | Description                                                          | Example                                         |
+| ---------- | -------------------------------------------------------------------- | ----------------------------------------------- |
+| ID         | Notification identity number                                         | `Smtp12345`                                     |
+| Type       | Notification types                                                   | `smtp`                                          |
+| Recipients | An array of email addresses that will receive the e-mail from Monika | `["monika@testmail.com", "symon@testmail.com"]` |
+| Hostname   | The smtp host that you will be using for sending the email           | `smtp.gmail.com`                                |
+| Port       | The port allowed to be used for sending mail in your host            | `587`                                           |
+| Username   | Registered username on your smtp server                              | `yourusername@gmail.com`                        |
+| Password   | The password set for your username                                   | `thepasswordforyourusername`                    |
+
+### Example using Gmail SMTP
+
+To use Gmail SMTP with Monika,
+
+1. You need to have a Gmail account.
+2. Use `smtp.gmail.com` for `hostname`.
+3. Use `587` for `port`.
+4. Use your Gmail address for `username`.
+5. Use your Gmail password for `password`.
+   1. If you have activated 2-Factor-Authentication (2FA), you need to [create an App Password from your Account Settings](https://support.google.com/accounts/answer/185833). Then use the app password for `password`.
+
 ## Telegram
 
 Monika supports Telegram. To enable notification via Telegram, you must have a Telegram bot. Please consult to [Bots: An introduction for developers](https://core.telegram.org/bots).
@@ -210,6 +313,33 @@ Monika supports Telegram. To enable notification via Telegram, you must have a T
 | Group ID  | The ID of group where the bot should send the messages | `-123456`                     |
 | Bot Token | The Token of your telegram bot                         | `abcdefg:hijklmnopqrstuvwxyz` |
 
+## Webhook
+
+Monika supports Webhook. To enable notification via Webhook.
+
+```yml
+- id: unique-id-webhook
+  type: webhook
+  data:
+    url: https://YOUR_WEBHOOK_URL
+```
+
+| Key  | Description                                                      | Example                           |
+| ---- | ---------------------------------------------------------------- | --------------------------------- |
+| ID   | Notification identity number                                     | `Webhook12345`                    |
+| Type | Notification types                                               | `webhook`                         |
+| Url  | The URL of the server that will receive the webhook notification | `https://yourwebsite.com/webhook` |
+
+Using the webhook type configuration, `Monika` will send a request with the following body:
+
+```js
+body: {
+  url: string
+  time: string
+  alert: string
+}
+```
+
 ## Whatsapp
 
 Monika supports Whatsapp notification. To enable notification via whatsapp, you must have a registered user in whatsapp business api server. Please refer to [WhatsApp Business API](https://developers.facebook.com/docs/whatsapp) documentation.
@@ -233,108 +363,3 @@ Monika supports Whatsapp notification. To enable notification via whatsapp, you
 | Url          | The URL of your whatsapp api server                                                       | `https://yourwhatsappapiserver.com` |
 | Username     | Your whatsapp api user name                                                               | `username`                          |
 | Userpassword | Your whatsapp api user password                                                           | `userpassword`                      |
-
-## Microsoft Teams
-
-Monika supports sending notifications via Microsoft Teams. In order to be able to send notifications via Microsoft Teams, you may need to add Connectors and webhooks to your channel. Please refer to [Microsoft Teams Documentation](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using) to enable connectors and webhooks.
-
-```yml
-id: unique-id-teams
-type: teams
-data:
-  url: https://YOUR_TEAMS_WEBHOOK_URL
-```
-
-| Key  | Description                             | Example                                 |
-| ---- | --------------------------------------- | --------------------------------------- |
-| ID   | Notification identity number            | `Webhook12345`                          |
-| Type | Notification types                      | `webhook`                               |
-| Url  | The URL of your Microsoft Teams Webhook | `https://<company>.webhook.office.com/` |
-
-## Discord
-
-Monika supports Discord. To enable notification via Discord, you must create a discord webhook first. More info at [Discord webhook documentation](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
-
-```yml
-id: unique-id-webhook,
-type: discord,
-data:
-  url: https://YOUR_DISCORD_URL
-```
-
-| Key  | Description                                                   | Example                                                        |
-| ---- | ------------------------------------------------------------- | -------------------------------------------------------------- |
-| ID   | Notification identity number                                  | `Discord12345`                                                 |
-| Type | Notification types                                            | `discord`                                                      |
-| Url  | The URL of the Discord Webhook that will receive notification | `https://discord.com/api/webhook/<webhook.id>/<webhook.token>` |
-
-## Facebook Workplace
-
-Monika supports Facebook Workplace. To enable notification via Workplace, you must create custom integration first. More info at [Facebook Workplace Custom Integrations](https://developers.facebook.com/docs/workplace/custom-integrations-new/)
-
-```yml
-{
-  'id': 'unique-workplace-id',
-  'type': 'workplace',
-  'data':
-    {
-      'thread_id': '12345678910',
-      'access_token': 'your_custom_integration_access_token',
-    },
-}
-```
-
-| Key         | Description                                     | Example                         |
-| ----------- | ----------------------------------------------- | ------------------------------- |
-| ID          | Notification identity number                    | `Workplace12345`                |
-| Type        | Notification types                              | `workplace`                     |
-| ThreadID    | It's located at thread url, in the last segment | `6367478493277649`              |
-| AccessToken | Workplace access token for custom integration   | `DQVJzYWtsdHRJRWIxUk9uOG5VV...` |
-
-## Monika Whatsapp Notifier
-
-You can get a notification from Monika to your Whatsapp number without having a Whatsapp Business account. First, you must create a [Monika Whatsapp Notifier account](https://whatsapp.hyperjump.tech).
-
-```yml
-id: unique-id-monika-notif
-type: monika-notif
-data:
-  url: https://YOUR_MONIKA_NOTIF_URL
-```
-
-| Key  | Description                              | Example                                                            |
-| ---- | ---------------------------------------- | ------------------------------------------------------------------ |
-| ID   | Notification identity number             | `MonikaNotif12345`                                                 |
-| Type | Notification types                       | `monika-notif`                                                     |
-| Url  | The URL of the Monika Notif Webhook link | `https://whatsapp.hyperjump.tech/api/notify?token=<webhook.token>` |
-
-## Desktop Notifications
-
-Monika supports desktop notifications. Here are the prerequisites for enabling the desktop notifications:
-
-- macOS: Uses OSAScript (Apple Open Scripting Architecture). AppleScript 2.0 or later and macOS version 10.5 or later required.
-- Linux: Uses `notify-send` command. `notify-osd` or `libnotify-bin` required (Ubuntu should have this by default).
-- Windows: Uses Powershell. Refer to [Microsoft Official Documentation](https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/install/windows-powershell-system-requirements?view=powershell-7.1) for System Requirements.
-
-```yml
-id: unique-id-monika-notif,
-type: desktop
-```
-
-## Larksuite Notifications
-
-If you use Larksuite, you can get Monika to send notifications to the Larksuite bots. You can create a webhook url, and then use it in the monika configuration.
-
-You can find more information on creating [webhooks here.](https://www.larksuite.com/hc/en-US/articles/360048487775-Workplace-Use-Lark-Flow-Webhook-Triggers)
-
-The Yaml config setup may look something like this:
-
-```yml
-notifications:
-  - id: lark-group-message
-    type: lark
-    data:
-      url: https://open.larksuite.com/open-apis/bot/v2/hook/your-webhook-key-here
-```
-
-Keep watch on these pages, new notification methods are being developed.
diff --git a/src/components/config/validate.ts b/src/components/config/validate.ts
index b8a8d56d..11be8194 100644
--- a/src/components/config/validate.ts
+++ b/src/components/config/validate.ts
@@ -223,6 +223,11 @@ function validateNotification(notifications: Notification[]): Validation {
         break
       }
 
+      case 'google-chat': {
+        if (!notification.data.url) return WEBHOOK_NO_URL
+        break
+      }
+
       default:
         return NOTIFICATION_INVALID_TYPE
     }
diff --git a/src/components/notification/channel/googlechat.ts b/src/components/notification/channel/googlechat.ts
new file mode 100644
index 00000000..ad3f595f
--- /dev/null
+++ b/src/components/notification/channel/googlechat.ts
@@ -0,0 +1,233 @@
+/**********************************************************************************
+ * MIT License                                                                    *
+ *                                                                                *
+ * Copyright (c) 2021 Hyperjump Technology                                        *
+ *                                                                                *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy   *
+ * of this software and associated documentation files (the "Software"), to deal  *
+ * in the Software without restriction, including without limitation the rights   *
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell      *
+ * copies of the Software, and to permit persons to whom the Software is          *
+ * furnished to do so, subject to the following conditions:                       *
+ *                                                                                *
+ * The above copyright notice and this permission notice shall be included in all *
+ * copies or substantial portions of the Software.                                *
+ *                                                                                *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR     *
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,       *
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE    *
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER         *
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  *
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  *
+ * SOFTWARE.                                                                      *
+ **********************************************************************************/
+import axios from 'axios'
+
+import { NotificationMessage } from '../../../interfaces/notification'
+import { GoogleChatData } from '../../../interfaces/data'
+import { log } from '../../../utils/pino'
+
+export const sendGoogleChat = async (
+  data: GoogleChatData,
+  message: NotificationMessage
+) => {
+  const notifType =
+    message.meta.type[0].toUpperCase() + message.meta.type.substring(1)
+  let chatMessage
+
+  switch (message.meta.type) {
+    case 'start':
+      chatMessage = {
+        cards: [
+          {
+            header: {
+              title: 'Monika Notification',
+              subtitle: `Monika is starting`,
+              imageUrl: 'https://bit.ly/3kckaGO',
+            },
+            sections: [
+              {
+                widgets: [
+                  {
+                    textParagraph: {
+                      text: `<b>Message:</b> New monika monitoring started`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Time:</b> ${message.meta.time}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>From:</b> ${message.body}`,
+                    },
+                  },
+                ],
+              },
+            ],
+          },
+        ],
+      }
+      break
+    case 'termination':
+    case 'incident':
+      chatMessage = {
+        cards: [
+          {
+            header: {
+              title: 'Monika Notification',
+              subtitle: `New ${notifType} from Monika`,
+              imageUrl: 'https://bit.ly/3kckaGO',
+            },
+            sections: [
+              {
+                widgets: [
+                  {
+                    textParagraph: {
+                      text: `<b>Message: <font color=#ff0000>Alert!</font></b> ${message.summary}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>URL:</b> <a href>${message.meta.url}</a>`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Time:</b> ${message.meta.time}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>From:</b> ${message.meta.monikaInstance}`,
+                    },
+                  },
+                ],
+              },
+            ],
+          },
+        ],
+      }
+      break
+    case 'recovery':
+      chatMessage = {
+        cards: [
+          {
+            header: {
+              title: 'Monika Notification',
+              subtitle: `New ${notifType} from Monika`,
+              imageUrl: 'https://bit.ly/3kckaGO',
+            },
+            sections: [
+              {
+                widgets: [
+                  {
+                    textParagraph: {
+                      text: `<b>Message: <font color=#0000ff>Recovery</font></b> ${message.summary}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>URL:</b> <a href>${message.meta.url}<a>`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Time:</b> ${message.meta.time}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>From:</b> ${message.meta.monikaInstance}`,
+                    },
+                  },
+                ],
+              },
+            ],
+          },
+        ],
+      }
+      break
+    case 'status-update':
+      chatMessage = {
+        cards: [
+          {
+            header: {
+              title: 'Monika Notification',
+              subtitle: `Monika Status`,
+              imageUrl: 'https://bit.ly/3kckaGO',
+            },
+            sections: [
+              {
+                widgets: [
+                  {
+                    textParagraph: {
+                      text: `<b>Host:</b> ${message.meta.monikaInstance}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Number of Probes:</b> ${message.meta.numberOfProbes}`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Maximum Response Time:</b> ${message.meta.maxResponseTime} ms in the last ${message.meta.responseTimelogLifeTimeInHour} hours`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Minimum Response Time:</b> ${message.meta.maxResponseTime} ms in the last ${message.meta.responseTimelogLifeTimeInHour} hours`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Average Response Time:</b> ${message.meta.averageResponseTime} ms in the last ${message.meta.responseTimelogLifeTimeInHour} hours`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Incidents:</b> ${message.meta.numberOfIncidents} in the last 24 hours`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Recoveries:</b> ${message.meta.numberOfRecoveries} in the last 24 hours`,
+                    },
+                  },
+                  {
+                    textParagraph: {
+                      text: `<b>Notifications:</b> ${message.meta.numberOfSentNotifications}`,
+                    },
+                  },
+                ],
+              },
+            ],
+          },
+        ],
+      }
+      break
+    default:
+      break
+  }
+
+  try {
+    const res = await axios({
+      method: 'POST',
+      url: data.url,
+      headers: {
+        Accept: 'application/json',
+        'Content-type': 'application/json',
+      },
+      data: chatMessage,
+    })
+
+    return res
+  } catch (error) {
+    log.error(
+      "Couldn't send notification to Google Chat. Got this error: " +
+        error.message
+    )
+  }
+}
diff --git a/src/components/notification/checker.ts b/src/components/notification/checker.ts
index 05ac20e3..f33f0cf4 100644
--- a/src/components/notification/checker.ts
+++ b/src/components/notification/checker.ts
@@ -39,6 +39,7 @@ import {
   dataWebhookSchemaValidator,
   dataWorkplaceSchemaValidator,
   dataLarkSchemaValidator,
+  dataGoogleChatSchemaValidator,
 } from './validator'
 
 // reexported with alias because this `errorMessage` function is used in test file
@@ -59,6 +60,7 @@ export const notificationChecker = async (notifications: Notification[]) => {
     whatsapp: dataWebhookSchemaValidator,
     workplace: dataWorkplaceSchemaValidator,
     lark: dataLarkSchemaValidator,
+    'google-chat': dataGoogleChatSchemaValidator,
   }
 
   await Promise.all(
diff --git a/src/components/notification/index.ts b/src/components/notification/index.ts
index 0a2a8c63..e1a6bd7b 100644
--- a/src/components/notification/index.ts
+++ b/src/components/notification/index.ts
@@ -44,6 +44,7 @@ import { sendWebhook } from './channel/webhook'
 import { sendWhatsapp } from './channel/whatsapp'
 import { sendWorkplace } from './channel/workplace'
 import { sendLark } from './channel/lark'
+import { sendGoogleChat } from './channel/googlechat'
 
 export class NotificationSendingError extends Error {
   notificationType: string
@@ -219,6 +220,11 @@ export async function sendNotifications(
             break
           }
 
+          case 'google-chat': {
+            await sendGoogleChat(notification.data, message)
+            break
+          }
+
           default: {
             break
           }
diff --git a/src/components/notification/validator.ts b/src/components/notification/validator.ts
index b0ddba75..4e3371a5 100644
--- a/src/components/notification/validator.ts
+++ b/src/components/notification/validator.ts
@@ -116,3 +116,9 @@ export const dataLarkSchemaValidator = dataBaseEmailSchemaValidator(
 ).keys({
   url: Joi.string().uri().required().label('Lark URL'),
 })
+
+export const dataGoogleChatSchemaValidator = dataBaseEmailSchemaValidator(
+  'google-chat'
+).keys({
+  url: Joi.string().uri().required().label('Google URL'),
+})
diff --git a/src/index.ts b/src/index.ts
index f3bbccf6..17d0d7a2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -449,13 +449,11 @@ Please refer to the Monika documentations on how to how to configure notificatio
             case 'sendgrid':
               break
             case 'webhook':
-              startupMessage += `    URL: ${item.data.url}\n`
-              break
             case 'slack':
-              startupMessage += `    URL: ${item.data.url}\n`
-              break
             case 'lark':
+            case 'google-chat':
               startupMessage += `    URL: ${item.data.url}\n`
+              break
           }
         })
       }
diff --git a/src/interfaces/data.ts b/src/interfaces/data.ts
index 943526d3..07db18f2 100644
--- a/src/interfaces/data.ts
+++ b/src/interfaces/data.ts
@@ -126,3 +126,7 @@ export interface DBLimit {
   deleted_data: number
   cron_schedule: string
 }
+
+export interface GoogleChatData {
+  url: string
+}
diff --git a/src/interfaces/notification.ts b/src/interfaces/notification.ts
index 0318ea2a..b52b6c54 100644
--- a/src/interfaces/notification.ts
+++ b/src/interfaces/notification.ts
@@ -34,6 +34,7 @@ import {
   WorkplaceData,
   LarkData,
   SlackData,
+  GoogleChatData,
 } from './data'
 
 export type Notification =
@@ -50,6 +51,7 @@ export type Notification =
   | WorkplaceNotification
   | DesktopNotification
   | LarkNotification
+  | GoogleChatNotification
 
 interface BaseNotification {
   id: string
@@ -122,6 +124,11 @@ interface LarkNotification extends BaseNotification {
   data: LarkData
 }
 
+interface GoogleChatNotification extends BaseNotification {
+  type: 'google-chat'
+  data: GoogleChatData
+}
+
 export interface NotificationMessage {
   subject: string
   body: string


Test patch:
diff --git a/test/components/notification.test.ts b/test/components/notification.test.ts
index 1ffd4d3e..681fc99f 100644
--- a/test/components/notification.test.ts
+++ b/test/components/notification.test.ts
@@ -34,6 +34,7 @@ import * as telegram from '../../src/components/notification/channel/telegram'
 import * as webhook from '../../src/components/notification/channel/webhook'
 import * as whatsapp from '../../src/components/notification/channel/whatsapp'
 import * as lark from '../../src/components/notification/channel/lark'
+import * as googlechat from '../../src/components/notification/channel/googlechat'
 import {
   MailgunData,
   MonikaNotifData,
@@ -41,6 +42,7 @@ import {
   WebhookData,
   WhatsappData,
   LarkData,
+  GoogleChatData,
 } from '../../src/interfaces/data'
 
 chai.use(spies)
@@ -425,4 +427,35 @@ describe('send alerts', () => {
 
     expect(lark.sendLark).to.have.been.called.exactly(1)
   })
+
+  it('should send google chat notification ', async () => {
+    chai.spy.on(googlechat, 'sendGoogleChat', () => Promise.resolve())
+
+    await sendAlerts({
+      probeID: 'c0ff807f-b326-49b7-9b47-7d15f07a90a0',
+      validation: {
+        alert: { query: 'status-not-2xx', message: '' },
+        isAlertTriggered: true,
+        response: {
+          data: '',
+          status: 500,
+          responseTime: 0,
+          headers: {},
+        },
+      },
+      notifications: [
+        {
+          id: 'googlechat-test',
+          type: 'google-chat',
+          data: {
+            url: 'xx',
+          } as GoogleChatData,
+        },
+      ],
+      url: 'https://hyperjump.tech',
+      probeState: 'DOWN',
+    })
+
+    expect(googlechat.sendGoogleChat).to.have.been.called.exactly(1)
+  })
 })
diff --git a/test/testConfigs/googlechat/googleChatConfig.yml b/test/testConfigs/googlechat/googleChatConfig.yml
new file mode 100644
index 00000000..311fdebf
--- /dev/null
+++ b/test/testConfigs/googlechat/googleChatConfig.yml
@@ -0,0 +1,23 @@
+notifications:
+  - id: unique-id
+    type: google-chat
+    data:
+      url: http://www.example.com
+probes:
+  - id: '1'
+    name: Example
+    description: Probe
+    interval: 0
+    requests:
+      - method: POST
+        url: https://something/login
+        headers:
+          Authorization: ''
+        body:
+          username: someusername
+          password: somepassword
+    incidentThreshold: 2
+    recoveryThreshold: 2
+    alerts:
+      - status-not-2xx
+      - response-time-greater-than-200-ms