Skip to main content

Notification

Naas provides you with an easy way to send emails straight from your notebook. This is incredibly useful when you want to send data updates, reports, or any type of alert to your colleagues or yourself.

Simple Text Notifications

To send an email, you can use the following code:

import naas

naas.notification.send(
email_to="[email protected]",
subject="Hello world 👋🌏",
html="Naas is here for you"
)

This will send an email to [email protected] with the subject "Hello world 👋🌏" and the content "Naas is here for you".

Notifications with Attachments

If you need to include attachments, you can specify them as follows:

import naas

naas.notification.send(
email_to="[email protected]",
subject="The tesla action is going up",
html="check in the link the chart data made from fresh dataset : [LINK]",
files=["path/to/my/super/data.csv"]
)

In this case, data.csv will be attached to the email.

HTML Notifications

You can also use HTML content in your notifications, such as adding images:

import naas

naas.notification.send(
email_to="[email protected]",
subject="The tesla action is going up",
html="<h1>Check in the link the chart image below</h1><br/> <img src='path/to/my/super/data.png'/>"
)

Custom Sender

By default, the emails will be sent from your Naas account email. However, you can specify a different sender:

import naas

naas.notification.send(
email_to="[email protected]",
subject="❤️ Check this email sent from Naas",
html="I made this in 1 min. It's so easy to send emails with naas.ai",
email_from="[email protected]"
)

Listing Sent Notifications

You can list all the notifications you have sent using naas.notification.list():

import naas

naas.notification.list()

If you are an admin, you can list all notifications sent by users with naas.notification.list_all():

import naas

naas.notification.list_all()

This way, Naas allows you to keep track of all the notifications sent through your notebooks.