Get your API key

Lesson 5 of 5

AI replies with limits

Answer free-text questions with AI grounded in the FAQ, keep orders and prices in code, cap daily use and spend, protect privacy, and test tricky messages.

8 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson your bot will answer free-text questions with AI, using only the business's own FAQ, while code still controls orders and prices, a daily cap and a spend limit protect your money, and private details stay out of the AI.

You need: the online bot from lesson 4, an AllModelAPI account with a new API key, your coding agent · Time: 8 minutes

  1. Customers don't always use buttons. They type "kal ka menu kya hai?", "do you deliver near the bus stand?" or "can I pay at month end?". Keywords from faq.txt miss many of these. A language model can understand the question and answer in the customer's own style.

    But a model also makes things up with confidence. So the bot gets a clear split:

    • Buttons and commands go to code: menu, orders, prices, totals, cancellations, reminders. Code reads the database; nothing is guessed.
    • Free text goes to the AI, which may only explain what is in the FAQ, and must send everything else to the owner.
    Flow diagram titled "Code decides. AI only explains." A new message goes up to "Code + database (no AI)" for buttons and commands: orders, prices, refunds, reminders. Free text goes along a lower path: 1 Checks (daily cap left? hide phone numbers), 2 AI + FAQ (FAQ only, max 300 tokens), 3 Reply (the answer, or "I'll ask Sharma ji"). A dashed box says AI never confirms prices, orders or refunds; if the API is down or the cap is reached, send a polite fallback message. Footer: one key just for the bot, with a spend limit
    Money and orders stay in code. The AI gets only free text, and only after the checks.
    Why?

    If the AI can say "yes, your order is confirmed" or "₹80 is fine", a customer will eventually get a promise the business never made. Keeping money and orders in code means the worst AI mistake is a clumsy sentence, not a lost tiffin.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Ground the AI in the FAQ
  2. Put limits on usage and money
  3. Keep private details out of the AI
  4. Test it with tricky messages
  5. Recap