From Assessment to Personal Plan: Generating a Structured Plan With AI and Following Up by SMS
An assessment that ends in a personalised plan is a strong offer for coaches and educators. The hard parts are what happens when the model's plan is well-formed but wrong, and which follow-up messages you're actually allowed to send. A template, validation layers, a fallback path and a proposed message table.


Text equivalent. AI assessments Teaching diagram • Validation before follow-up Answers No name / phone Model Provider-neutral Parse Size / empty / truncation Schema Structure only Business rules + review flag Schema-valid does not mean correct Bounded retry > human review Parse/schema/model failure: capped attempts Rule fail or model review flag: direct review Fail Human decision Approve · edit + revalidate · manual plan Unresolved > named owner Queue a reviewed plan Private expiring link · dedup ID Pass Approved PROPOSED SMS / M1 > M2 > M3 Every send: verify consent basis + suppression + dedup. No automatic marketing permission. Synthetic plan and proposed orchestration • no executed end-to-end SMS pipeline
For a coach, tutor or teacher, "answer a few questions and get your personal plan" is an appealing first step to offer. The visitor can receive a plan shaped around their answers, and the business gets a warm lead with context. Language models make the plan part look easy.
The engineering is in the parts around the model: what shape the plan must take, how you catch a plan that looks fine but is wrong, what the visitor sees when generation fails, and which follow-up messages you are allowed to send. This article works through those parts with a synthetic weekly practice plan for a music student.
It covers turning answers into a plan. Routing an enquiry to the right service is a different job, with different risks, and isn't covered here.
Step 1: define the plan template before writing a prompt
Start with the document you want the student to receive, not with the prompt. Write the plan by hand for three made-up students: a beginner, someone returning after a break, and an intermediate player. Then extract the parts that stay the same:
- a level the plan is written for;
- total practice minutes per week;
- one to three focus areas;
- the practice days, each with minutes and a few concrete activities;
- whether a human should look at it before it is sent, and why.
That becomes a JSON Schema. Example (synthetic template):
This is a provider-neutral application-validation schema, checked locally with Ajv. It has not been submitted to Gemini or any other model API; provider acceptance and generation behaviour are untested.
{
"type": "object",
"properties": {
"template_version": { "type": "string", "enum": ["weekly-practice-plan/v1"] },
"level": { "type": "string", "enum": ["beginner", "returning", "intermediate"] },
"weekly_minutes": { "type": "integer", "minimum": 30, "maximum": 600 },
"focus_areas": {
"type": "array",
"items": { "type": "string", "enum": ["technique", "reading", "repertoire", "ear_training", "theory"] },
"minItems": 1,
"maxItems": 3
},
"days": {
"type": "array",
"minItems": 1,
"maxItems": 7,
"items": {
"type": "object",
"properties": {
"day": { "type": "string", "enum": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] },
"minutes": { "type": "integer", "minimum": 5, "maximum": 120 },
"activities": {
"type": "array",
"minItems": 1,
"maxItems": 4,
"items": {
"type": "object",
"properties": {
"focus": { "type": "string", "enum": ["technique", "reading", "repertoire", "ear_training", "theory"] },
"minutes": { "type": "integer", "minimum": 5, "maximum": 60 },
"instruction": { "type": "string" }
},
"required": ["focus", "minutes", "instruction"],
"additionalProperties": false
}
}
},
"required": ["day", "minutes", "activities"],
"additionalProperties": false
}
},
"needs_human_review": { "type": "boolean" },
"review_reason": { "type": ["string", "null"] }
},
"required": ["template_version", "level", "weekly_minutes", "focus_areas", "days", "needs_human_review", "review_reason"],
"additionalProperties": false
}Design notes:
- Closed lists (
enum) for anything you'll act on. Levels, focus areas and days are enums, so downstream code and the review screen never see unexpected values. - Free text only where a human reads it.
instructionandreview_reasonare the open strings. JSON Schema can bound their length, but some providers ignore length keywords during generation (see step 2), so the example enforces length, blank-text and consistency rules in application code (step 3). template_versionis in the output, so you know which template produced a stored plan after you change it.needs_human_reviewandreview_reasonlet the model flag uncertainty. Your own rules decide the routing, though (see step 3); the model's flag is one input among several.
How many assessment questions?
As many as the plan needs, and no more. Each question should change something in the plan. Treat any specific count, whether five, six or eight steps, as a design choice to test with real users, not a rule. The assessment is a multi-step form, so W3C's forms guidance applies: label every control, group related ones, show progress and only ask for what you need (W3C WAI: Forms tutorial).
Step 2: constrain the model's output to the template
Several model APIs can be asked to return JSON that follows a schema. Google's Gemini documentation, for example, says Gemini models can be configured "to generate responses that adhere to a provided JSON Schema" (Gemini API: Structured outputs). The same page sets out limits that matter for a template like this one (as read on 2026-11-07):
- Only a subset of JSON Schema is supported.
- Some keywords are not enforced during generation.
minLength,maxLength,minProperties,maxProperties,uniqueItems,contains,minContainsandmaxContainsare stripped and ignored, whileminItemsandmaxItemsare enforced. - Very large or deeply nested schemas may be rejected with a
400 INVALID_ARGUMENTerror. - In its best practices, the page says: "While output is syntactically correct JSON, always validate values in your application," and recommends error handling "for schema-compliant but semantically incorrect outputs."
That last point is what this article is about. A schema makes the plan well-formed. It does not make the plan correct. A plan can match every type and enum and still give a beginner two hours a day of fast scales.
The template above sticks to enums, required fields, item-count bounds and integer ranges, and leaves everything else to application checks. Avoiding the keywords the page lists as ignored doesn't guarantee a provider will accept the schema: whether Gemini accepts this exact nested schema wasn't tested for this article. Other providers have their own subsets and limits, so test against your provider's current API rather than assuming.
Step 3: validate in layers
Run separate checks on every plan, whatever the provider promises.
Layer 0 — parse safely. Before any schema check, treat the raw response as untrusted text. An empty response, a refusal, a response cut off mid-JSON or an oversized answer should fail cleanly at this step, with a size limit applied before parsing.
Layer 1 — schema validation in your code. Validate the returned JSON against the same schema with a standard validator. This catches anything the provider didn't enforce, a changed or misconfigured schema, and responses from a different model or provider.
Layer 2 — business and text rules. For the practice plan, the example rules are:
| Rule (example) | Why we check this in application code |
|---|---|
Day minutes add up to weekly_minutes | Cross-field arithmetic, which standard JSON Schema doesn't express |
| Each day's activity minutes add up to that day's minutes | Cross-field arithmetic |
| No day appears twice | uniqueItems wouldn't compare a nested field, and the Gemini page lists it as ignored during generation |
Every activity's focus is one of the plan's focus_areas | Cross-field reference |
| A beginner day is at most 45 minutes | Full JSON Schema can express this with conditionals (if/then), but a provider's supported subset may not, and the limit is a teaching decision that changes (the 45 is an example) |
| Instructions are non-blank, at most 280 characters, and contain no links or markup | Length keywords may be ignored during generation, and "no links" is a policy rule |
review_reason is present when review is requested, and empty otherwise | Cross-field consistency |
Treat every string the model returns as untrusted: escape it when rendering HTML or SMS, never execute it, and don't turn it into links or commands without validation.
Here is a plan that passes the schema and fails the rules. Example (synthetic):
{
"template_version": "weekly-practice-plan/v1",
"level": "beginner",
"weekly_minutes": 60,
"focus_areas": ["technique"],
"days": [
{ "day": "mon", "minutes": 120, "activities": [
{ "focus": "technique", "minutes": 60, "instruction": "Fast scales at maximum tempo." },
{ "focus": "technique", "minutes": 60, "instruction": "Repeat until perfect." } ] }
],
"needs_human_review": false,
"review_reason": null
}In a local test with Ajv 8.20.0 (a JSON Schema validator for JavaScript) on Node.js 24.22.1, this plan passed schema validation. The business-rule check then reported "day minutes sum to 120, weekly_minutes is 60" and "beginner day longer than 45 min". A schema-only pipeline would have sent it.
And here is output that fails the schema itself. Example (synthetic):
{
"template_version": "weekly-practice-plan/v1",
"level": "advanced",
"weekly_minutes": 90,
"focus_areas": ["technique", "sight_reading"],
"days": [ { "day": "monday", "minutes": 30, "activities": [] } ],
"needs_human_review": false
}In the same test, the validator reported a missing review_reason, a level outside the allowed list, an unknown focus area (sight_reading), an invalid day name and an empty activities list. A provider that enforces your schema during generation should make output like this less likely. The check costs almost nothing, and it protects you when the provider, model or schema changes.
The same local test also covered an empty response, a truncated one, a review request without a reason, and a plan with a blank instruction and a link in another. Each failed at the expected layer. These are checks of the application code with hand-written samples. No model was called, so they say nothing about how often a given model produces each failure.
Step 4: decide what happens when the plan is invalid
This is the part most demos leave out. Proposed fallback path:
| Situation | Action | What the visitor sees |
|---|---|---|
| Parses, schema-valid, rules pass, model didn't flag review | Queue for sending (step 5) | Their plan |
| Empty, refused, truncated, oversized or non-JSON response | Retry within a fixed budget (the example allows 2 attempts in total; also cap the total time), then human review | "We're preparing your plan. You'll receive it by [channel] once it has been reviewed." |
| Schema-invalid | Same as above: bounded retry, then human review | Same message |
| Schema-valid but a business or text rule fails | Human review. Don't retry blindly, because the same answers may keep producing the same problem | Same message |
needs_human_review is true | Human review, with the model's review_reason shown to the reviewer | Same message |
| Model call fails or times out | Bounded retry with backoff, then human review. Alert someone if failures persist | Same message, never an error page that loses their answers |
| Human review queue isn't cleared | Escalate to a named person. The terminal state is a reviewed plan, a manually written plan or an honest "we couldn't prepare this" message, never silence | A follow-up from a person |
These controls reduce risk. They don't establish educational quality: a plan can pass every rule and still be poor advice. Review a sample of passing plans as well as failing ones, and judge the teaching content, not just the JSON.
Two rules for the failure path:
- Never send a partial or "best effort" plan when validation fails. Sending nothing until a human has looked is better than sending something wrong under your name.
- Keep the assessment answers whatever happens. Store the answers the plan needs before calling the model, securely and with a retention limit, so a failure never means asking the visitor to start again.
The human review screen should show the visitor's answers, the raw model output, the validation errors and the template version. The reviewer needs three actions: approve, edit and approve, or reject and write the plan manually. Re-run the schema and rule checks on any edited or hand-written plan before it's sent. Log who did what, so you can later see which rules fail most and improve the template or prompt.
Don't promise turnaround times on that screen or in the message unless someone is actually staffed to meet them.
Keep personal data out of the prompt
The model needs the assessment answers. It does not need the visitor's name or phone number. Send only what the plan requires, and join the plan to the contact record after generation, in your own system. Free-text answers can contain personal details even after you remove the name and phone fields, so apply the same care to them. If students may be children, check what guardian consent and privacy rules apply before collecting phone numbers or sending messages.
Step 5: follow up by SMS, with consent decided per message
Following up by SMS can be useful, but whether a message is allowed, and what consent it needs, depends on the country, the type of message and your SMS provider's rules. Nothing below is legal advice. Check the rules that apply to you with your provider and, where needed, a lawyer.
A useful working distinction:
- Transactional (service) messages relate to something the person asked for, such as "your plan is ready".
- Marketing messages promote a product or service, such as "book a trial lesson this week".
These labels are illustrative. Whether a message counts as promotional isn't decided only by whether the person asked for something.
Where the line falls, and what consent each type needs, varies by jurisdiction. Treat the classifications below as questions to verify, not answers.
Proposed message sequence (synthetic, not a client's actual sequence):
| # | Trigger | Message purpose | Likely type (verify) | Consent basis to verify | Notes |
|---|---|---|---|---|---|
| M1 | Plan approved and sent | "Your practice plan is ready: [link]" | Transactional | The visitor asked for the plan and gave their number for it | Send once, and only after approval |
| M2 | 3 days after M1 | Check-in: "How did the first sessions go? Reply with any question." | Unclear; may count as marketing in some places | Possibly needs separate opt-in | Only if the visitor ticked "send me practice check-ins" |
| M3 | 7 days after M1 | Offer a lesson or consultation | Marketing | Explicit marketing consent where required | Don't send without a recorded opt-in |
| — | Any reply such as STOP, or an opt-out by any channel | Stop all non-essential messages | — | — | Opt-out keywords, and whether a confirmation message is permitted or required, depend on provider and country |
Implementation details that keep this honest:
- Separate the checkboxes. Getting the plan by SMS and receiving marketing messages are different permissions. Don't pre-tick the marketing one. (A common good practice; your jurisdiction may require it.)
- Record consent as data: phone number, the exact wording shown, which boxes were ticked, timestamp and source page. You'll need it if anyone asks.
- Check consent and your suppression list at send time, not only at signup, so an opt-out stops queued messages.
- Deduplicate sends with a message ID per person and trigger, so a retry never sends M1 twice.
- Keep the plan link private: an unguessable, expiring link, or one that requires the recipient to confirm who they are. Don't put assessment details in the SMS text or the URL.
- Respect local time. Schedule by the recipient's time zone and avoid unsociable hours. Some places regulate this.
- Make every message identify the sender and say how to stop.
Figure (teaching diagram, to be produced): Answers (stored) → model → parse → schema check → business/text rules → model review flag → queue for send. Failure branches: parse/schema failure → bounded retry → human review; rule failure or needs_human_review=true → human review; model error/timeout → bounded retry → human review; review → approve / edit (re-validate) / manual plan / escalation. Below: a proposed SMS timeline M1–M3, each with a consent + suppression check at send time.A worked context from this portfolio
The Siamak Sanei case study describes a site for a piano instructor in which a Gemini-based assessment returns a weekly practice plan, with phone capture and automated SMS. That is the kind of system this article discusses. The case file doesn't document the actual assessment questions, plan template, validation, review process or SMS sequence, and none of the examples above describe them. They are synthetic, written for this article.
Checklist
- The plan template is defined (with a version) before the prompt.
- The schema has been tested against your provider's API, and anything the provider doesn't enforce is checked in code.
- Every plan is parsed safely and passes schema validation and business/text rules before it is sent, including plans edited by a reviewer.
- Invalid output leads to a bounded retry or human review, never a partial plan, and the review queue has a named owner.
- Assessment answers are stored before generation, and personal data stays out of the prompt.
- Reviewers can approve, edit or reject, and every action is logged.
- Each SMS message has a classification, a consent basis and an opt-out path, all verified for your jurisdiction and provider.
- Consent and suppression are recorded and checked at send time, and sends are deduplicated.
Designing an assessment like this?
If you're planning an assessment-to-plan flow with AI generation, review and messaging, see AI systems and automation.
Sources
- Google AI for Developers, Gemini API: Structured outputs (read 2026-11-07; the URL redirects to aistudio.google.com/docs/structured-output): https://ai.google.dev/gemini-api/docs/structured-output
- W3C WAI, Forms tutorial: https://www.w3.org/WAI/tutorials/forms/
What could this change for you?
Tell me what you’re building — I’ll tell you honestly where I’d start.
Start a project with me