The Alex Pizza Assistant drives every conversation through a linear sequence of named steps defined in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/alex-pizza-assistant/llms.txt
Use this file to discover all available pages before exploring further.
steps[] array inside app.js. The app starts at index 0 and advances one step at a time via advanceStep(), but it is not purely sequential — three branching points exist: the addAnother loop that sends the user back to size for a second pizza, the paymentMethod fork that routes cash orders directly to completion, and the cardCvv fork that only asks for a tip on delivery orders. Understanding this array is the foundation for understanding everything else in the app.
The Steps Array
The following array is defined at the top ofapp.js and contains every question the chatbot will ever ask, along with its validator and error message.
Step Sequence
The logical path through the steps, including all branch points, is shown below.size → toppings → crustType → quantity
The four pizza-building questions run in sequence. When
quantity is answered, addCurrentPizzaToOrder() pushes the completed pizza into order.pizzas[] and the bot confirms what was added.addAnother (branch)
Yes —
order.currentPizza is reset to a blank pizza and currentStep jumps back to size. The pizza-building loop repeats.No — currentStep advances to method.method
The customer chooses carry out or delivery. This choice is recorded once and applies to every pizza already in the order.
paymentMethod (branch)
Card — advances to
cardNumber.Cash — the bot shows the appropriate pickup or delivery message and finishOrder() is called immediately. Card steps are skipped entirely.cardNumber → cardExpiration → cardCvv
The three card fields are collected in sequence. After
cardCvv, the bot displays a simulated approval using the last four digits of the card number.tip (delivery + card only)
Only reached when
order.method === "delivery" after cardCvv. For carry out card orders, finishOrder() is called right after cardCvv.The order method (
carry out or delivery) is chosen a single time — after all pizzas have been added — and it applies uniformly to every pizza in the order. There is no per-pizza delivery option.State Object
All data collected during a session lives in theorder object. It is declared at the top of app.js and mutated in place throughout the conversation.
Branching Logic
TheadvanceStep() function is the sole place where currentStep is mutated. It reads the step id and the normalized value to decide which step to jump to next.
yes (or y), currentPizza is wiped clean and the step pointer rewinds to size. This can repeat as many times as the customer wants.
Cash vs card branch — when paymentMethod normalizes to "cash", no card fields are ever shown. finishOrder() fires immediately, skipping cardNumber, cardExpiration, cardCvv, and tip.
Delivery tip branch — after cardCvv, the app checks order.method. Only a "delivery" order proceeds to tip; a carry out card order ends at CVV.
Completion
finishOrder() is called from three places in advanceStep(): after paymentMethod (cash), after cardCvv (carry out + card), and after tip (delivery + card).
finishOrder() performs these actions in order:
- Calls
calculateTotals()one final time to ensure the receipt is up to date. - Adds a thank-you bubble with the customer name and a result bubble showing the grand total.
- For card orders, adds a simulated “payment processed” confirmation.
- Coupon check — if
order.total >= 50, the customer is awarded a$10 offcoupon message; otherwise, the app displays a reminder that the threshold has not been reached. - Calls
runFastEta(), which usessetTimeoutto inject a series of ETA countdown bubbles at 450 ms intervals, ending with either “Your driver is on the way!” (delivery) or “Order is ready for pickup!” (carry out). - Disables the input and submit button, locking the chat for the completed session.