About this project
InboxPilot — portfolio project by Uriel Papa
The problem
Small businesses like a café-caterer get a steady stream of messages across email, Facebook and web forms: catering quotes, bookings, complaints, refund demands and spam. The owner answers them between shifts, so replies are slow, inconsistent and occasionally promise things (refunds, discounts, full slots) the business can't deliver. Every slow or wrong reply costs a booking or a customer.
The approach
An AI agent triages each message: it classifies intent, priority and sentiment, then drafts a reply grounded only in the knowledge base and a live availability table. It uses tool calling (search_knowledge_base, check_availability, propose_booking, propose_ticket, flag_spam) and returns structured output. Actions are only proposed — a human approves, edits or rejects every reply and action in a queue, and every step is written to an audit log. Guardrails block refunds, discounts or slots not backed by data, and spam gets no reply.
Architecture
React (TanStack Start) UI │ server functions (run on the server, service role) ▼ Server functions ──► Lovable AI (model calls server-side only) │ ▼ Lovable Cloud database RLS enabled on all 7 tables, no direct anon access: messages · proposed_actions · knowledge_base · availability bookings · tickets · audit_log
Server functions
- triageMessage → runAgent tool loop (search_knowledge_base, check_availability, propose_booking, propose_ticket, flag_spam, submit_triage)
- approveMessage · rejectMessage · saveDraft · simulateMessage
- resetDemo · ensureFreshDemo (re-seeds after 24h idle, tops up the 14-day availability)
- upsertKb / deleteKb
- read functions: getMessages, getMessage, getKb, getAvailability, getRecords, getAudit
Public webhook route (the "inbound-message" edge-style function): POST /api/public/inbound-message
Inbound webhook
New messages can be posted from any form or integration. Fields are validated; bodies over 5,000 characters are rejected.
https://your-app.lovable.app/api/public/inbound-message
curl example
curl -X POST https://your-app.lovable.app/api/public/inbound-message \
-H "Content-Type: application/json" \
-d '{"sender_name":"Jamie Test","sender_email":"jamie@example.com","channel":"Website form","subject":"Catering for 40?","body":"Hi! Do you cater Premium for 40 people in BGC?"}'What I'd do next in a real deployment
- Connect real channels (Gmail, Messenger, form provider) with signed webhooks and real sending after approval.
- Staff login with roles, SLAs and assignment; auto-approve only high-confidence, low-risk intents.
- Semantic search over a larger knowledge base, plus eval sets per intent to track accuracy and regressions.
- Booking system sync, PII redaction in logs, and rate limiting on the public webhook.