TinyPingTinyPing

How to create a Google Chat webhook

To create a Google Chat webhook, open the space in Chat on the web, click the down arrow next to the space name and choose Apps & integrations, then Add webhooks. Give it a name, save it, and copy the link: that link is your webhook URL.

Last updated

Before you start

  • A Google Workspace account (business or education). Personal Gmail accounts cannot add webhooks.
  • Webhooks turned on for your organization. A Workspace admin can turn them off.
  • A computer with a web browser. You cannot add webhooks in the Chat mobile app.
  • A space to post into. Webhooks belong to a space, not to a direct message.

Create a Google Chat webhook, step by step

  1. Open Google Chat (opens in a new tab) in a web browser and go to the space that should receive the messages.
  2. At the top, click the space name (or the down arrow next to it), then click Apps & integrations.
  3. Click Add webhooks.
  4. Type a Name for the webhook, for example TinyPing Alerts. Add an Avatar URL if you want a custom picture, such as the TinyPing icon linked below these steps.
  5. Click Save.
  6. Next to your new webhook, click More, then Copy link.

To show the TinyPing icon next to alerts, paste this into Avatar URL in step 4. It is a square 512 x 512 PNG.

Avatar URL
https://tinyping.ai/brand/kit/png/logo/tinyping-app-icon-512.png

The URL starts with https://chat.googleapis.com/v1/spaces/. Anything that sends a message to it shows up in the space, under the name you chose.

Test your webhook

Paste this into a terminal, with your own URL in place of the example. Keep the single quotes around the URL: it contains & characters that your shell would otherwise cut off.

Terminal
curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"text":"Hello from TinyPing"}' \
  'https://chat.googleapis.com/v1/spaces/EXAMPLE-SPACE/messages?key=EXAMPLE-KEY&token=EXAMPLE-TOKEN'

If it works, "Hello from TinyPing" appears in the space within a few seconds, and Google answers with a short JSON description of the message.

Troubleshooting

I cannot find Apps & integrations or Add webhooks
Check that you are in a space (not a direct message), in a web browser (not the mobile app), and signed in with a Google Workspace account. If all three are true, your Workspace admin has probably turned webhooks off. Ask them to allow incoming webhooks.
The request fails with 400 Bad Request
Google could not read the message. Check that the body is valid JSON with a text field, and that you sent the Content-Type: application/json header.
The request fails with 403 or 404
The URL is incomplete or the webhook was deleted. Copy the link again from the space. A URL cut off at the first & is a common cause, so keep it in quotes.
The request fails with 429 Too Many Requests
Google limits how many messages a webhook can post in a short time. Send fewer messages, or wait a moment and try again.
The command does not work in Windows Command Prompt
Command Prompt does not understand single quotes. Use double quotes around the URL and escape the ones in the body: -d "{\"text\":\"Hello\"}". Or run it in PowerShell with curl.exe.

Keep the URL secret

The webhook URL works like a password. Anyone who has it can post messages into your space, without signing in. Do not commit it to a public repository or paste it into tickets and chats. Store it the way you store other secrets.

If the URL leaks, remove the webhook: open the space, click the down arrow next to its name, choose Apps & integrations, and remove the webhook from its More menu. Then add a new webhook and give the new URL to every tool that used the old one.

Use it with TinyPing

TinyPing checks your websites, APIs and cron jobs around the clock and posts to your Google Chat space when something goes down. To connect your new webhook:

  1. In TinyPing, open Alerts.
  2. Under Add a contact, set Type to Google Chat and paste the webhook URL.
  3. Choose whether it alerts for all monitors or only the ones you pick, then click Add contact.

TinyPing posts when a monitor goes down and again when it recovers, in one thread per outage, so the space stays tidy. It also posts SSL certificate and domain expiry reminders before they run out.

Start your 7-day free trial

US$6.99 a month or US$47 a year per 50 monitors, team members free. No card needed for the trial.

Related

More guides in the help center.