Send notifications to Google Chat from your workflow

You can create a workflow that sends messages to a Google Chat incoming webhook. Incoming webhooks let you send asynchronous messages into Google Chat from applications that aren't Chat apps. For example, you can configure a monitoring application to notify on-call personnel on Google Chat when a server goes down.

Create and register a Google Chat incoming webhook

In the Google Chat space where you want to receive messages, create a webhook. Follow the instructions to register the incoming webhook.

Make an HTTP call to the webhook URL

Create a workflow and add a step to the workflow that makes an HTTP POST call to the webhook URL. For example:

YAML

  - get_message:
      call: http.post
      args:
        url: WEBHOOK_URL
        body:
          text: "Hello world!"
        headers:
          Content-Type: "application/json; charset=UTF-8"
      result: response
  - return_value:
      return: ${response}

JSON

  [
    {
      "get_message": {
        "call": "http.post",
        "args": {
          "url": "WEBHOOK_URL",
          "body": {
            "text": "Hello world!"
          },
          "headers": {
            "Content-Type": "application/json; charset=UTF-8"
          }
        },
        "result": "response"
      }
    },
    {
      "return_value": {
        "return": "${response}"
      }
    }
  ]

Replace WEBHOOK_URL with the webhook URL that you copied when registering the incoming webhook.

You can confirm that the workflow works as expected by ensuring that a notification is sent to your Google Chat space.

What's next