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.

Start the interactive lessonRead the lesson below

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.

Workshop files

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

Start hereWorkshop files

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

Files for this step

Start hereWorkshop files

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.

Files for this step

Start hereWorkshop files

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.

Files for this step

Start hereWorkshop files

Open or download the files below. When saving a project, keep the folder paths shown in the filenames.

Was this lesson useful?

Leave a like, or share it with someone who could use it.

Continue learning

Explore the other lessons