...
Python 3
boto3
Using the package
Copy the
notification_service
directory in to the directory with your other Python code
Code Block |
---|
my-research-project-repo/ ├── notification_service/ │ ├── email.py │ └── sms.py ├── README.md ├── raw-data-extraction.py ├── data-processing.py ├── data-analysis.py └── send-notifications.py |
Import the package
Code Block |
---|
import notification_service.email as email import notification_service.sms as sms |
Email notification example
Code Block |
---|
email_payload = { "addresses": [ # If name is used, then name must use MIME encoded-word syntax # You can also use a simple email addresse email.encode_address(name="John Q. Public", address="john.public@dot.gov"), "john.q.public@dot.gov" ], # Subject longer that 78 characters will be truncated. "subject": "SDC: Demo research-_teams_notification-_service", # Body text longer than 128 characters will be truncated "body_text": "This is a demo of the research-_teams_notification-_service." } email_response = email.send(email_payload) print(email_response) |
SMS notification example
Code Block |
---|
sms_payload = { "phone_numbers": [ # A string with 10 numeric digits, US phone numbers only "7035550161", "703-555-0159", "703.555.0130", "(703) 555-0156", ], # Messages longer than 128 characters will be truncated "message": "This is a demo of the research-_teams_notification-_service." } sms_response = sms.send(sms_payload) print(sms_response) |
...
FunctionName (string), required
research-_teams_notification-_service
Payload (JSON formatted string), required
type
(string), requiredemail
to_addresses
(list of strings), not more than 50 recipients, requiredsubject
(string), max 78 characters, requiredbody_text
(string), max 128 characters, requiredreply_to_addresses
(list of strings), required
...
FunctionName (string), required
research-_teams_notification-_service
Payload (JSON formatted string), required
type
(string), requiredsms
phone_number
(string), 10 digit number, US numbers only, requiredmessage
(string), max 128 characters, required
...