This thing mails letters to City Council.
-
Set up an AWS account.
-
Set up AWS keys on your machine.
-
Install node
-
Install serverless:
npm install -g serverless
-
Authorize AWS SES to send from your desired domain.
-
If you want to send to non-verified email addresses, request to move out of the sandbox. Otherwise, verify the email you're sending to.
-
Create a new env file, named:
env.<env name>.yml
(e.g.env.dev.yml
). See example -
Set up Slack
- Go to https://api.slack.com/apps
- Create a new app and attach it to your team
- Enable incoming webhooks for the app and select the channel that you want to post to. Copy the webhook URL into the env file.
- From the "basic information" tab, copy the verification token into the env file.
-
Deploy the Lambda functions
serverless deploy -s <env name>
-
Copy the Lambda URLs that serverless prints out:
- Enable interactive messages for the Slack app. Copy the URL of the
approve
function into the interactive messages request URL. - Copy the URL of the
submit
function into the code that is placed into NationBuilder.
- Enable interactive messages for the Slack app. Copy the URL of the
-
Insert the code snippets into NationBuilder (see example)
-
(Optional) Set up a Slack slash command to point to the
slash
endpoint URL.
The system consists of several parts:
- The form in NationBuilder (see example)
- 4 AWS Lambda functions (
submit
,approve
,slash
, andprocessSlashCommand
) - The Slack application
- (Optional) An S3 bucket for logging. Because we log in a consistent JSON format, you can use AWS Athena to query logs. We provide a Slack slash command to do this.
The workflow:
- User fills in form on NationBuilder
- The submission goes to the
submit
Lambda function. - This function sends a request to the Slack app, this is posted on a Slack channel
- Someone from the group reads the submission and clicks "Approve"
- Slack sends a request to the
approve
Lambda function. - The function uses AWS SES to send the email.
- If enabled, the function writes a JSON file containing the letter details to the S3 bucket.