Skip to content

send_teams_adaptive_card

send_teams_adaptive_card(webhook_url, title, message, image_url, button_text, button_url)

Description

Sends Adaptive Card to a Microsoft Teams channel.

To get the webhook_url for a channel, follow this doc from Microsoft.

Examples

Call or Deploy send_teams_adaptive_card ?
Call send_teams_adaptive_card directly

The easiest way to use bigfunctions

  • send_teams_adaptive_card 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_adaptive_card in your project

Why deploy?

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

pip install bigfunctions
bigfun get send_teams_adaptive_card
bigfun deploy send_teams_adaptive_card
select bigfunctions.eu.send_teams_adaptive_card("YOUR_WEBHOOK_URL", "BigFunctions", "Hello 👋 from bigfunctions!", "https://adaptivecards.io/content/adaptive-card-50.png", "Click me!", "https://unytics.io/bigfunctions/")
select bigfunctions.us.send_teams_adaptive_card("YOUR_WEBHOOK_URL", "BigFunctions", "Hello 👋 from bigfunctions!", "https://adaptivecards.io/content/adaptive-card-50.png", "Click me!", "https://unytics.io/bigfunctions/")
select bigfunctions.europe_west1.send_teams_adaptive_card("YOUR_WEBHOOK_URL", "BigFunctions", "Hello 👋 from bigfunctions!", "https://adaptivecards.io/content/adaptive-card-50.png", "Click me!", "https://unytics.io/bigfunctions/")
+----------+
| response |
+----------+
| ok       |
+----------+

Need help or Found a bug using send_teams_adaptive_card?
Get help using send_teams_adaptive_card

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about send_teams_adaptive_card

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.

Use cases

A use case for the send_teams_adaptive_card 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_adaptive_card 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_adaptive_card(
    "YOUR_WEBHOOK_URL",
    "Daily Sales Update", -- title
    CONCAT("Daily sales data aggregation complete!  Total sales: $", SUM(daily_sales)), -- message
    "https://adaptivecards.io/content/adaptive-card-50.png" -- image_url (optional)
    "Click me!", -- button_text (optional)
    "https://www.bigfunctions.com" -- button_link (optional)
);

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_adaptive_card 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_adaptive_card(
                "YOUR_WEBHOOK_URL",
                "ALERT", -- title
                "Website traffic is unusually low!", -- message
                "https://cdn-icons-png.freepik.com/512/5735/5735886.png" -- image_url (optional)
                "Check this out!", -- button_text (optional)
                "https://www.bigfunctions.com" -- button_link (optional)
            )
        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_adaptive_card(
            "YOUR_WEBHOOK_URL",
            "Data validation failed!", -- title
            CONCAT("Found ", invalid_records, " invalid records."), -- message
            null, -- image_url (optional)
            null, -- button_text (optional)
            null -- button_link (optional)
        )
    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_adaptive_card 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!

Share on Add a on