Glossary
›
State machine

State machine

Glossary
Also known as:
Finite-state machine (FSM), finite-state automaton, statechart

What is a state machine?

A state machine is a model of a process as a fixed set of states, such as submitted, under review or approved, together with the events that move it from one state to another and the rules that decide whether a move is allowed. At any moment the process is in exactly one state, with only that state's moves available.

The idea comes from computer science, where it is formally called a finite-state machine, and it is everywhere once noticed: a traffic light, a parcel that moves from ordered to shipped to delivered, a loan application that moves from started to decided to funded. Its value lies in what it rules out. If a state machine has no path from declined to funded, no amount of clever input can produce one.

How a state machine works

Every state machine is built from five parts. The examples follow a simple account-opening process.

The five parts of a state machine, in an account-opening process
Part What it is Example
State A distinct situation the process can be in Identity not yet verified
Event Something that happens and may trigger a move The customer uploads a driving license
Transition A permitted move from one state to another From not verified to verified
Guard A condition that must be true for the move to happen The document check passed and the name matches
Action Work done when a move happens Record the check and send a confirmation

When an event arrives, the machine looks up the transitions available from its current state, tests their guards and takes the one that passes. Anything else is rejected or routed to a defined exception state. Large processes quickly produce many states, so designers often use statecharts, an extension that nests states inside other states and lets several parts of a process run side by side without listing every combination.

Why state machines matter

Modeling behavior as states and transitions catches problems that testing misses. Engineers at Amazon Web Services reported in Communications of the ACM that they had used TLA+, a language for specifying systems as states and the steps between them, on 10 large, complex systems, and that in each it added significant value, including finding subtle bugs. In one database system, the shortest sequence of events that exposed a bug was 35 high-level steps long.

The same discipline applies to business processes. Writing a process down as states and transitions forces questions that prose documents let slide: what happens if the customer stops halfway, which steps can be skipped, which must happen before money moves. The answers become part of the design rather than surprises found in production or in an audit.

Where state machines are used

  • Order and case lifecycles. Orders, claims, disputes and support tickets that move through defined statuses.
  • Applications and onboarding. Loan, insurance and account applications that must complete steps in a set order.
  • Phone menus and conversation flows. Each menu or conversation step is a state, and each answer a transition.
  • Software and devices. Network protocols, user interfaces, payment terminals and embedded controllers.
  • Workflow and approval systems. Documents that pass from draft to review to approval with role-based guards.

A state machine is a poor fit for work that has no meaningful stages, such as answering a one-off question, or for creative tasks where the path is meant to be open. Forcing structure onto those produces a long list of states that adds nothing.

What a good state machine looks like

  • Every state named for what it means. "Awaiting income document" rather than "step 4".
  • Complete transitions. Each state defines what happens for every expected event, including timeouts and cancellations.
  • An exception path. Unexpected events lead to a defined state, often a handover to a person, rather than a crash or a silent stall.
  • Guards that carry the rules. Business and regulatory conditions are written as guards, so they are checked every time.
  • A diagram that matches the code. The picture reviewers approve is generated from, or verified against, what actually runs.
  • A log of every move. Each transition records the state before and after, the event and the time.

How to measure a state machine

  • Completion rate. The share of instances that reach a successful end state.
  • Time in state. How long instances wait in each state, which shows where work stalls.
  • Exception rate. How often unexpected events send an instance to the exception path.
  • Path coverage in testing. The share of possible transitions exercised by the test suite.
  • Abandonment by state. Where customers drop out, located to the exact state rather than "somewhere in the middle".

Rules that a state machine can enforce in the United States

Many regulations are, in effect, rules about order and timing, which makes them natural guards and deadlines in a state machine. A few US examples follow, drawn from banking because its timing rules are the most explicit; the same pattern applies to cancellation windows in subscriptions, cooling-off periods in sales and response deadlines in insurance claims.

  • Disclosure deadlines. For most mortgage applications, Regulation Z requires the Loan Estimate to be delivered or mailed within three business days of receiving the application, and the Closing Disclosure to be received at least three business days before closing. Each is a natural timer on a state.
  • Verification after account opening. Banks' customer identification rules require identity to be verified within a reasonable time after an account is opened. A state machine can enforce that as a deadline on the state between opened and verified.
  • Calling hours. Federal telemarketing rules bar telephone solicitations before 8 a.m. or after 9 p.m. at the called person's location, a guard on every outbound call transition.

Frequently asked questions

What is the difference between a state machine and a flowchart? A flowchart describes a sequence of steps, often informally. A state machine defines states and the only moves allowed between them, precisely enough to run and test.

What is a finite-state machine? The formal name for a state machine with a limited, known set of states. Almost all state machines used in business software are finite.

What is a statechart? An extension of the state machine, introduced in 1987, that allows states inside states and parts of a process running in parallel. It keeps large models readable.

Is an executable flow graph a state machine? It is built on the same idea. An executable flow graph models a conversation as states, decision points and allowed transitions, and adds the data to capture and the constraints to respect at each step.

Can a state machine work with a language model? Yes. A common design lets the language model interpret what a person said and phrase replies, while the state machine decides which step comes next and what is allowed.

‍

Structure where it counts, conversation everywhere else.

Encore's AI agents run each customer journey through a reviewable structure compiled from how your top performers win, so required steps happen in order and every move is logged. Run them on voice, chat, SMS, WhatsApp, email, IVR, IVA or agentic landing pages, with Wingman assisting your team or Autopilot taking whole journeys. Programs built this way have sustained 30% lead conversion at $250K in monthly lead value, go live in weeks and run on an engine protected by two granted patents. Scale your best to be the best.

Scale your best to be the best.

Book a Demo