Daily birthday reminder email with Python and GitHub Actions

0
0
Daily birthday reminder email with Python and GitHub Actions

May possibly possibly additionally trustworthy 24, 2020

After forgetting however another birthday, I made up my thoughts to location up an easy on every day basis e mail reminder machine. It comprises a Python program that’s scheduled to flee on every day basis utilizing GitHub Actions. The whole birthdays and diversified anniversaries are maintained in a csv file and the on every day basis e mail is ship utilizing Sendgrid API. Attributable to the low volumes, the ultimate corporations and merchandise passe – are on FREE plans.

Since environment it up, I expose built-in some foreign exchange and stock mark information into the on every day basis mail. The code is built-in on this program nevertheless might furthermore be commented out if no longer passe as confirmed extra beneath.

GitHub Repository: https://github.com/whoek/birthday-reminder

Instruments and API’s passe

  • Birthday guidelines and Python program is on GitHub
  • Github Actions set off the on every day basis e mail
  • SendGrid API to ship emails

Non-mandatory

  • IEX Cloud API for catch stock prices
  • Finnhub API for catch foreign exchange charges

Native set up

  1. Clone this GitHub Repository
  2. In the event you occur to don’t have religion to embody stock prices and foreign exchange data, remark out get_forex_html() and get_stock_html() in predominant()
    • In the event you occur to guard to have religion to embody foreign exchange data, catch an API key from Finnhub. It is a great distance free for normal quotes
    • For stock quotes, catch a key from IEX Cloud. It is a great distance free for low amount, normal data
def predominant(): 
    html_content = 
#       get_forex_html() + 
#       get_stock_html() + 
        get_birthday_html()
  1. Arrange Python dependencies with pip set up environs requests sendgrid.
  2. Win a SendGrid API key. It is a great distance free when you despatched a low amount of emails per day
  3. Replace the important thing data within the .env file
  4. Journey with python daily_email.py

GitHub Actions

  1. Accomplish sure GitHub Actions is Enabled internal Settings of your repository
  2. Swap the scheduled time in file .github/workflows/pythonapp.yml. Use crontab guru as guide whereas it is good to possibly presumably successfully be now to not lunge with cron settings
  3. To hint residing or re-flee an Motion, see data under the Actions

GitHub Actions

Runtime is under 1 minute. On the GitHub free thought, it is good to possibly presumably furthermore trustworthy have religion 2,000 Actions minutes/month readily available. So no sing there.

workflow

Birthdays

Affirming the birthday file

I passe normal csv file construction in place of yaml, json or any diversified. Proper right here is in say that I am able to retain the guidelines with out misery on my native machine utilizing Excel. It additionally shows effectively on GitHub.

Sample file

birthday,age,identify,level to
2020-06-21,as quickly as,Father's Day,Ireland
2021-06-20,as quickly as,Father's Day,Ireland
2022-06-19,as quickly as,Father's Day,Ireland
2020-05-26,45,Adrian Bruce,birthday
1964-05-27,0,Alexander MacDonald,birthday
  • birthday – Ought to be in yyyy-mm-dd construction
  • age – Likelihood is excessive you will furthermore enter the age of the particular particular person on the required date. Accomplish this Zero if date of beginning grew to become entered. Proper right here is passe to level to the calculated age of the particular particular person within the e mail. If age of specific particular person is unknown , proceed the age enviornment clean. The place the age enviornment is clean, the twelve months enviornment of birthday is missed. For as quickly as-off reminders or events, add the remember as quickly as within the age enviornment. The reminder will final be confirmed on date indicated.

Day-to-day e mail

workflow

Edit

LEAVE A REPLY

Please enter your comment!
Please enter your name here