Google Spaces is a shared chat option included with Google Apps/domains.
Google provides an API to allow third-party apps such as Omnilert to post messages to Google "Spaces". Here's how to set up such a connection to post Omnilert alerts to Google Spaces using Webhooks.
(Please Note: You will need administrator access to Omnilert and your organization's Google Spaces account to complete this setup.)
Step 1: Create a "Webhooks" connector within your desired "Google Spaces" channel.
You will need to add a "webhook" to receive the alerts sent by Omnilert.
See https://developers.google.com/chat/how-tos/webhooks for detailed instructions from Google on how to enable webhooks for the desired Google Space.
The result of that setup's first step will be a URL provided by Google. Copy that URL. You will need it for Step 3.
(You only need the webhook URL from Google. You will create your JSON script in the "Step 3" section of this guide below.)
Step 2: Create a new Webhook Endpoint in Omnilert
In Omnilert, you will need to set up a new "Webhook" endpoint to send messages to your Google Spaces.
Go to Endpoints > Add Endpoint to create a new Webhook endpoint in Omnilert's admin portal. See: Adding a new Endpoint for instructions. (Tip: Be sure to set your new endpoint as "Active")
Step 3: Configure the Omnilert Webhook to send to Google Spaces
Next, we need to edit the new webhook endpoint and insert a JSON script to send its hook in a format that Google Spaces can read.
- Go to Endpoints > Active (or Inactive if you hadn't activated your new endpoint yet!)
- Click on the new webhooks endpoint in the list
- Go to the "Configure" tab for your new webhook endpoint.
- Paste your customized JSON script (see below for code!)
- Check the box to "Bypass Service Status Checks". (Google's API will not accept "OPTION" requests, so this feature must be disabled for the webhook to work properly.)
- Click Update configuration to save your changes.
The Omnilert configuration JSON script for sending to Google is quite simple. You'll only need to set 4 parameters in your JSON:
- url = This will be your Google app's webhook URL from Step 1.
- postData = The payload to send to Google. Google will want it to be a parameter called "text" with the text content to display. In the example below, we'll insert the Omnilert content using variables {{webhook_subject}} and {{webhook_body}}
- method = POST (We want to post the data!)
- headers = Where we sent the content type for the posts. This will always be the same thing; "application/json" for Google.
Example Configuration JSON for sending to Google Spaces:
You will need to customize the code below to meet your needs. At a minimum, you must replace "YOUR_GOOGLE_WEBHOOK_URL" with the Google webhook URL created in Step 1 of this guide.
{
"url": "YOUR_GOOGLE_WEBHOOK_URL",
"postData": {
"text": "*Subject:* {{webhook_subject}} \n *Message:* {{webhook_body}} \n\n `This message sent via OMNILERT Webhook`"
},
"method": "POST",
"headers": {
"Content-type": "application/json"
}
}
In this example, we've configured the Google message to include both the "Subject" {{webhook_subject}} and "Message body" {{webhook_body}} of the Omnilert alert.
Naturally, you can edit the formatting and layout to your own liking. Simply edit the "postData" section of the JSON script accordingly.
Sending Omnilert messages to Google Spaces
After your configuration is complete, you'll be able to send Omnilert messages to your Google Spaces channel right away.
Simply select your new webhook endpoint as your would any other endpoint in Omnilert!
Compose and send your alert with the new webhook endpoint selected.
The message will be posted to Google via the webhook created in Step 1.
Comments
0 comments
Please sign in to leave a comment.