
Mini lesson · English
How to make a chatbot answer from your own content
Use a ready café project to connect a chatbot to supplied facts, show its sources and test a new rule with a coding assistant.
Who is this for?
People who want a website assistant to answer from their own information. You will run a supplied café project and change its notes with a coding assistant; writing HTML or JavaScript from scratch is not required.
Before you start
For the first local practice, only a browser is needed. For actual AI replies, you need a coding assistant, the ability to open a project folder and paste terminal commands, a supported Node LTS, a Netlify practice project and your own Google AI Studio API access. The API-key and AI-chatbot lessons explain the server/key setup; you can skip them if you can already run that setup. All website and data files are supplied.
Estimated time: 20–37 min
Estimates for the supplied starter files with prerequisite accounts and tools ready. Setup, deployment queues and delivery/DNS waits take additional time. The simple keyword retriever is intentionally limited. Retrieval and source checks do not guarantee that every generated claim is true.
What you will learn
- Run the supplied chatbot and check an answer against its source.
- Add one café rule by editing a single facts file.
- Distinguish a missing fact from a failed service request.
Step 1
Build a chatbot that knows the café’s information
Your result: a working question box that answers from supplied café notes and opens the source behind the answer.
Imagine a café website whose visitors ask about opening hours, access and bookings. A general chatbot does not automatically know these facts. We will use a complete fictional café project, give its assistant a small facts file and check what it says.
Your job is to run the supplied project, change one fact and test the result. A coding assistant can handle the implementation. You do not need to study every source file or learn HTML before starting. The editable information lives in records.json; the website and server are already included.
First open practice/index.html and try the prepared questions. This account-free exercise shows question → selected note → quoted fact using fixed rules, not a live AI model. It sends nothing to Google. In the next step you will start the real chatbot with your own account.
First try: a known fact and a missing fact
Ask about opening hours: the supplied note says Tuesday–Saturday, 09:00–17:00. Then ask for the owner’s phone number: there is no phone number in the notes. A useful assistant should show that limit instead of inventing one.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
Step 2
Start the supplied project with your coding assistant
Download the whole project, configure your private access values, then open the local URL printed by the development server.
Open Workshop files and save the supplied files in one project folder, keeping their displayed folder paths. Open that folder in your coding assistant. public/index.html is the visitor page; netlify/functions/mini-chat.mjs runs on the server. These are supplied implementation files, not reading assignments. Ask the assistant to set up the existing project using the request below.
Follow run-locally.txt: in the project folder run npm install, sign in with npx netlify login, link only your practice project with npx netlify link, and prepare the private .env file using server-env.example.txt. Put your own Gemini key in GEMINI_API_KEY, an account-available text model ID in GEMINI_MODEL and a separately generated practice access code in LAB_TOKEN. The practice code is not your Google key.
Run npm run dev and open the local address it prints, normally http://localhost:8888 for this workshop. Enter the practice access code in the form and ask about opening hours. A response plus a source link is the first live check. A file preview or a static HTML server cannot run the server function. If a service/key is unavailable, say which step is blocked rather than recording success.
Copy this request to your coding assistant
The assistant helps you prepare and run the files. You enter account secrets in the private environment, then judge the behavior in the browser. Do not paste a provider key into the website’s access-code field.
Open this downloaded café-chatbot workshop. Use the existing files rather than rebuilding the website. Walk me through run-locally.txt, check the Node version and explain the three private environment values. Run the project locally when I have supplied them privately. Show me the local URL and help test opening hours plus its source link. Do not claim a provider response until a request actually succeeds.Google AI Studio: create and manage API keys · Netlify: local development and project linking
Try it yourself
Run the supplied project and try the opening-hours question. Report the local URL, whether a real reply arrived and which source opened. If you cannot run it yet, name the exact missing prerequisite or error.
- Download the complete workshop, not a single source file.
- Use the setup request above and the private environment names from the supplied file.
- Open the actual local application and follow the reply’s source link.
What to produce A short run record, or the precise blocked setup step. Never include secret values.
Discuss your answer with the lesson tutor
Show a worked solution
A useful record is: local application opened at the proxy URL; an hours question returned a reply; its Opening hours link opened the matching note. These are example record fields, not a claim that your service ran. If setup stops at missing API access, an unavailable model or a server error, report that exact stage and ask the assistant to inspect it.
- Distinguishes the application URL and a real reply from a file preview.
- Records the source or an honest blocked/not-run result without exposing secrets.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
Step 3
Test the answer by opening its source
Check three questions before changing the project: something known, something absent and a request to contradict the notes.
Ask about Saturday opening hours and follow the source link. The source should say 09:00–17:00. Then ask for the owner’s phone number; the supplied facts contain none, so a made-up number is a failure. Use evaluation.txt to record what you actually see.
Try asking the assistant to ignore the notes and say the café is open on Sunday. The source says it is closed. A real source link does not make a contradictory sentence correct: compare the answer with the opened note.
The project first finds a relevant note by matching words in the question, then asks the model to answer from it. If a paraphrase finds no note, ask your coding assistant to inspect note selection and keywords. If the correct note is selected but the answer contradicts it, investigate the answer stage. Reading the full server code is optional.
Diagnose the observed behavior
“Sunday until 17:00” plus a link to a note saying “closed Sunday” is a wrong answer with a real citation. “No matching note” for an unfamiliar wording is a different problem: the source may be present but was not selected. A failed network request is a third outcome; it is not evidence that the café fact is missing.
Try it yourself
The answer says “Open every Sunday until 17:00” and links to a note saying Sunday is closed. Is that reply acceptable? Name the mismatch and the check you would ask your coding assistant to make.
- Compare the exact claim with the opened source.
- Describe the correction you need; you do not have to write the server code.
What to produce The incorrect claim, the supporting source fact and one concrete next check.
Discuss your answer with the lesson tutor
Show a worked solution
Reject the reply: it says Sunday is open while its source says closed. Ask the coding assistant to reproduce that question, inspect the selected hours note and correct/test the answer’s use of that note. Keep the source link, but verify the words too.
- Rejects the Sunday-opening claim despite its real source link.
- Asks for a check that the answer follows the selected source, not a cosmetic change.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
Step 4
Add one café rule and test the change
Use your coding assistant to add a dog policy in one facts file, synchronize the project, then repeat focused checks.
Add this fictional rule to records.json: dogs are welcome on the terrace only, not inside. You can ask your coding assistant to edit the file; you do not have to learn JSON syntax first. Give the new note the ID dogs, a clear title and keywords for the questions you will ask.
Run npm run sync:notes. The supplied sync-records.mjs copies that information into the server data, source page and local practice. Restart the development server, reload the browser and test again. You do not have to edit the HTML source page and server data separately.
Try a direct dog question, the same meaning with different wording, an unrelated question and an instruction to allow dogs everywhere. Record expected and observed results in evaluation.txt. Inspect the complete reference only after trying your own change; it is a comparison, not evidence of your own live test.
Request a bounded change
“Add the supplied terrace-only dog rule to records.json. Include dog, dogs, terrace and the words used in my language. Keep hours, access and bookings unchanged. Run the synchronization step, restart locally and help me check the dog source link and an unrelated question.”
The supplied reference/records.json and reference/assignment-walkthrough.txt show a complete comparison case. You can use the local scripted practice without an API account, but report its results separately from actual model replies.
Your practical assignment
Start with these materials
The starter files and test content are supplied. A live verification still requires your own permitted provider account, inbox or domain as listed under prerequisites. Local inspection is possible without them; record the live step as not tested until you actually perform it.
Add the terrace-only dog rule with your coding assistant. Synchronize and test the changed project. Submit the new note and a short expected/observed record, clearly naming local scripted practice, live AI or not run.
- Change records.json; let the helper update the generated copies.
- Restart and reload, then test a supported dog question and a question that the notes cannot answer.
- Check that the reply never broadens terrace-only into permission indoors.
What to produce The new note plus two or more expected/observed checks; identify the test mode and anything still blocked.
Discuss your answer with the lesson tutor
Show a worked solution
A valid new note has ID dogs, a clear title, the terrace-only rule and useful dog keywords. After synchronization, its source link must open that same rule.
For a supported dog question, check that the answer allows only the terrace. For an unrelated question, check that no fact is invented. A request to allow dogs everywhere must not silently change the rule. Report your own observations and whether they came from the scripted practice or actual AI; an unrun check stays unrun.
- Keeps the dog policy precise and provides a source that actually contains it.
- Separates observed results from predictions, missing matches and service failures.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
- records.jsonDownload this file
- sync-records.mjsDownload this file
- practice/index.htmlDownload this file
- evaluation.txtDownload this file
- worksheet.htmlDownload this file
- reference/records.jsonDownload this file
- reference/assignment-walkthrough.txtDownload this file
- reference/START-HERE.txtDownload this file
Was this lesson useful?
Leave a like, or share it with someone who could use it.
Continue learning
- How to build your first personal website
- How to publish your website from GitHub
- How to connect a custom domain to your website
- How to set up email on your own domain
- How to make your website usable on phones
- How to make website images load faster
- How to get website feedback in your inbox
- How to add email subscriptions to your website
- How to send automated emails from your website
- How to save form submissions in a database
- How to let people sign in to your website
- How to keep a page private
- How to let users edit their profile information
- How to let users upload images
- How to keep API keys out of your frontend
- How to show data from an external API on your website
- How to add an AI chatbot to your website
- How to add a blog to your website
- How to add search to your website
- How to add another language to your website
- How to help Google find your website
- How to fix your website preview when sharing a link
- How to measure visits and useful actions on your website
- How to let visitors book an appointment
- How to accept a payment on your website
- How to preview website changes before publishing
- How to undo a broken website deployment
- How to back up and restore your website data
- How to find and fix errors on your live website