Python API
Notifier
- class RPA.Notifier.Notifier
- 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 Notifywhich 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 Emailcould 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, ) - ROBOT_LIBRARY_DOC_FORMAT = 'REST'
 - ROBOT_LIBRARY_SCOPE = 'GLOBAL'
 - generic_notify(provider_name: str, **kwargs)
- Generic keyword to use with any notifier provider. - Parameters:
- provider_name – name of the notifier service 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not 
 
 - notify_email(message: str | None = None, to: str | None = None, username: str | None = None, password: str | None = None, host: str | None = None, port: int = 587, tls: bool = True, **kwargs) bool
- Notify using email provider - Parameters:
- message – notification message 
- to – target of email message 
- username – email account username 
- password – email account password 
- host – email SMTP host name 
- port – email SMTP host port number 
- tls – should TLS be used (default True) 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not 
 - Example. - # Notify with Outlook account Notify Email ... message=Message from the Robot ... to=RECIPIENT_EMAIL_ADDRESS ... username=OUTLOOK_USERNAME ... password=OUTLOOK_PASSWORD ... host=smtp.office365.com ... subject=Subject of the Message 
 - notify_gmail(message: str | None = None, to: str | None = None, username: str | None = None, password: str | None = None, **kwargs) bool
- Notify using Gmail provider - Parameters:
- message – notification message 
- to – target of email message 
- username – GMail account username 
- password – GMail account password 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not 
 
 - notify_pushover(message: str | None = None, user: str | None = None, token: str | None = None, **kwargs) bool
- Notify using Pushover provider - Parameters:
- message – notification message 
- user – target user for the notification 
- token – service token 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not 
 
 - notify_slack(message: str | None = None, channel: str | None = None, webhook_url: str | None = None, **kwargs) bool
- Notify using Slack provider - Parameters:
- message – notification message 
- channel – target channel for the notification 
- webhook_url – Slack webhook url 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not 
 
 - notify_telegram(message: str | None = None, chat_id: str | None = None, token: str | None = None, **kwargs) bool
- Notify using Telegram provider - Parameters:
- message – notification message 
- chat_id – target chat id for the notification 
- token – service token 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not 
 
 - notify_twilio(message: str | None = None, number_from: str | None = None, number_to: str | None = None, account_sid: str | None = None, token: str | None = None, **kwargs) bool
- Notify using Twilio provider - Parameters:
- message – notification message 
- number_from – number where the message comes from 
- number_to – number where the messages goes to 
- account_sid – Twilio account SID 
- token – Twilio account token 
- kwargs – see library documentation 
 
- Returns:
- True if notification was successful, False if not