This example demonstrates building a production-ready streaming chatbot with:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/motiadev/motia/llms.txt
Use this file to discover all available pages before exploring further.
- Real-time AI responses using Server-Sent Events (SSE)
- Conversation history management
- Multi-user support with isolated sessions
- Stream-based real-time updates
View source code
Complete source code on GitHub
What you’ll build
A chatbot system with:- HTTP endpoint for sending messages
- Streaming LLM responses
- Persistent conversation history
- Real-time UI updates via Motia streams
Architecture
Step 1: Create chat endpoint
Createsteps/chat-message.step.ts to receive messages:
steps/chat-message.step.ts
Step 2: Process with streaming
Createsteps/process-message.step.ts for AI processing with streaming:
steps/process-message.step.ts
Step 3: Configure the chat stream
Createsteps/chat.stream.ts for real-time updates:
steps/chat.stream.ts
Step 4: Alternative - SSE endpoint
For direct SSE without Motia streams, createsteps/chat-sse.step.ts:
steps/chat-sse.step.ts
Frontend: React integration
Connect to the chat stream:components/ChatWindow.tsx
Testing the chatbot
Send a message:What you learned
Real-time streaming
Stream AI responses in real-time
Server-Sent Events
Use SSE for one-way server-to-client streaming
Conversation state
Manage conversation history with state
Motia streams
Use Motia streams for real-time updates
Next steps
Gmail automation
Build email workflow automation
AI agents guide
Learn advanced AI agent patterns