Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Python 3

  • boto3

Using the package

  1. 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
  1. Import the package

Code Block
import notification_service.email as email
import notification_service.sms as sms
  1. 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)
  1. 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), required

      • email

    • to_addresses (list of strings), not more than 50 recipients, required

    • subject (string), max 78 characters, required

    • body_text (string), max 128 characters, required

    • reply_to_addresses (list of strings), required

...

  • FunctionName (string), required

    • research-_teams_notification-_service

  • Payload (JSON formatted string), required

    • type (string), required

      • sms

    • phone_number (string), 10 digit number, US numbers only, required

    • message (string), max 128 characters, required

...