Send users notifications through various platforms
Project description
Notify
Sending mails and teams messages in a smart way. This project makes it easy to send basic messages through Teams or Email.
Installation
pip install zyppnotify
Notify Mail
When using the NotifyMail
class, the environment variables EMAIL_USER
(mailadress you want to mail with), MAIL_TENANT_ID
, MAIL_CLIENT_ID
and MAIL_CLIENT_SECRET
(3x App registration credentials with User.Read.All permission with admin consent to authenticate to MS Graph) need to be set.
The initialization of this class will return an error if one of thes variables is not set.
from notify import NotifyMail, NotifyTeams
# versturen van een basis bericht met onderwerp en tekst
mail = NotifyMail(to="reveiver@domain.com",
subject="Notify me!",
message="This is a test message, send through the notify package")
mail.send_email()
Notify Teams
For the Notify for Teams (1.0.0) you can create a webhook as by following the steps in the Microsoft documentation.
Requirement: Add member that sends the message to the channel
In the workflow app, make sure the message is sent as user, and not as Flowbot.
from notify import NotifyTeams
from notify.tests import import_sample_dfs
webhook = ("REPLACE_ME")
teams = NotifyTeams(webhook=webhook)
# versturen van een basis bericht met onderwerp en tekst
teams.basic_message(title="Notify me!",
message="This is a test message, send through the notify package")
# versturen van een uitgebreid rapport over dataframes.
dfs = import_sample_dfs()
teams.basic_message(title="Notify me!",
message="This is optional",
buttons={"button_name": "https://www.my_link.nl"},
dfs=dfs) # creates a report on the dataframes processed.
Add extra elements to Teams message
With the parameter extra
the user can add adaptive cards elements to the message. The extra
parameter should be a
list of dictionaries. The dictionaries should contain the keys index
and item
. The index
key should be an integer
and the item
key should be a dictionary containing the adaptive card element. The index
key determines the location
in the message.
from notify import NotifyTeams
webhook = ("REPLACE_ME")
teams = NotifyTeams(webhook=webhook)
extra_item = {"type": "TextBlock", "color": "good", "text": "This is extra text in green", "wrap": "true"}
teams.basic_message(title="Notify me!",
message="This is optional",
buttons={"button_name": "https://www.my_link.nl"},
extra=[{"index": 3, "item": extra_item}]) # creates a report on the dataframes processed.
With the method create_adaptive_card_dataframe(df)
you can create an Adaptive Card dataframe to be added as an extra element.
from notify import NotifyTeams
from notify.tests import import_sample_dfs
webhook = ("REPLACE_ME")
teams = NotifyTeams(webhook=webhook)
df = import_sample_dfs().get("Transactions")
extra_df = teams.create_adaptive_card_dataframe(df)
teams.basic_message(title="Notify me!",
message="This is optional",
buttons={"button_name": "https://www.my_link.nl"},
extra=[{"index": 3, "item": extra_df}]) # creates a report on the dataframes processed.
Notify utils
from notify import format_numbers, dataframe_to_html
from notify.tests import import_sample_dfs
df = import_sample_dfs().get("Transactions")
# format numbers and currencies using dutch locale
df = format_numbers(df, currency_columns=["amount"], number_columns=[])
html_table = dataframe_to_html(df)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zyppnotify-1.0.1.tar.gz
.
File metadata
- Download URL: zyppnotify-1.0.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3244953b72c9117a68f0ff6350c51e112cb1d6a95d4f8cbaec6a1f551d011a3 |
|
MD5 | 1b909f3bd11d44e8306832011487c88e |
|
BLAKE2b-256 | 9c4ed27eeba35920b4c479e0b6b0acf2bc12bc893a7355dd2e3739b6310e0899 |
File details
Details for the file zyppnotify-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: zyppnotify-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ca3a83dde6fac168521ded87920f75e6a16fb52fe3b9431e10c40dfd538b7a6 |
|
MD5 | fc58656696cd2be919cc20d4baa3e49b |
|
BLAKE2b-256 | 6199ebf2ee5cd55183747bc4a65969a68dfa072d2a5a54645ac8fe402bdcfc87 |