Giter VIP home page Giter VIP logo

pfs-email-serverless's Introduction

pfs-email-serverless

This is a lambda function created by the serverless framework. It searches through members in our mongodb who have not been sent emails and sends them an email with their custom token to unlock the pledge free stream. It then marks those members off as already receiving the email.

The lambda should be triggered every 3 minutes to look for members to email. AWS CloudWatch Events handles the schedule.

Requirements

  • node
  • aws cli
  • serverless

Installation

Running

The lambda runs every 3 minutes during drive time (manually enabled at the start of drive), but if you want to trigger a run:

serverless invoke --function sendEmails -l

By default, this will run in 'dev' mode, which will email [email protected] instead of the user's real email. Dev mode will also not set that user's emailSent flag, which makes it easier to run the method again and send an email without having to manually reset that flag.

During drive time, a developer will deploy the 'prod' mode of lambda and attach the 'sendPFSemails_trigger' CloudWatch rule to that lambda so that it will run every 3 minutes.

Developing

Most of the changes you'll need to make such as copy changes or code changes will be done in handler.js. Once those changes are done, check it into git and type in

serverless deploy

to deploy those changes to AWS lambda, which is where the function will run when you do serverless invoke...

When you are sure everything is working, deploy it to prod with:

serverless deploy -s prod

The prod version will use real users' email addresses and mark them as emailSent = true once an email is sent.

Debugging

To quickly view the logs without having to play the 'click all links' game in the AWS console, you can run:

serverless logs --function sendEmails

Typically, if you are not seeing emails, either there are no users who have not been sent the email, or there is an IAM error and the lambda script can't decrypt any of the secrets or does not have the necessary permissions to read something.

pfs-email-serverless's People

Contributors

nakedsushi avatar

Watchers

 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.