luveqz / airtable-postmark-integration-poc

Automates email notifications based on Airtable updates. A quick PoC for an Animal Advocacy Careers volunteer request.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Airtable-Postmark Integration PoC

A serverless function that sends email notifications (via Postmark) every time an Airtable form is submitted. This is a proposal for an Animal Advocacy Careers volunteer request.

⚡ Development

First, make sure you have:

Set the required env variables:

cp .env.example .env

Then just install the project and run the development server:

yarn && npx vercel dev

Go to http://localhost:3000/api/handler.

If everything was properly setup, you should see a JSON response from Postmark:

[
  {
    "To": "receiver@example.com",
    "SubmittedAt": "2023-12-11T04:16:22.3461509Z",
    "MessageID": "1d01314b-ae4e-4gdc-a217-e4e1c3afd356",
    "ErrorCode": 0,
    "Message": "OK"
  },
  {
    "To": "receiver2@example.com",
    "SubmittedAt": "2023-12-11T04:16:22.3461509Z",
    "MessageID": "22bdabc-7c84-4ad2-bed8-107f2f637b31",
    "ErrorCode": 0,
    "Message": "OK"
  }
]

⚡ Production

1. Vercel Setup

Set the required env variables. It would be easier to just fill this file locally and then import it as a whole from Vercel:

cp .env.example .env

2. Airtable Webhook Setup

Create a new webhook:

curl -X POST "https://api.airtable.com/v0/bases/{baseId}/webhooks" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
--data '{
    "notificationUrl": "YOUR_NOTIFICATION_URL",
    "specification": {
      "options": {
        "filters": {
          "dataTypes": [
            "tableData"
          ],
          "fromSources": [
            "formSubmission"
          ],
          "recordChangeScope": "YOUR_TABLE_ID",
          "changeTypes": ["add"]
        }
      }
    }
  }'

Make sure you change the value of {baseId}, YOUR_TOKEN, YOUR_NOTIFICATION_URL and YOUR_TABLE_ID.

About

Automates email notifications based on Airtable updates. A quick PoC for an Animal Advocacy Careers volunteer request.


Languages

Language:TypeScript 79.2%Language:Shell 20.8%