DEV Community

Cover image for InboxNegotiator: Turning Debt Reminders into Payment Plans with AI and Postmark
FranP-code
FranP-code Subscriber

Posted on

InboxNegotiator: Turning Debt Reminders into Payment Plans with AI and Postmark

This is a submission for the Postmark Challenge: Inbox Innovators.

What I Built

I built InboxNegotiator, a serverless AI-powered engine that transforms stressful payment reminder emails into manageable, negotiated payment plans.

The concept is simple:

  1. A user receives a payment reminder email from a creditor on the webhook defined on Postmark inbound parsing.
  2. It is being handled by AI to understand the asked debt and generate and generate a legally compliant negotiation response.
  3. The users handle the response to modify it and sent it to creditor.
  4. Everything is tracked on a sleek, real-time dashboard where the user can see the negotiation status, the proposed plan, and projected savings.

It's designed to be a "fire-and-forget" solution to the tedious and often intimidating process of communicating with creditors, leveraging the power of automation and AI to advocate on the user's behalf.

Demo

Live App: https://inbox-negotiator.vercel.app

How to Test:

  1. Create an account on the app.

  2. On onboarding, you will be asked for add an additional email. Go to your Postmark server -> Default Inbound Stream and copy your inbound email address. Put it in in the additional email input.

  3. Go to your Postmark server -> Default Inbound Stream and introduce https://inbox-negotiator.vercel.app/api/postmark on the Webhook input.

  4. Recieve a email asking for a debt. Here's a template for you :)

    Subject: Outstanding Utility Bill Payment Due
    Body: Dear customer, you owe $1,250.50 to CreditPlus for your January utility bills. Please pay by 2025-06-15 to avoid penalties
    
  5. (Optional) Add your Postmark Server Token to be able to send a response directly from the app. (You will need to be authorized on Postmark to send emails with the receptor's email address and domain)

  6. In around 30 seconds you will have an AI generated email to negotiate the terms of the debt. Modify it as you want and send it.

  7. Recieve response from creditor.

    • Templates:
      • Acceptance: Body: Dear customer, we accept your offer.
      • Rejection: Body: Dear customer, you can't negotiate this debt.
  8. You will get a summary of the performance of negotiation (changes on payment or changes on conditions of the debt).

Screenshots

The Real-Time Dashboard: A clean overview of all active and settled negotiations, built with shadcn/ui.
Real-Time Dashboard

Timeline & AI Response: The generated negotiation text and a timeline of events.
Timeline & AI Response

Code Repository

The complete source code is available on GitHub. Explore the magic behind the curtain!

https://github.com/FranP-code/inbox-negotiator

How I Built It

This project is fully serverless, relying on a modern stack to create a seamless, event-driven workflow.

Tech Stack:

  • Framework: Astro (using Astro endpoints for the full-stack API)
  • Email Processing: Postmark Inbound Webhooks
  • Database & Backend: Supabase (PostgreSQL, Edge Functions for AI, Realtime)
  • UI: shadcn/ui + HeroUI for a modern, responsive interface.
  • AI: Gemini's API (called from a Supabase Edge Function)

Of course! Here is a concise and credible "Implementation Journey" section based on your final post. It highlights the key technical decisions and the flow of data through the system.


The Implementation Journey

The entire architecture is an event-driven workflow designed for a fast, responsive user experience. Here's how it operates from start to finish:

  1. The Entry Point: Postmark Webhook
    The process kicks off the moment an email lands at the user's unique Postmark inbound address. Postmark instantly parses the email and fires a webhook, sending a clean JSON payload to my Astro API route at /api/postmark.

  2. The API Handler: Astro & Supabase
    This serverless Astro endpoint is the central receiver. It validates the incoming JSON, extracts key data—creditor, debt amount, and the email body—and inserts it into a debts table in my Supabase database. This action is fast, ensuring Postmark gets a quick 200 OK response.

  3. The AI Brain: Supabase Edge Function & Gemini
    The new row in the debts table automatically triggers a Supabase Edge Function via a database webhook. This asynchronous approach prevents blocking the API route. The Edge Function constructs a detailed, context-aware prompt using the debt information and calls the Gemini API to generate a legally-aware, FDCPA-compliant negotiation draft.

  4. The Real-Time UI: Astro & Supabase Subscriptions
    Once Gemini returns its response, the Edge Function updates the debts record with the AI-generated text and changes its status. On the frontend, the Astro app uses the Supabase JS client to subscribe to real-time changes in the database. The moment the record is updated, the dashboard seamlessly displays the new AI draft, ready for the user to review, edit, and send.

  5. Closing the Loop: Handling Responses
    The process works in reverse, too. When a creditor replies, their email is also caught by the Postmark webhook. A separate function parses the response for keywords (like "accept," "agree," or "offer") to automatically update the negotiation's status and summarize the outcome for the user on their dashboard.

My Experience with Postmark

Postmark was the absolute cornerstone of this project. The Inbound Parsing feature is a game-changer. It transformed the messy, unstructured world of email into a predictable, developer-friendly JSON payload.

The setup was incredibly straightforward, and the webhook reliability meant I could build my entire application logic on the assumption that I'd receive clean, structured data every time. Without Postmark, this project would have been exponentially more complex.

It's a truly powerful tool for any developer looking to build applications on top of email.

Last words

Thank you for checking out my project!
Made with ❤️ by Francisco Pessano from 🇦🇷

Top comments (0)