bigfunctions > send_teams_message
send_teams_message¶
Call or Deploy send_teams_message
?
✅ You can call this send_teams_message
bigfunction directly from your Google Cloud Project (no install required).
- This
send_teams_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_teams_message(message, webhook_url)
Description
Sends message
to a Microsoft Teams channel.
To get the
webhook_url
for a channel, follow this doc from Microsoft.
Examples¶
select bigfunctions.eu.send_teams_message("Hello 👋 from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.us.send_teams_message("Hello 👋 from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.europe_west1.send_teams_message("Hello 👋 from bigfunctions!", "YOUR_WEBHOOK_URL")
+----------+
| response |
+----------+
| ok |
+----------+
Need help using send_teams_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_teams_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¶
A use case for the send_teams_message
BigQuery function would be to send notifications to a Microsoft Teams channel upon the completion of a BigQuery job or when specific conditions are met in your data.
Scenario 1: BigQuery Job Completion Notification:
Imagine you have a long-running BigQuery query that aggregates daily sales data. You want to be notified in your team's channel when the job finishes. You could create a scheduled query and then add a final step using the send_teams_message
function. This step would execute only after the main query completes.
-- Your main query to calculate daily sales
SELECT ...
FROM ...
-- Send a Teams notification when the query is done
SELECT bigfunctions.us.send_teams_message(
CONCAT("Daily sales data aggregation complete! Total sales: $", SUM(daily_sales)),
"YOUR_WEBHOOK_URL"
);
Scenario 2: Anomaly Detection Alert:
Suppose you're monitoring website traffic and want to be alerted if traffic drops below a certain threshold. You can set up a scheduled query to check the traffic data and use send_teams_message
to send an alert if an anomaly is detected.
-- Check for low website traffic
SELECT
CASE
WHEN current_traffic < 1000 THEN bigfunctions.us.send_teams_message(
"ALERT: Website traffic is unusually low!",
"YOUR_WEBHOOK_URL"
)
ELSE CAST(NULL as STRING) -- Do nothing if traffic is normal
END
FROM
(SELECT COUNT(*) AS current_traffic FROM `your_project.your_dataset.website_traffic` WHERE timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR))
;
Scenario 3: Data Validation Notification:
You can use this function to notify your team about data quality issues. For example, if a data validation check fails, send a message to Teams.
-- Check for invalid records
SELECT
CASE
WHEN invalid_records > 0 THEN bigfunctions.us.send_teams_message(
CONCAT("Data validation failed! Found ", invalid_records, " invalid records."),
"YOUR_WEBHOOK_URL"
)
ELSE CAST(NULL as STRING)
END
FROM
(SELECT COUNT(*) AS invalid_records FROM `your_project.your_dataset.your_table` WHERE some_validation_check IS FALSE);
These examples illustrate how send_teams_message
can integrate BigQuery with Microsoft Teams for real-time notifications, allowing for proactive monitoring and faster responses to critical events. Remember to replace "YOUR_WEBHOOK_URL"
with the actual webhook URL for your Teams channel and select the correct BigFunctions dataset based on your BigQuery region (e.g., bigfunctions.eu
, bigfunctions.asia_southeast1
).
Spread the word¶
BigFunctions is fully open-source. Help make it a success by spreading the word!