Modelling Quote Follow-Up as a State Machine: Notes on Building AI for Trades

2026-11-28来源 dev.toEnglish

Modelling Quote Follow-Up as a State Machine: Notes on Building AI for Trades

If you're building software for tradespeople, quote follow-up looks trivial: send a reminder after N days. In practice it's a small state machine with awkward edges, and getting those edges wrong is how you annoy customers and embarrass the business you're working for. This post walks through a model that holds up, written from the perspective of ai for trades work where an LLM agent writes the messages but deterministic logic decides when and whether to send them.

The code is illustrative TypeScript, not anyone's production system.

Why not just a cron job?

A naive implementation looks like this:

if (daysSince(quote.sentAt) === 3 && !quote.accepted) sendReminder(quote); 

Problems appear quickly:

  • The customer replied by phone yesterday saying they'll decide on Friday. You chase anyway.
  • The quote was revised. Which version are you chasing?
  • The customer said they went with someone else. You keep sending reminders.
  • The tradie edited the price in their job software, and the agent is quoting stale numbers.

Every one of these is a state the cron job doesn't know about.

The states

type QuoteState = | 'sent' | 'awaiting_first_touch' | 'awaiting_second_touch' | 'awaiting_close_out' | 'customer_engaged' // replied with a question or a date | 'needs_human' // price, scope, complaint | 'won' | 'lost' | 'expired'; 

The key states are customer_engaged and needs_human. Most bad follow-up comes from collapsing them into 'not accepted yet'.

Transitions

type Event = | kind: 'timer_elapsed' | 'decline' | kind: 'quote_revised' | 'lost' ; function next(state: QuoteState, e: Event): QuoteState if (e.kind === 'status_changed_in_source') return e.status; if (e.kind === 'quote_revised') return 'awaiting_first_touch'; if (e.kind === 'reply') switch (e.intent) case 'accept': return 'won'; case 'decline': return 'lost'; case 'defer': return 'customer_engaged'; case 'question': return 'customer_engaged'; case 'price_or_scope': case 'complaint': return 'needs_human'; if (e.kind === 'timer_elapsed') switch (state) case 'sent': return 'awaiting_first_touch'; case 'awaiting_first_touch': return 'awaiting_second_touch'; case 'awaiting_second_touch': return 'awaiting_close_out'; case 'awaiting_close_out': return 'expired'; return state; 

Note the precedence: a status change in the source system beats everything. If the tradie marks the job as won in their job software, no clever inference should override that.

Design notes

The job software is the source of truth

Trades already run on tools like ServiceM8, Tradify, simPRO or Procore. The quote, its version and its status live there. Your follow-up engine should read from that, not keep its own copy that drifts. Any time you're about to send a message, re-read the current quote.

Let the LLM classify, not decide

The model is useful for two things: classifying an inbound reply into an intent, and drafting a message in the business's tone. It should not be the thing deciding whether a message goes out. Keep the transition function deterministic and testable.

Bias classification towards humans

When the classifier is unsure whether a reply is a simple question or a price objection, route it to needs_human. A slightly slower response to an ambiguous reply is far better than an agent improvising about price.

Respect deferrals

If a customer says 'we'll decide after the long weekend', store deferUntil and suppress timers until then. Few things feel more robotic than a reminder the day after you asked for space.

Business hours for outbound

Inbound answering can be 24/7, but outbound follow-ups should usually respect sensible hours for the customer.

Where this sits in a product

This is the shape of problem laikodev works on: AI agents for trade and construction businesses that answer calls, chase paperwork and follow up quotes 24/7, built around tools like ServiceM8, Tradify, simPRO and Procore. Paperwork chasing has a near-identical state machine, with documents in place of quotes.

Takeaway

The interesting engineering in ai for trades isn't the language model. It's the boring state handling around it that keeps the agent from chasing someone who already said yes.

More on laikodev at https://laiko.dev

原文:https://www.a8q9.cn/en/article/modelling-quote-follow-up-as-a-state-machine-notes-on-building-ai-for-trades-f15d4b.html

相关文章