MessagesState
Ready-made state.
So many graphs need a messages key with add messages that LangGraph provides it ready made. It's called messages state. You can use it as it is, or extend it with your own keys.

- Very common
- Ready-made
- Extend it
Extending MessagesState
Our state extends messages state, so it already has messages with add messages. We add one key of our own, the customer's name. The node uses both. Input messages can be plain dictionaries now. Run it. The model greets the customer by name.
from langchain.chat_models import init_chat_model
from langgraph.graph import MessagesState, StateGraph, START
model = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0)
class State(MessagesState):
customer: str
def chat(s):
prompt = [("system", f"Greet {s['customer']} by name. One sentence.")] + s["messages"]
return {"messages": [model.invoke(prompt)]}
b = StateGraph(State); b.add_node(chat); b.add_edge(START, "chat")
out = b.compile().invoke({"customer": "Priya", "messages": [{"role": "user", "content": "Hi!"}]})
print(out["messages"][-1].text)Hello Priya, it's great to hear from you today!
MessagesState
Messages state is just a typed dictionary, with one key, messages, using add messages. Subclass it to add keys, like a customer name, a cart, or a counter. It's the usual starting point for chatbots and agents.
| key | value |
|---|---|
| One key | messages |
| Reducer | add_messages |
| Subclass | add your keys |
| Use for | chatbots, agents |
Summary
Messages state gives you a messages key with add messages, ready to use or extend. Next, a chatbot graph with several turns.
Key takeaways- MessagesState
- Subclass it
- Dict messages work