You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-tos/airflow/send-ms-teams-notifications.md
+37-12Lines changed: 37 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,45 @@ sidebar_position: 35
8
8
9
9
As stated in [how to send email notifications](/docs/how-tos/airflow/send-emails), Airflow allows multiple ways to inform users about DAGs and tasks status.
10
10
11
-
Furthermore, it's important to understand Airflow handles these 4 status (`failure`, `retry`, `success` and `missed SLA`) via callbacks. You can learn more about them [here](https://airflow.apache.org/docs/apache-airflow/2.2.1/logging-monitoring/callbacks.html)
11
+
Furthermore, it's important to understand Airflow handles these 4 status (`failure`, `retry`, `success` and `missed SLA`) via callbacks. You can learn more about them [here](https://airflow.apache.org/docs/apache-airflow/2.2.1/logging-monitoring/callbacks.html).
12
12
13
-
Below we explain how to use those callbacks to send Microsoft Teams notifications.
13
+
## Prepare the Microsoft side
14
14
15
-
## Prepare Microsoft Teams
15
+
Sending messages through Teams is done using Power Automate webhooks. These connections can be assigned to Teams channels, chats, or individuals. It is a simple two step automation: a webhook receives the DAG notification, and an action posts it to your Teams.
16
16
17
-
Sending messages through Teams is done using Webhooks. These connections can be assigned to MS Teams channels.
17
+
Everything on the Microsoft side is managed through their [Power Automate](https://make.powerautomate.com/) application. Choose `My flows` from the sidebar:
18
18
19
-
In the channel you want to send Airflow notifications to, click the `...` -> `Connectors` and search for `Incoming Webhook`.
Choose `Instant cloud flow` from the `New flow` dropdown:
22
22
23
-
Click `Configure`, give it a name, and optionally select an image to use as the sender's avatar, then click `Create` and you will be given a webhook URL.
This will create a flowchart with just the webhook on it. Click on it to bring up a sidebar with its settings. Make sure it is set to allow anyone to trigger the flow. Also note the empty URL field here; we will have to come back for it after the flow is saved. You can name this flow at any time by clicking on the title text (shown here as `Untitled flow`).
Then, click the (+) on the flowchart to add an action. Type `card` into the search box to narrow the results, then choose `Post card in a chat or channel`:
The settings for this action determine where your notification will go. First, paste the following into the `Adaptive Card` field; this tells the workflow how to read the notifications:
38
+
-`@triggerBody()?['attachments'][0]?['content']`
39
+
40
+
Then set `Post In` to `Chat with Flow bot` to message only yourself, or for group messages, `Group chat` or `Channel`. For the latter two, there are more fields to set the exact destination.
Now click Save in the upper right corner of the screen, and when it finishes, you can return to the webhook's sidebar and copy the URL it's generated. Make sure to copy all of it.
26
45
27
46
:::info
28
-
Store this URL in a safe place as you will need it in a subsequent step and anyone with this link can send notification to that MS Teams channel.
47
+
Store this URL in a safe place as you will need it in a subsequent step and anyone with this link can send notifications to that Teams channel.
29
48
:::
49
+
30
50
## Prepare Airflow
31
51
### Create a new Integration
32
52
@@ -86,7 +106,13 @@ To send MS Teams notifications, in the Airflow DAG we need to import the appropr
86
106
-`connection_id`: the name of the Datacoves Integration created above
87
107
- if no connection_id is specified, MSTeams Notifier will use `ms_teams`
88
108
-`message`: the body of the message
89
-
-`theme_color`: theme color of the MS Teams card
109
+
-`theme_color`: theme color of the MS Teams card. This may be one of:
110
+
-`default`
111
+
-`emphasis`
112
+
-`good`
113
+
-`attention`
114
+
-`warning`
115
+
-`accent`
90
116
91
117
:::info
92
118
`on_failure_callback` will throw an error if using lists causing your task to fail.
0 commit comments