Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flighty Email

A Cloudflare Worker that automatically extracts flight information from forwarded emails and posts formatted notifications to Slack.

How It Works

┌─────────────┐     ┌──────────────┐     ┌─────────────┐     ┌─────────┐
│   Email     │────▶│   Inbound    │────▶│   GPT-5.2   │────▶│  Slack  │
│  (forward)  │     │   Webhook    │     │  Extraction │     │  Post   │
└─────────────┘     └──────────────┘     └─────────────┘     └─────────┘
  1. Forward a flight confirmation email to your inbound email address
  2. Webhook receives the email via inbound.new (or similar service)
  3. AI extracts flight details using OpenCode Zen's GPT-5.2
  4. Slack notification is posted with all flight information

Features

  • Extracts multiple flights from a single email (round trips, connections, etc.)
  • AI-generated trip titles and descriptions
  • Structured data extraction:
    • Flight numbers
    • Confirmation codes (PNR)
    • Airlines
    • Departure/arrival airports and times
    • Passenger names and seat assignments
  • Beautiful Slack notifications with Block Kit formatting
  • "Track Flight" buttons linking to FlightRadar24

Example Slack Message

┌─────────────────────────────────────────────┐
│  Cancun Getaway                             │
├─────────────────────────────────────────────┤
│  Round trip from Jacksonville to Cancun,   │
│  Jan 23-28, 2026                            │
├─────────────────────────────────────────────┤
│  Flight 1: AA 1018            [Track Flight]│
│  American Airlines                          │
│                                             │
│  From:          To:                         │
│  JAX            MIA                         │
│                                             │
│  Departure:     Arrival:                    │
│  Fri, Jan 23    Fri, Jan 23                 │
│  6:00 AM        7:25 AM                     │
│                                             │
│  Confirmation: IMOZHR                       │
│  Passengers: Ryan Vogel (Seat 22A)          │
├─────────────────────────────────────────────┤
│  Flight 2: AA 2494            [Track Flight]│
│  ...                                        │
└─────────────────────────────────────────────┘

Setup

Prerequisites

Installation

# Clone the repo
git clone https://github.com/YOUR_USERNAME/flighty-email.git
cd flighty-email

# Install dependencies
npm install

# Login to Cloudflare
npx wrangler login

Configuration

Set the required secrets:

# Your OpenCode Zen API key
npx wrangler secret put OPENCODE_API_KEY

# Your Slack incoming webhook URL
npx wrangler secret put SLACK_WEBHOOK_URL

Deploy

npm run deploy

Your worker will be available at: https://flighty-email.<your-subdomain>.workers.dev

Configure Email Webhook

Point your email webhook service to:

POST https://flighty-email.<your-subdomain>.workers.dev/api/inbound

The webhook expects a payload matching the inbound.new format.

Development

Local Development

# Create a .dev.vars file with your secrets
cat > .dev.vars << EOF
OPENCODE_API_KEY=your-opencode-api-key
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
EOF

# Start the dev server
npm run dev

Watch Logs

# Pretty-printed logs from deployed worker
npm run logs

# JSON format (for piping to jq)
npm run logs:json

Type Check

npx tsc --noEmit

API

POST /api/inbound

Receives email webhook payloads and processes them.

Request Body: Email webhook payload (see src/types.ts for schema)

Response:

{
  "success": true,
  "message": "Webhook processed",
  "emailId": "inbnd_abc123",
  "flightData": {
    "tripTitle": "Cancun Getaway",
    "tripDescription": "Round trip from Jacksonville to Cancun, Jan 23-28, 2026",
    "isFlightEmail": true,
    "flights": [...]
  },
  "slackSent": true
}

GET /

Health check endpoint.

Response:

{
  "status": "ok",
  "service": "flighty-inbound-worker"
}

Tech Stack

License

MIT

About

Cloudflare Worker that extracts flight info from emails and posts to Slack

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages