Notifications
Created: January 26, 2024, Updated: April 17, 2024
Notification is a way to send an HTTP request from Bizzflow. You will learn how to create a notification.
Notifications provide us with a way to send an HTTP notification, for example to trigger a DAG in another Airflow, send message to Slack, trigger a webhook in Zapier or in any other destination. Notifications can be a part of orchestrations.
Notification Configuration
Each notification is defined by its id and type. There are two types of notification.
HTTP notification
This type of notification is powerful, but can be complicated to set up. It allows to send any HTTP request. Bellow is a list of required and optional parameters. You can also use any other pair key: value, those will be used as kwargs for python requests lib. See Docs.
Key | Type | Description |
---|---|---|
type | string | required, value = http |
url | string | required, an URL you want to request |
method | string | required, GET, POST, PUT, DELETE |
retry_count | int | an optional amount of retries when response is not 2xx, default is 0 |
Airflow DAG trigger
A simplified notification type for triggering airflow DAG via API. It uses HTTP BaseAuth. In order to use it, you must have API access enabled in the destination project.
Key | Type | Description |
---|---|---|
type | string | required, value = trigger-airflow-dag |
base_url | string | required, airflow base url domain or IP address |
username | string | required, api user |
password | string | required, api password |
dag_id | string | required, name of DAG you want to trigger |
retry_count | int | an optional amount of retries when response is not 2xx, default is 0 |
Example
There two notifications, first triggering a DAG in airflow and a second one sending message to slack.
notifications.json
{
"marketing-orch": {
"type": "trigger-airflow-dag",
"base_url": "https://myproject.bizzflow.app",
"username": "apiuser",
"password": "#!#:myprojecapipassword",
"dag_id": "00_Orchestration_marketing",
"retry_count": 2
},
"slack-notification": {
"type": "http",
"url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
"method": "POST",
"retry_count": 0,
"headers": {"Content-Type": "application/json", "Accept": "application/json"},
"data": "{\"text\": \"Hello, world.\"}"
}
}
Again, everything works the same with YAML
:
notifications.yaml
---
marketing-orch:
type: trigger-airflow-dag
base_url: https://myproject.bizzflow.app
username: apiuser
password: "#!#:myprojecapipassword"
dag_id: 00_Orchestration_marketing
retry_count: 2
slack-notification:
type: http
url: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
method: POST
retry_count: 0
headers:
Content-Type: application/json
Accept: application/json
data: '{"text": "Hello, world."}'