Skip to content

Removing email, adding to readme #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,37 @@ To start the application locally, run:
> Generate a new GraphQL API key, with expiration of 364 days.

> `amplify push`

## Tech stack

This application was largely built through AWS Amplify and much of the backend is serverless.

We used React for the frontend, a GraphQL api for the datastore interaction, NoSQL DynamoDB as the datastore, Cognito for login/authentication, and a Lambda based email notification service.

## Email Notification

#### API Call

Our notification system used a REST call to API Gateway. That Gateway triggered a Lambda function which leveraged Amazon SES (Simple Email Service) to send out an email template with values from the API call substituted in. The API call in the code can be found in the AddComplaintSummary Component.

```
async function sendEmail() {
const apiName = 'acluNotificationAPI';
const path = '/sendEmail';
console.log("sending email")
const myInit = {
body: {"complaintId": values.complaintID,
"email": values.emailAddress,
"complaintStatus": values.complaintStatus},
};
return await API.post(apiName, path, myInit);
}
```

This call leverages our Cognito authentication to reach API Gateway. API Gateway will need CORS disabled for testing purposes.

#### Lambda
The Lambda code can be found in the sendEmailLambda index.js file. This lambda will need an IAM role attached with SES permissions. The "to" and "source" email fields are left blank but these can be sourced from the API call, a DB, Lambda environment variables, or hardcoded.

#### SES
Setting up SES for testing starts with creating and verifying a sender identity - a domain or email address you use to send email through Amazon SES. Your account will begin in the SES sandbox which imposes some limits on your activity - most notably only allowing messages to already verified email addresses. Moving out of the sandbox requires a production request, details found here : https://docs.aws.amazon.com/ses/latest/dg/request-production-access.html
4 changes: 2 additions & 2 deletions client/amplify/backend/function/sendEmailLambda/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ async function sendMail(subject, data,event) {

const emailParams = {
Destination: {
ToAddresses: ["[email protected]"],
ToAddresses: [to-email],
},
Message: {
Body: {
Text: { Data: data },
},
Subject: { Data: subject },
},
Source: "[email protected]",
Source: source-email,
};

let code = 200;
Expand Down