Skip to content

send_google_chat_message

send_google_chat_message(message, webhook_url)

Description

Sends message to google chat space using incoming webhook.

To get the incoming webhook_url:

  • In a web browser, open Google Chat.
  • Go to the space to which you want to add a webhook.
  • At the top, next to space title, click Down Arrow arrow_drop_down > Apps & integrations.
  • Click Manage webhooks.
  • If this space already has other webhooks, click Add another. Otherwise, skip this step.
  • For Name, enter "Quickstart Webhook".
  • For Avatar URL, enter https://developers.google.com/chat/images/chat-product-icon.png.
  • Click SAVE.
  • To copy the full webhook URL, click Copy.

Usage

Call or Deploy send_google_chat_message ?
Call send_google_chat_message directly

The easiest way to use bigfunctions

  • send_google_chat_message function is deployed in 39 public datasets for all of the 39 BigQuery regions.
  • It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)

Public BigFunctions Datasets

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...
Deploy send_google_chat_message in your project

Why deploy?

  • You may prefer to deploy send_google_chat_message in your own project to build and manage your own catalog of functions.
  • This is particularly useful if you want to create private functions (for example calling your internal APIs).
  • Get started by reading the framework page

Deployment

send_google_chat_message function can be deployed with:

pip install bigfunctions
bigfun get send_google_chat_message
bigfun deploy send_google_chat_message

Examples

select bigfunctions.eu.send_google_chat_message("Hello \ud83d\udc4b from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.us.send_google_chat_message("Hello \ud83d\udc4b from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.europe_west1.send_google_chat_message("Hello \ud83d\udc4b from bigfunctions!", "YOUR_WEBHOOK_URL")
+--------------------------------------------------------------------------------------------------+
| response                                                                                         |
+--------------------------------------------------------------------------------------------------+
| {
  "name": ...,
  "sender": ...,
  "createTime": ...,
  "text": "Hello 👋 from bigfunctions!"
}
 |
+--------------------------------------------------------------------------------------------------+

Use cases

Here are a few use cases for the send_google_chat_message BigQuery function:

1. Data Monitoring and Alerting:

  • Threshold breaches: Imagine you have a BigQuery table tracking website traffic. You can schedule a query to check if traffic drops below a certain threshold. If it does, use send_google_chat_message to send an alert to a Google Chat space dedicated to website monitoring. The message could include details like the current traffic level, the threshold breached, and a timestamp.
  • Data quality issues: A scheduled query can check for data quality issues, such as null values in critical columns or inconsistencies between tables. If a problem is detected, the function can send a notification to the data engineering team's Google Chat space.
  • Job completion status: After a long-running BigQuery job finishes (e.g., a large data import or a complex transformation), the function can send a message to the relevant team confirming completion (or failure, along with the error message).

2. Report Automation and Sharing:

  • Daily summaries: Generate a daily summary of key business metrics from your BigQuery data and send it to a Google Chat space for management review. The message could be formatted as a table or a short bullet-point list.
  • Weekly performance reports: Consolidate weekly performance data and send a report to the sales team's Google Chat space, highlighting top performers, areas for improvement, and key trends.
  • Ad-hoc data insights: After running an exploratory query that reveals an interesting insight, use the function to share the finding with colleagues in a Google Chat space, along with a link to the BigQuery query.

3. Workflow Integration:

  • Triggering downstream actions: When certain conditions are met in your BigQuery data (e.g., a new customer signs up, an order is placed), the function can send a message to a Google Chat space that integrates with other tools. This message could trigger a downstream action in another system, such as updating a CRM or sending a welcome email.
  • Human-in-the-loop processes: Some data processes might require human intervention. The function can be used to notify a human operator in a Google Chat space when their input is needed. The operator can then take the necessary action and update the relevant data in BigQuery.

Example (Data Monitoring):

#standardSQL
DECLARE threshold INT64 DEFAULT 1000;
DECLARE current_traffic INT64;

SET current_traffic = (SELECT COUNT(*) FROM `your-project.your_dataset.website_traffic` WHERE _PARTITIONTIME = CURRENT_DATE());

IF current_traffic < threshold THEN
  SELECT bigfunctions.us.send_google_chat_message(
    FORMAT("ALERT: Website traffic dropped below %d. Current traffic: %d", threshold, current_traffic),
    "YOUR_WEBHOOK_URL"
  );
END IF;

This demonstrates how send_google_chat_message can be integrated into a SQL script to provide real-time alerts based on data in BigQuery. You can adapt this pattern for various other use cases as needed. Remember to replace placeholders like "YOUR_WEBHOOK_URL", "your-project.your_dataset.website_traffic", and adjust the logic to suit your specific requirements. Also ensure you're calling the function from the correct regional dataset (e.g., bigfunctions.us, bigfunctions.eu).


Need help or Found a bug?
Get help using send_google_chat_message

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about send_google_chat_message

If the function does not work as expected, please

  • report a bug so that it can be improved.
  • or open the discussion with the community on Slack.

We also provide professional suppport.


Show your ❤ by adding a ⭐ on