Inspirational Quote Bot in Python

Cole Crescas
2 min readMay 11, 2021

Everyone likes to open their inbox every morning and find a motivational quote to start their day. I wanted to create a function that collects quotes from an API and sends out to the recipients in a list assigned to the variable “to” (not shown here for privacy).

To start we import the necessary packages including the unused scheduler package in case you wanted to automated the execution time. Setting up the quote API, I saved the quotes in a json format after pulling them from the URL given below. The author & text are then selected and passed into the yagmail loop where the author and text are printed for visibility & saved as two variables.

How It Works:

Fetching Quotes:

Selecting a Random Quote:

  • A random quote is selected from the list.

Sending Emails:

  • Yagmail is used to send emails, with the quote’s content as the email body and the author as the subject.
  • The recipients’ email addresses are specified in the to list.

Scheduling:

  • The script is scheduled to run daily at 8:00 AM using the schedule library.

To send an email, the user must create an email & configure the app password to provide the SMTP server…

--

--