
Mini lesson 18 of 30 · Connect data and AI
Build a chatbot that knows the café’s information
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.
Your result: a working question box that answers from supplied café notes and opens the source behind the answer.
Purpose of this lesson
- 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.
Explanation, worked example and practice
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.
Check your starting skills
These are useful skills, not locked course requirements. If you can already do them, start this lesson; otherwise open the linked preparation. The supplied starter files mean you do not need an existing personal website.
- How to keep API keys out of your frontend
Put the provider secret only in the private server environment.
- How to add an AI chatbot to your website
Run a first real AI reply.
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.
Understand the idea
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.
Try it yourself
Open the local practice and try the opening-hours and phone-number questions. For each, report whether a note was found and what the page showed. This is a scripted exercise; do not report it as a live AI test.
- Open the ready practice link below; no download or API key is needed.
- Use both prepared questions and compare Selected evidence with Scripted response.
What to produce: Two short observations: one supported fact and one missing fact.
Show a worked solution
The hours question selects the hours note and displays its supplied hours. The phone question finds no matching note and shows the missing-information message. These are results of the local rules exercise; live AI generation has not yet been tested.
What a sound answer includes
- Distinguishes a matching hours note from an absent phone fact.
- Reports the local scripted result without claiming an AI request.

Step 1 · How to make a chatbot answer from your own content
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.
Explanation, worked example and practice
Understand the idea
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.Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
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.
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.
What a sound answer includes
- 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.

Step 2 · How to make a chatbot answer from your own content
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.
Explanation, worked example and practice
Understand the idea
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.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
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.
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.
What a sound answer includes
- 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.

Step 3 · How to make a chatbot answer from your own content
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.
Explanation, worked example and practice
Understand the idea
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.
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
Your practical assignment
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.
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.
What a sound answer includes
- Keeps the dog policy precise and provides a source that actually contains it.
- Separates observed results from predictions, missing matches and service failures.
Was this lesson useful?
Leave a like, or share it with someone who could use it.