rlisagor / ahv-council-thing

This thing mails letters to City Council.
3 stars 2 forks source link

This thing mails letters to City Council.

Set up dev environment

  1. Set up an AWS account.
  2. Set up AWS keys on your machine.
  3. Install node
  4. Install serverless:

    npm install -g serverless

Configure environment and deploy

  1. Authorize AWS SES to send from your desired domain.

  2. 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.

  3. Create a new env file, named: env.<env name>.yml (e.g. env.dev.yml). See example

  4. Set up Slack

    1. Go to https://api.slack.com/apps
    2. Create a new app and attach it to your team
    3. Enable incoming webhooks for the app and select the channel that you want to post to. Copy the webhook URL into the env file.
    4. From the "basic information" tab, copy the verification token into the env file.
  5. Deploy the Lambda functions

    serverless deploy -s <env name>
  6. 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.
  7. Insert the code snippets into NationBuilder (see example)

  8. (Optional) Set up a Slack slash command to point to the slash endpoint URL.

How it works

The system consists of several parts:

The workflow:

  1. User fills in form on NationBuilder
  2. The submission goes to the submit Lambda function.
  3. This function sends a request to the Slack app, this is posted on a Slack channel
  4. Someone from the group reads the submission and clicks "Approve"
  5. Slack sends a request to the approve Lambda function.
  6. The function uses AWS SES to send the email.
  7. If enabled, the function writes a JSON file containing the letter details to the S3 bucket.