bigfunctions > send_google_chat_message
send_google_chat_message¶
Call or Deploy send_google_chat_message
?
✅ You can call this send_google_chat_message
bigfunction directly from your Google Cloud Project (no install required).
- This
send_google_chat_message
function is deployed inbigfunctions
GCP project in 39 datasets for all of the 39 BigQuery regions. You need to use the dataset in the same region as your datasets (otherwise you may have a function not found error). - Function is public, so it can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- You may prefer to deploy the BigFunction in your own project if you want 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). Discover the framework
Public BigFunctions Datasets:
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Description¶
Signature
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.
Examples¶
select bigfunctions.eu.send_google_chat_message("Hello 👋 from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.us.send_google_chat_message("Hello 👋 from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.europe_west1.send_google_chat_message("Hello 👋 from bigfunctions!", "YOUR_WEBHOOK_URL")
+--------------------------------------------------------------------------------------------------+
| response |
+--------------------------------------------------------------------------------------------------+
| {
"name": ...,
"sender": ...,
"createTime": ...,
"text": "Hello 👋 from bigfunctions!"
}
|
+--------------------------------------------------------------------------------------------------+
Need help using send_google_chat_message
?
The community can help! Engage the conversation on Slack
For professional suppport, don't hesitate to chat with us.
Found a bug using 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.
For professional suppport, don't hesitate to chat with us.
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
).
Spread the word¶
BigFunctions is fully open-source. Help make it a success by spreading the word!