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.

KeyTypeDescription
typestringrequired, value = http
urlstringrequired, an URL you want to request
methodstringrequired, GET, POST, PUT, DELETE
retry_countintan 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.

KeyTypeDescription
typestringrequired, value = trigger-airflow-dag
base_urlstringrequired, airflow base url domain or IP address
usernamestringrequired, api user
passwordstringrequired, api password
dag_idstringrequired, name of DAG you want to trigger
retry_countintan 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."}'