Topic overview
A chatbot is more than a model behind a text box. It manages a conversation: each turn is combined with history, instructions, retrieved knowledge, and tool results, then answered and streamed back. The hard part is not the first reply but the tenth: keeping context within limits, staying on task and on policy, recovering from misunderstandings, and knowing when to hand off to a person.
Core concepts
Conversation state: the model is stateless, so your app sends the relevant history, as role-tagged messages, with every turn and stores the conversation itself. Decide what you persist (messages, summaries, user facts) and for how long.
Context window management: history grows each turn. Keep the system prompt and the most recent turns, summarise or drop older ones, and pin facts that must not be lost. Long histories raise cost and latency and can bury your instructions.
Memory: short-term memory is the current thread. Long-term memory is facts saved across sessions in a database or vector store and retrieved when relevant. Get consent, and let users see and delete what is stored.
System prompt and persona: sets the role, tone, boundaries, and refusal rules. Keep it stable, test it like code, and never rely on it alone for safety.
Grounding with retrieval: for product, policy, or company questions, retrieve the relevant documents (RAG) and answer from them with citations, instead of trusting the model’s memory.
Tools and actions: let the bot look up an order, open a ticket, or book a slot through tool calls. Validate arguments, ask the user to confirm risky actions, and log every action taken.
Streaming and latency: stream tokens as they are generated so replies feel fast, show progress while tools run, and set timeouts with a sensible fallback message.
Safety and handoff: filter unsafe input and output, resist prompt injection, avoid leaking private data, and hand off to a human when confidence is low, the user asks, or the stakes are high.
Evaluation: measure task success, groundedness, escalation rate, and user satisfaction on real conversation samples, and replay logged conversations against a new prompt before you ship it.
Why it matters
Chatbots are the most common way users meet an LLM product, and one of the easiest to get subtly wrong: lost context, confident wrong answers, or an action taken without confirmation. Treating conversation as a system, with state, grounding, tools, guardrails, and evals, is what separates a demo from something users can trust.
Interview relevance
Expect to design a support or assistant chatbot end to end: how you store and trim history, what you keep as long-term memory, how you ground answers and cite sources, which actions need confirmation, how you stop prompt injection, how you measure quality, and when you escalate to a human. Common follow-ups cover latency and streaming, cost control as conversations grow, and handling many users or several languages.