OpenAI Assistant & Bubble.io API Connector Part 2
In this Bubble tutorial we demonstrate how to use the OpenAI Assistant API, OpenAI Thread API and Bubble API Connector.
Unlock the power of OpenAI's Assistant API: Build a ChatGPT-like interface in Bubble!
Master thread management: Learn to create, display, and interact with AI chat threads in your Bubble app.
Elevate your Bubble skills: Discover advanced techniques for integrating AI and no-code to create powerful, responsive chat interfaces.
Building on the OpenAI Assistant API in Bubble.io
Let's take everything we covered in part one of this video of how to use the Bubble API connector with OpenAI's new Assistant API. We'll be building upon that to cover the core context. Go back and watch the previous video if you need a refresher. Let's dive in with the OpenAI API here. You can see we've got our different prompts, our different API calls listed down here. This is what we're building upon from the previous tutorial.
Creating a ChatGPT-like Interface
I'm going to go onto my blank page here, and I'm going to create something that looks similar to the ChatGPT web interface. I'll have two groups: one as a column with a width of 220, and another where my chat is going. To get a little bit of contrast between them, I'll add some styling. Let's make the first group dark color and the second one gray with white text.
Adding a New Chat Button
We'll start with a button to create a new thread. I'll call this "new chat" and add some nice styling. What's new chat going to do? Well, from the OpenAI API perspective, it's going to create a new thread. So I'll use the "create new thing" action in the database.
Setting Up the Thread Data Type
I'm going to create a new data type and call it "thread" to use the terms that OpenAI are using. The thread will have an ID field of type text. Then I need to do my API call. I'm going to look for my OpenAI create thread action, which I've set up in the plugins section.
Creating the Thread in the Database
Going back into the workflow, there are no parameters needed for create thread, but out of the response, I can take the ID. This will create an entry in my database for this thread.
Displaying Threads
To display these threads, I'm going to add in a repeating group. This will list through threads, and I'll add a text label to show the thread ID as a way to distinguish between the different threads I create.
Setting Up the Conversation View
Next, we'll start adding our conversation view. I'm going to add in another repeating group for this. I'm going to try to get this data live from OpenAI rather than storing messages in my database. To do that, I'll use the "list messages" API call and initialize it with the thread ID.
Using User Fields for Current Thread
I'm probably going to use a field on the user for the thread ID so that when the user clicks on a different thread, I can swap that out in the user. This is handy for remembering which thread is being used, especially if the page refreshes or the user navigates away and comes back.
Setting Up the Chat Interface
I'll add a text label to display the message content, a multi-line input for the user to type their message, and a send button. When the send button is clicked, we'll create a message and assign it to the current thread using the OpenAI API.
Handling Message Creation and Display
To create a message, I'll use the "create message in thread" workflow action, using the current user's thread ID and the message content. I'll use JSON safe to ensure the message is properly formatted for the API. Then, I'll run the assistant on the thread.
Testing the Chat Functionality
After setting everything up, I tested the chat functionality. There were some initial issues with data not updating in real-time, which I'll need to address in a future update.
Conclusion and Next Steps
While we've successfully set up the basic structure for our OpenAI Assistant-powered chat in Bubble, there are still some challenges to overcome, particularly with real-time updates of the repeating group. I'll be exploring solutions to this in a future video. Despite these challenges, we've made significant progress in integrating OpenAI's Assistant API with Bubble, creating a foundation for a powerful AI-driven chat application.
The best way to learn Bubble.io?
Start building with total confidence
No more delays. With 30+ hours of expert content, you’ll have the insights needed to build effectively.
Find every solution in one place
No more searching across platforms for tutorials. Our bundle has everything you need, with 500+ videos covering every feature and technique.
Dive deep into every detail
Get beyond the basics with comprehensive, in-depth courses & no code tutorials that empower you to create a feature-rich, professional app.

Frequently Asked Questions
Find answers to common questions about our courses, tutorials & content.
No. Our Beginner Essentials course and AI No-Code Coach are designed for total newcomers. You’ll learn Bubble.io step by step - no coding required.
Simply type your question in plain English, and our AI taps into the entire video library to recommend the exact lessons you need. It’s like having a personal instructor on demand.
As long as you’re subscribed! With our monthly subscription, you get unlimited access to all 500+ videos, our growing course library, and the AI No-Code Coach.
Your subscription includes:
- Bubble Beginner Essentials – Get up and running fast.
- Build a ChatGPT Clone – Integrate AI into your no-code apps.
- Build Your SaaS Website with AI – Learn to create a scalable startup site.
Plus, new tutorials every week!
The AI No-Code Coach is your first stop for instant answers. If you need deeper help, you can book 1:1 Bubble coaching for expert guidance.
Yes! If you don’t see real progress within 14 days, let us know, and we’ll issue a full refund—no questions asked.
Absolutely. Your subscription is month-to-month, and you can cancel anytime—no lock-ins, no hidden fees.
Absolutely. Your subscription is month-to-month, and you can cancel anytime—no lock-ins, no hidden fees.
If you’re serious about building a successful SaaS startup, check out Mastery—our intensive mentorship program. Mastery goes beyond Bubble.io development and includes:
- 1:1 mentorship to fast-track your progress
- Marketing strategies tailored for no-code founders
- Product management insights to scale your startup
- Personalized support from experienced founders