GithubHelp home page GithubHelp logo

twitter-digest's Introduction

Twitter Digest ✉️

twitter email digest gif

A netlify lambda function to send you email digests of twitter lists.

I decided to create twitter digest to help me spend less time on social media. Particulary during the COVID-19 global pandemic.

It is completely free to run.

Code Tutorial: https://tobenxe.com/building-a-netlify-lambda-function-to-turn-twitter-lists-into-email-digests/

Requirements

  • A netlify account
  • A sendgrid account + API key
  • A twitter API key & API secret
  • Some cron service to schedule the email. (https://cron-job.org/, https://easycron.com are some options if you don't have something already)
  • An email [o_o]

Usage

1) Deploy to Netlify

2) Fill in environment variables:

During the initial site setup at step 3 you should be able to set environment variables by clicking "show advanced" > "new variable".

Basic Authorization:
Name:       Value:
AUTH_USER   <some made up but secure username>
AUTH_PASS   <some made up but secure password>

This helps provide some protection to the endpoint so only your cron job can access the function. The function checks for an authorization header in requests, it will use AUTH_USER and AUTH_PASS to work out what the appropriate header value a legitimate request would have.

NOTE: This does not have to be your twitter user name or password, it is probably best if it isn't.

Learn more about HTTP basic auth here.

Twitter Authentication
Name:           Value:
TWITTER_KEY     <twitter api key>
TWITTER_SECRET  <twitter api secret>

The function uses app only auth. You'll need a twitter developer account to get these.

Twitter List ID
Name:            Value:
TWITTER_LIST_ID  <twitter list id>

If you look in the address bar when you are on your list: eg. https://twitter.com/i/lists/1245290837988315136

The TWITTER_LIST_ID will be 1245290837988315136

Email
Name:      Value:
MY_EMAIL   <youremail>@<mailprovider>.<tld>

The email you'd like the digest to be sent to, for example [email protected]

NOTE: When you get the first email, you may have to check your spam folder initially and mark the email as "not spam"

Sendgrid Authentication
Name:          Value:
SENDGRID_KEY   <sendgrid api key>

Your API key from sendgrid. You can find a tutorial on how to get this here

3) Schedule request to the function

You can use any cron job service that allows HTTP basic authentication (most of them do). In the tutorial I used https://cron-job.org. You should specify a user and a password (should be the same as AUTH_USER and AUTH_PASS) to enable HTTP basic auth.

If you are using some other method (maybe your own server/machine) to schedule the request, you need to set the Authorization header (remember to encode your 'user:password' string after 'Basic ' to base64!).

Local Development

Create a .env file in the root of the directory to store the environment variables. Create a webpack.functions.js like the one here Run the following commands

npm install
npm run start:lambda //to test locally

Possible Todos/Ideas (contribution ideas):

  • Add a since_id prop to the twitter API call in order to avoid getting duplicate tweets (would need some persistence of the id for the last fetched tweet, preferably free).
  • Make the html email look nicer ? (looks simple enough already but maybe it could look better).
  • Swap out sendgrid API for just smtp with nodemailer (or an alternative).

twitter-digest's People

Contributors

tobenxe avatar

Watchers

Manel Vilar avatar

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.