Skip to content

send_teams_message

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.

Usage

Call or Deploy send_teams_message ?
Call send_teams_message directly

The easiest way to use bigfunctions

  • send_teams_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_teams_message in your project

Why deploy?

  • You may prefer to deploy send_teams_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_teams_message function can be deployed with:

pip install bigfunctions
bigfun get send_teams_message
bigfun deploy send_teams_message

Examples

select bigfunctions.eu.send_teams_message("Hello \ud83d\udc4b from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.us.send_teams_message("Hello \ud83d\udc4b from bigfunctions!", "YOUR_WEBHOOK_URL")
select bigfunctions.europe_west1.send_teams_message("Hello \ud83d\udc4b from bigfunctions!", "YOUR_WEBHOOK_URL")
+----------+
| response |
+----------+
| ok       |
+----------+

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).


Need help or Found a bug?
Get help using send_teams_message

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about 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.

We also provide professional suppport.


Show your ❤ by adding a ⭐ on