Notifier is a library interfacting with different notification providers.

Supported providers

  • email
  • gmail
  • pushover
  • slack
  • telegram
  • twilio

Providers not supported yet via specific keywords

  • gitter
  • join
  • mailgun
  • pagerduty
  • popcornnotify
  • pushbullet
  • simplepush
  • statuspage
  • zulip

There is a keyword Generic Notify which can be used to call above services, for example.

Generic Notify
    provider_name=gitter
    message=Hello from Robot
    token=TOKEN
    room_id=ID_OF_THE_GITTER_ROOM

Parameters for different providers can be read from the Notifiers documents (link below).

Read more at https://notifiers.readthedocs.io/en/latest/

About kwargs

The **kwargs is a term for any extra named parameters, which can be included in the same way as already named arguments, e.g. Notify Email could be called with subject=my email subject which will be passed through **kwargs.

Notifier documentation contains information about all possible arguments that different providers support.

Robot Framework

&{account}=    Create Dictionary
...    host=smtp.office365.com
...    username=ACCOUNT_USERNAME
...    password=ACCOUNT_PASSWORD
Notify Email
...    to=RECIPIENT_EMAIL
...    from_=SENDER_ADDRESS            # passed via kwargs
...    subject=Hello from the Robot    # passed via kwargs
...    message=Hello from the Robot
...    &{account}                      # passed via kwargs
notifier = Notifier()
account = {
    "host": "smtp.office365.com",
    "username": "EMAIL_USERNAME",
    "password": "EMAIL_PASSWORD"
}
notifier.email_notify(
    to="RECIPIENT_EMAIL",
    from_="SENDER_EMAIL",
    subject="Hello from the Python Robot",
    message="Hello from the Python RObot",
    **account
)

Examples

Robot Framework

*** Settings ***
Library  RPA.Notifier

*** Variables ***
${SLACK_WEBHOOK}   https://hooks.slack.com/services/WEBHOOKDETAILS
${CHANNEL}         notification-channel

*** Tasks ***
Lets notify
   Notify Slack   message from robot  channel=${CHANNEL}  webhook_url=${SLACK_WEBHOOK}

Python

from RPA.Notifier import Notifier

library = Notifier()

slack_attachments = [
   {
      "title": "attachment 1",
      "fallback": "liverpool logo",
      "image_url": "https://upload.wikimedia.org/wikipedia/fi/thumb/c/cd/Liverpool_FC-n_logo.svg/1200px-Liverpool_FC-n_logo.svg.png",
   }
]

library.notify_slack(
   message='message for the Slack',
   channel="notification-channel",
   webhook_url=slack_webhook_url,
   attachments=slack_attachments,
)