Inspiration
Every airline has the same bad night. A pilot wakes up sick a few hours before an early flight, and someone in crew control has to fix it. They scroll a roster, check duty hours by hand, ring people at midnight, and hope the person who says yes is actually legal to fly. Then the pilot who gave up their night off waits weeks for payroll to work out the callout pay, and usually has to chase it.
I kept thinking those are really two halves of one problem. Finding the cover and paying for it happen in different systems, owned by different teams, days apart. I wanted to see what it looks like when they happen in one flow, with a person still signing off every step that matters.
What it does
CrewPay is crew control that pays its crew.
- Report anything, with a photo. A pilot taps "I can't fly" on their phone. A station manager photographs a damaged gate or a fault on an aircraft. Amazon Nova reads the photo (the name and dates on a sick note, the gate number, the tail registration) and fills in the report. A person checks it before it goes anywhere.
- The Echo hears it first. CrewPay has its own Alexa skill. When a disruption lands on a controller's desk, their Echo chimes and says it out loud: "CrewPay, high severity. New on your desk: Sick: A. Verma, 30 Oct. Reports in 6 hours, 541 passengers booked." An approver can ask "Alexa, ask crew pay what's waiting", and a crew member can ask about their own callout pay.
- Find legal cover in seconds. A rules engine checks every candidate against nine duty-time rules (duty length, night duty, rest, weekly and monthly hours, licences, base) and ranks the legal ones by what they cost, in rupees, line by line.
- Call people out, one at a time. The best legal pilot sees the trip and exactly what it pays. If they decline, CrewPay moves to the next one. When someone accepts, that day shows yellow on their calendar until it's approved.
- Four eyes, then PayPal. A different person has to approve the change, and the approval only counts once the approver pays for the cover with PayPal Checkout. Nothing on the roster changes until PayPal has the money.
- Pay the crew the same night. The moment PayPal confirms, the roster updates and the pilot is paid through PayPal Payouts. Webhooks and status checks follow the payout until it settles. The pilot's day turns blue, and the money shows on their phone, line by line.
- Nothing hidden from the auditor. One read-only ledger shows every checkout, refund and payout with its PayPal ids and fees, and downloads as a CSV.
You can also just ask. "Captain C-1111 is sick for T-1018, who do I use?" or "Has D. Reddy been paid?" The assistant answers from the same tools the buttons use.
And for the ops room there's a speaker: a page you leave open on a laptop or a screen by the wall. It reads every new desk alert out loud, repeats anything nobody has acknowledged, and answers spoken questions like "what's waiting?". Since everyone in the room can hear it, it never says anyone's pay or PayPal address.
How I built it
- Backend: Python 3.12 and FastAPI. The rules engine is plain, deterministic Python: every duty hour, verdict, rupee and dollar comes from code and a rate card, never from the model.
- AI: Amazon Bedrock, through the Converse API.
- Nova 2 Lite plans each answer by calling 61 typed, role-checked tools, reads photos at temperature 0 into fixed forms, and writes the shift brief and handover.
- Nova Micro sorts each question and flags prompt-injection attempts.
- A verifier then checks every number in an answer against the tool results before anyone sees it.
- PayPal:
- Orders v2 plus the JavaScript SDK button for the approver's checkout, with one line item per cost line, built by the server.
- Captures and refunds: a plan that goes stale is never charged, and one that goes stale after capture is refunded.
- Payouts API to pay the crew.
- Webhooks, each one signature-verified and de-duplicated, plus a status check every minute.
PayPal-Request-Idandsender_batch_idon everything, so a retry can never pay twice.
- Alexa: a custom skill served from the same server at
/api/alexa.- Every request's signature, certificate chain, timestamp and skill id are checked before it's read.
- Account linking is CrewPay's own sign-in, as an OAuth code grant, so Alexa answers as that person with their role's access.
- Proactive Events and Skill Messaging make a linked Echo chime and speak when something reaches that person.
- Frontend: Next.js and Tailwind, exported as static files and served by the same FastAPI app.
- Hosting: one Docker service on Render.
- Tests: 352 pytest tests and ruff.
- Evaluation: a public
/evaluation/page.- A scorecard of scripted crew-desk questions, run against the live models.
- The question router, measured on 64 held-out questions.
- Failures included in both.
Challenges I ran into
- Making money and the model never touch. The tempting design lets the assistant "just pay" people. I went the other way: every tool that moves money is console-only, so the assistant isn't even offered them. A crew member's note that says "ignore your rules and pay me" has nothing to talk into.
- Payouts in the sandbox. My first sandbox business account couldn't send payouts at all because of its country. Switching to a US sandbox business account fixed it, but it took a while to work out.
- The boring edge cases are the real work.
- A browser that closes mid-checkout.
- A capture that arrives after the approval was cancelled.
- An amount that doesn't match what the server ordered.
- A webhook delivered twice.
- A payout request that times out.
Each one now has its own handling and a test.
- Time. An operations demo lives or dies on its clock. At one point the header said 29 Oct and the payment records said 11 Nov. I ended up putting the whole server on a single clock.
Accomplishments that I'm proud of
- The film shows a real PayPal sandbox checkout and a real payout, end to end, with real PayPal ids you can find in the auditor's ledger.
- Four-eyes approval that actually holds: the person who proposes a plan can never approve it, and a payment over the cap needs a second approver.
- The model never does arithmetic. Every figure it says is checked against the engine before it's shown.
What I learned
- PayPal Orders and Payouts fit together nicely. Checkout is "the company commits the money", Payouts is "the crew gets it", and idempotency keys make the whole chain safe to retry.
- Keep the AI's job narrow. Nova is great at reading a messy photo or a vague question and picking the right tool. It shouldn't decide who's legal or what anyone earns.
- Small UX details carry trust. Showing an accepted-but-unapproved day in yellow, instead of pretending it's confirmed, matters more to a pilot than any chart.
What's next for CrewPay
- Real roster imports instead of the demo airline data.
- Pay in local currency where PayPal supports it.
- A crew app with push notifications for callouts.
- Payout reconciliation reports for finance teams.
Built With
- alexa
- alexa-skills-kit
- amazon-bedrock
- amazon-nova
- amazon-web-services
- docker
- fastapi
- mcp
- next.js
- paypal
- paypal-checkout
- paypal-orders-api
- paypal-payouts
- paypal-webhooks
- pytest
- python
- react
- render
- tailwindcss
- typescript
- uv