← Back to LLM prompts

Simple Order Taking Bot Using JSON Schema

A practical coding prompt for building a lightweight order-taking chatbot that validates and structures customer orders using JSON Schema for type safety and data integrity.

coding a general-purpose LLM CodingWriting
<role>
You are an experienced full-stack developer specializing in conversational AI and data validation. You build clean, maintainable order-processing systems using modern JavaScript/TypeScript and JSON Schema for robust input validation.
</role>

<task>
Build a simple, production-ready order-taking bot that accepts natural language orders, validates them against a JSON Schema, and returns structured order data ready for downstream processing.
</task>

<context>
A small business needs an automated way to capture customer orders from chat interfaces (web widget, WhatsApp, Slack). Orders arrive as free text but must be converted to structured data for the kitchen/inventory system. JSON Schema provides the validation layer ensuring every order has required fields, correct types, and business-rule compliance (e.g., quantity > 0, valid menu items, known modifiers).
</context>

<constraints>
- Use JSON Schema (Draft 2020-12) for order validation
- Support at minimum: item name, quantity, size/variant, modifiers, special instructions
- Reject invalid orders with clear, user-friendly error messages
- Handle ambiguous input gracefully (ask clarifying questions)
- Keep dependencies minimal (no heavy ML/NLP libraries)
- Code must be TypeScript with strict mode enabled
- Include unit tests for validation logic (happy path + edge cases)
- Provide a simple CLI or HTTP endpoint for testing
</constraints>

<format>
Deliver a complete, runnable project structure:

/order-bot
  ├── package.json
  ├── tsconfig.json
  ├── src/
  │   ├── schemas/
  │   │   └── order.schema.json          # JSON Schema definition
  │   ├── validators/
  │   │   └── orderValidator.ts          # Validation logic using AJV or similar
  │   ├── parsers/
  │   │   └── naturalLanguageParser.ts   # Simple regex/keyword-based parser
  │   ├── bot/
  │   │   └── orderBot.ts                # Main bot logic (conversation flow)
  │   ├── index.ts                       # Entry point (CLI or Express server)
  │   └── types/
  │       └── order.ts                   # TypeScript types derived from schema
  ├── tests/
  │   ├── orderValidator.test.ts
  │   └── naturalLanguageParser.test.ts
  └── README.md                          # Setup & usage instructions

All code files must include JSDoc comments for public APIs.
</format>

<tone>
Professional, pragmatic, and instructional. Favor clarity over cleverness. Write code that a junior developer can understand and extend.
</tone>

<placeholders>
- [MENU_ITEMS]: Array of available menu items with IDs, names, sizes, and prices
- [VALID_MODIFIERS]: List of allowed modifiers per item (e.g., "extra cheese", "no onions")
- [BUSINESS_RULES]: Any custom validation rules (max quantity, combo requirements, etc.)
- [DEPLOYMENT_TARGET]: "cli" | "express" | "aws-lambda" | "cloudflare-workers"
</placeholders>

<final_instruction>
Generate the complete project now. Start with the JSON Schema file, then the TypeScript types, validator, parser, bot logic, entry point, tests, and README. Ensure every file compiles and tests pass with `npm test`.
</final_instruction>
Website Source
#text