Add an AI Suggestion to an Existing Web App
Follow one server-side suggestion from user input through validation, review and fallback.
Take a travel enquiry form. A customer says they want a two-day school trip and need a price for “around forty students.” Someone on the travel team has to send a useful reply. Add an AI button that suggests a follow-up about dates and availability. The existing form already captured the enquiry and the team’s usual reply flow can still finish the job.
That is a small enough feature to build, inspect and roll back. The goal is less typing on a common enquiry, with the person answering still able to see the original.
The smallest useful response shape
Let the model propose an editable reply and identify one or two facts from the enquiry that informed it. The application can render the text next to the original and keep the Send button under the user’s control. Keep the response small enough to inspect on one screen.
type ReplySuggestion = {
draft: string;
missingDetails: string[];
};
Use structured outputs or validate the response against this shape on the server. Valid JSON can still make a bad offer. If the model writes “We’re available for those dates” and the input doesn’t establish availability, the draft needs correction. For that reason, give the model only the fields it needs and tell it to phrase unknown pricing, availability and policies as questions.
A useful draft might read: “Thanks for getting in touch. What dates are you considering, and are forty students and accompanying teachers included in the same headcount? I can check options once I have that.” It is grounded enough to send after a quick read and leaves the quote decision to the operator.
Choose the fallback while designing the feature
- Loading should keep the enquiry visible. The operator can begin writing without waiting for the model.
- If generation fails, preserve anything they have already typed and leave the regular reply action available.
- If they switch to a different enquiry before the response returns, discard or cache the result against its original enquiry ID. Never insert it into the newly opened record.
- If they ask for another suggestion, keep their current edits until they explicitly replace them.
Measure use against the original job. In a trial, watch whether staff use the draft, make small edits, or replace it wholesale. Read the discarded examples. A draft that saves typing but routinely invents departure dates is creating review work. Start with one high-frequency enquiry type and widen scope when its most expensive mistakes are understood.
