In this video, Amara asked the booking assistant to move booking LF-2417 to Sunday morning’s LF103 sailing and add her brother. With the previous lesson’s code, the change ran the moment the model asked for it. Now your code stops at the change, shows her exactly what will change, and runs it only after she types yes.
Key Points
- A change shouldn’t run before the passenger sees it. The model’s arguments are its reading of the passenger’s message. Even when your checks pass, a misreading, such as four passengers instead of three, would change the booking as quickly as a correct one.
- The pause belongs in your code, not the prompt. Instructions that tell the model to ask first are text the model reads. The model would write the question and judge the answer, and your code couldn’t tell whether a yes ever came.
- Check first, then ask, then check again. A new
planChange()holds the checks, and bothdescribeChange()andchangeBooking()call it. A change the data can’t allow comes back as an error result before the passenger is asked anything. Moving LF-2417 to an earlier sailing (LF101) with a car, for example, returnsNo vehicle spaces left on LF101.After the yes,changeBooking()runs the checks again, because the data can change while the passenger decides. - Describe the change from the call’s own arguments.
describeChange()builds the description from the arguments your code will run and the booking data, so what the passenger approves is exactly what runs:
Change booking LF-2417:
sailing: LF102, 2026-12-05 14:30 → LF103, 2026-12-06 08:00
passengers: 2 → 3
- Wait for a yes. This script’s
confirm()uses Node’sreadlinemodule to print the description and wait for a typed line at the terminal. In a web app, the server would keep the held call, the chat would show a yes and a no, and a yes would run that exact call, not a new one from the model. - Anything but a yes goes back as an error result. If the answer isn’t yes, the code throws inside the
tryblock, so yourcatchblock sendsThe passenger didn't confirm. Nothing changed.back as the call’s error result, with its ID. It’s marked as an error because the call didn’t do what the model asked. Every call still gets a result. - A yes in the chat doesn’t get around the gate. In this run, the model told Amara her booking was still on LF102 for two passengers and asked whether to move it. If she answers yes in the chat, the model makes a new
changeBooking()call, which meets the gate again. Your own runs will word their answers differently.