Skip to content

Sendnotify

flowtask.components.SendNotify

SendNotify

SendNotify(loop=None, job=None, stat=None, **kwargs)

Bases: DBSupport, FlowComponent

SendNotify

Overview

    The SendNotify class is a component for sending notifications to a list of recipients via various
    channels (e.g., email) using the Notify component. It supports adding attachments, templating messages
    with masked variables, and utilizing custom credentials for authentication.

.. table:: Properties
:widths: auto

    +----------------+----------+-----------+----------------------------------------------------------------------+
    | Name           | Required | Summary                                                                          |
    +----------------+----------+-----------+----------------------------------------------------------------------+
    | via            |   Yes    | The method for sending the notification, e.g., "email".                          |
    +----------------+----------+-----------+----------------------------------------------------------------------+
    | account        |   Yes    | A dictionary with server credentials, including `host`, `port`,                  |
    |                |          | `username`, and `password`.                                                      |
    +----------------+----------+-----------+----------------------------------------------------------------------+
    | recipients     |   Yes    | List of dictionaries with target user details for notification.                  |
    +----------------+----------+-----------+----------------------------------------------------------------------+
    | list           |   No     | Optional mailing list name for retrieving recipients from the database.          |
    +----------------+----------+-----------+----------------------------------------------------------------------+
    | attachments    |   No     | List of file paths for attachments to include in the notification.               |
    +----------------+----------+-----------+----------------------------------------------------------------------+
    | message        |   Yes    | Dictionary with the notification message content, supporting template variables. |
    +----------------+----------+-----------+----------------------------------------------------------------------+

Returns

    This component returns the input data after sending the notification. Metrics are recorded for each
    successful send, with details on recipients and the message content. If any specified attachment file
    is missing, a `FileNotFound` exception is raised. If there are errors in setting up or sending the
    notification, a `ComponentError` is raised with descriptive messages.


Example:

```yaml
SendNotify:
  via: email
  account:
    hostname: NAVIGATOR_ALERT_EMAIL_HOSTNAME
    port: NAVIGATOR_ALERT_EMAIL_PORT
    password: NAVIGATOR_ALERT_EMAIL_PASSWORD
    username: NAVIGATOR_ALERT_EMAIL_USERNAME
  attachments:
  - /home/ubuntu/symbits/bose/files/report/troc_open_tickets_{today}.csv
  masks:
    '{today}':
    - today
    - mask: '%Y-%m-%d'
    '{yesterday}':
    - yesterday
    - mask: '%Y-%m-%d'
    '{human-today}':
    - today
    - mask: '%m/%d/%Y'
    '{human-yesterday}':
    - yesterday
    - mask: '%m/%d/%Y'
    '#today-timestamp#':
    - current_timestamp
    - tz: America/New_York
  recipients:
  - name: Carlos Rivero
    account:
      address: crivero@trocglobal.com
  - name: Arturo Martinez
    account:
      address: amartinez@trocglobal.com
  - name: Jhoanir Torres
    account:
      address: jhtorres@trocglobal.com
  - name: Steven Greenstein
    account:
      address: sgreenstein@trocglobal.com
  - name: Sabra Pierre
    account:
      address: spierre1@trocglobal.com
  - name: Daniel McGee
    account:
      address: dmcgee@trocglobal.com
  - name: Kile Harris
    account:
      address: kharris10@trocglobal.com
  - name: Gerardo Espinoza
    account:
      address: gespinoza@trocglobal.com
  - name: Christopher Harmon
    account:
      address: charmon@trocglobal.com
  message:
    subject: T-ROC BOSE Break&Fix Open Tickets ({human-today})
    message_content: Please find attached the report generated on {human-today}.This
      is an automated message - please do not reply directly to this email.
    template: email_custom_report.html
    clientName: Bose
    dateGenerated: '{human-today}'
    created_at: '#today-timestamp#'
```

run async

run()

Running the Notification over all recipients.