Tutorials
Recap: Yesterday we wired LangBot’s prompt and model into one pipeline with LCEL’s pipe operator — chain = prompt | llm. One invoke() call now handles everything from formatting to generation. But we still get back a raw AIMessage and have to reach into .content for the text. Today LangBot returns real typed objects.
The problem: unstructured mush
Every LLM response so far has been an AIMessage — a blob of text with no shape. To extract anything useful, you either parse it yourself or pray the model followed your formatting instructions. Both are fragile.
Recap: On Day 1 we built a basic CLI chatbot. Day 2 gave it memory so it remembers the conversation. Day 3 added a prompt template so LangBot has a personality. But every turn still requires two separate steps — format the template, then call the model. Today we stitch them together into one fluid pipeline.
The problem: two steps where one should do
Here is how LangBot works on Day 3. Every single turn:
Recap: On Day 1 we built a CLI chatbot with ChatOpenAI. On Day 2 we gave it memory so it remembers the conversation. But LangBot still has no personality — every session starts with a blank slate, and the model defaults to its generic “helpful assistant” tone. Today we change that.
The problem: a chatbot with no identity
Right now, LangBot’s response to any first message is unpredictable. Ask “What do you do?” and you get whatever the base model decides. There is no way to control:
Recap: Yesterday we built LangBot — a 27-line CLI chatbot powered by ChatOpenAI. It works, but every message starts from scratch. Ask “What’s my name?” and it invents one. Remind it “My name is Alex” and ask again — it still guesses. Today we fix that.
The problem: amnesia mode
Try this in Day 1’s LangBot:
You: My favorite color is blue.
LangBot: That's a great choice! Blue is calming and versatile.
You: What did I just say my favorite color was?
LangBot: I'm not sure — you haven't mentioned a favorite color in this conversation.
Every call to llm.invoke() sends a single HumanMessage. The model has zero context from previous turns. For a real chatbot, this is a dealbreaker.
Welcome to LangBot — a daily tutorial series where we build one chatbot app from scratch using LangChain . Every post adds one new concept to the same codebase, so by the end you will have a production-ready chatbot and a solid mental model of how LangChain works.
No magic. No abandoned side projects. One app, built in public, one concept at a time.
What we are building
LangBot is a conversational chatbot that runs in your terminal. Today it will be simple: you type a message, it replies. But every day this week we will add memory, prompt templates, structured output, retrieval, agents, streaming, and more — all in the same codebase.