Giter Club home page Giter Club logo

notification-service-py's Introduction

Notification Service (Python)

Contains Python scripts to send notifications through a variety of media, like email and SMS. For instructional purposes.

Prerequisites

  • Anaconda 3.7
  • Python 3.7
  • Pip
  • Git

Installation

Fork the repository from GitHub source.

Then use GitHub Desktop or the command-line to "clone" or download your fork onto your local computer:

git clone https://github.com/YOUR_USERNAME/notification-service-py.git # this is the HTTP address, but you could alternatively use the SSH address

Navigate into your local repo before running any of the other commands below:

cd notification-service-py

Setup

Create and activate an Anaconda virtual environment. From within the virtual environment, install package dependencies listed in the "requirements.txt" file:

pip install -r requirements.txt

Copy the ".env.example" file to a new file called ".env" (in your local repo, NOT your remote repo), and update the environment variables inside as necessary (see below).

Email

For email capabilities, sign up for a SendGrid account, click the link in a confirmation email to verify your account, then create a new API key with "full access" permissions. Note the email address you used, and the value of the API Key, and store them in environment variables called MY_EMAIL_ADDRESS and SENDGRID_API_KEY, respectively.

SMS

For SMS capabilities, sign up for a Twilio account, click the link in a confirmation email to verify your account, then confirm a code sent to your phone to enable 2FA.

Then create a new project with "Programmable SMS" capabilities. And from the console, view that project's Account SID and Auth Token. Update the contents of the ".env" file to specify these values as environment variables called TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN, respectively.

You'll also need to obtain a Twilio phone number to send the messages from. After doing so, update the contents of the ".env" file to specify this value (including the plus sign at the beginning) as an environment variable called SENDER_SMS.

Finally, set an environment variable called RECIPIENT_SMS to specify the recipient's phone number (including the plus sign at the beginning).

Twitter

For tweeting capabilities, create a Twitter Account. Then while logged in to Twitter, visit the Twitter Application Management Console and click "Create New App" to create a new Twitter Application. You might have to first sign up for a Twitter developer account, and click the link in a confirmation email.

After creating a new application, click on the "Keys and Access Tokens" tab, and note the application's "Consumer Key" and "Consumer Secret". Scroll down and generate a new Access Token and note its "Access Token" and "Access Token Secret" values. Update the contents of the ".env" file to store these four values in the following environment variables, respectively: TWITTER_API_KEY, TWITTER_API_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET.

Usage

Send Email

Send email to the address specified:

python app/send_email.py

Send email template with image to the address specified:

python app/send_receipt_template.py

Send SMS

Send an SMS to the phone number specified:

python app/send_sms.py

Send a Tweet

Post a message to the Twitter platform:

python app/send_tweet.py

notification-service-py's People

Contributors

s2t2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

notification-service-py's Issues

Add tests

To provide a good example and promote quality control best practices, this app should be tested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.