Chatbots Tutorial menu

Chatbots Quiz

Answer these questions to check what you learned about building chatbots.

Quick Review

TopicKey idea
Rule-based botKeywords and fixed replies
AI chatbotA language model writes each reply
Messagessystem, user and assistant roles
MemoryYour code sends the history every time
API keyOnly on the server, in environment variables
StreamingText arrives piece by piece, ends with data: [DONE]
RAGRetrieve relevant chunks, then generate
SafetyStay on topic, limit usage, resist prompt injection

A one-line reminder of how the reply is read from a chat completions response:

Example

javascript
const data = { choices: [{ message: { content: "Hello from the AI!" } }] };
console.log(data.choices[0].message.content);
Output
Hello from the AI!

And the environment variable rule:

Example

text
Server code:   process.env.AI_API_KEY   (correct)
Browser code:  "sk-..." written in chat.js   (never)

Questions

Exercise

Which type of chatbot follows fixed keywords and replies written by a person?

Exercise

Which message role holds the bot's hidden instructions?

Exercise

Why does a chatbot send earlier messages with every request?

Exercise

Which HTTP status from an AI API usually means a wrong or missing API key?

Exercise

In a streamed response, where is the new text in each chunk?

Exercise

What is the main benefit of RAG?

Exercise

Why should the browser's chat code use textContent instead of innerHTML for AI replies?

Exercise

Your API key was pushed to GitHub by mistake. What should you do first?

Learn Chatbots with a teacher

Join the AI & Prompt Engineering course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp