Watch and track your favorite playlist.
Curated by: Laravel News (16 videos)
We've been testing the agent through JSON routes. It works, but real customers don't talk to JSON endpoints. They expect a chat interface, and nobody wants to stare at a loading spinner for five seconds while the AI generates a reply. In this episode we build a real-time chat widget where responses stream in word by word as the agent thinks. The SDK makes this a one-line change. Instead of `prompt()` we call `stream()`, and the SDK forwards token deltas to the browser via server-sent events. I add a stream method to the ChatController that handles SSE, reusing a private resolveAgent method to start or continue conversations for authenticated users. The frontend is a Livewire component that manages the message list, input, conversation ID, and a streaming flag. Inside the Blade template, Alpine.js opens a fetch readable stream, parses each chunk, and appends the text live. The result is a polished chat that feels like ChatGPT but runs on our agent with our tools, our knowledge base, and our conversation memory. I also flag a small gotcha around capturing the conversation ID on the first message and how to fix it with a completion callback. ⭐ GitHub: https://github.com/harris21/ship-ai-with-laravel 👉 Full series playlist: https://www.youtube.com/playlist?list=PLsmlCYEtWNI_plnKPPO13XjfDJoMIfhLN 👉 Timestamps 00:00 Why Streaming Matters 00:23 Prompt vs Stream 01:04 Building Stream Endpoint 03:03 Routing SSE Stream 03:28 Livewire Component State 05:04 Blade Template Setup 06:40 Chat Page Route View 07:37 Live Demo Streaming Chat 09:02 Conversation ID Gotcha 09:36 Wrap Up Next Steps ---------------------------------------------------------------------- ➫ Business Inquiries: hello@laravel-news.com ---------------------------------------------------------------------- JOIN OUR WEEKLY LARAVEL NEWSLETTER 👉 https://laravel-news.com/newsletter ----------------------------------------------------------------------