Real-time Chat with ChatGPT: Streaming Responses in Ruby on Rails [Tutorial] [Turbostream]

Dive into the next step of integrating ChatGPT with Ruby on Rails! This tutorial will guide you through creating a dynamic user experience by streaming ChatGPT responses in real time. We’ll explore the installation of Sidekiq, setting up message models, and utilizing Turbostream to write messages instantly. By the end, you’ll have a seamless chat experience ready to impress your users. Perfect for those familiar with Rails and looking to enhance their apps with AI chat capabilities. Don’t miss the recap for key takeaways!

This carries on from my previous video here: where I discuss calling the OpenAI API and waiting for a response. That way is still the best way (in my opinion) for NON user-facing integration with OpenAI. The way I discuss here is for a more dynamic UI.

## Timestamps
00:00 Intro
00:40 Install sidekiq
06:00 create message model, controller, etc
08:42 update chat views
11:55 Messages controller
14:25 messages views
20:00 OpenAI background job
28:15 Write to the page using Turbostream
28:45 broadcast the message
32:30 the message view
35:40 Recap

The source code and notes for this video are available on my Gumroad:


Some people online just talk – I just do. One of my major SaaS products out there is ( THE AutoResponder and Customer Management tool for Amazon Sellers. Join over 17,000 other Amazon Sellers and sign up today!

Looking for great hosting? I’ve been using DigitalOcean for 7 years and they have never let me down. Amazing.
Check them out here and get $100(!!!) free credits towards the cost of servers.

#techEntrepreneur #entrepreneurship #softwareDevelopment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.