OpenAI Assistant & API Connector Part 1

In this Bubble tutorial we demonstrate how to use the OpenAI Assistant API, OpenAI Thread API and Bubble API Connector.

Ask a question

Notify of
Inline Feedbacks
View all Q&As

Introduction to OpenAI Assistant API in Bubble

You asked for it in the comments. Here is my Bubble tutorial video demonstrating how to use the OpenAI Assistance API. This is brand new, this was only released last week and I'm probably going to do two parts of this. I'm going to do an explanation in this video about all of the additional OpenAI API calls that are required and then in part two I will actually put it into the front end of Bubble.

Understanding the OpenAI API Calls

But this is a really important explainer because I would like to point out that there is definitely more to it to make use of these exciting new features. There are more API calls that are required. But that is a hundred percent worth it in order to get OpenAI handling your thread. They will now store your messages which means that you don't have to send all your messages through every single time. OpenAI can take care of that all through their API.

Considering the Costs of OpenAI

I will just point out that some people on Twitter or on Twitter have seen them saying that this might get very expensive very soon. So do make sure you understand and you check out the costs of paying OpenAI to store your messages going forward. But all of that will be demonstrated, will be explained. I'll be going through the API documentation on the page here and I'll be showing how to link that into the Bubble API connector in this video.

Learning Bubble with Planet No Code

Before I launch into it, if you're watching this video you're probably learning Bubble and there is no better way to learn NoCode and Bubble than with Planet No Code.

Creating Messages in Bubble

So if I go under here and then go to messages and create message, I have to copy the structure here. And this is what it looks like in the Bubble API connector. If I copy the endpoint and paste it in, the structure that OpenAI provides uses curly brackets around the thread ID. For Bubble to turn it into square brackets, and that then lets me insert data into the URL.

Working with OpenAI in Bubble

This is where things are different to how we've worked with OpenAI in the past, which is that I get back a response instantly, there's no waiting, and my response is simply the recognition that I've created a message in the thread. I don't get back the OpenAI's reply to the message. We're going to come on to that. I can further demonstrate this by saying, well, what if we list all the messages currently in the thread? Is it just going to be the message I've added in, tell me three things to do, or will it include the AI's response? Well, let's have a look.

Creating an Assistant in OpenAI

Next, I need to create an assistant, and that's because an assistant is key for the run command, which is what I'm going to come on to in a moment. And so your assistant is setting the tone. And so I'm going to change this instead to say travel agent and say you are an experienced travel agent. And I'm going to initialize the call. And again, I get back an instant response and all of this is is a confirmation that the assistant has been created. And the assistant has an ID. So I'm selecting the ID and putting it on my clipboard because now I get to the point where I actually run it.

Running the Assistant in OpenAI

It's only at the point of running it that I get my AI responses or response in my conversation. So I'm going to paste in my assistant. I've got my structure here from the API documentation on run and create run. And so the only essential data that I place in is the assistant ID. And also again, notice the threads ID in the URL. So go back into here, copy my, copy my threads that I'm working with this one here. Okay, and now I can initialize my call.

Understanding the OpenAI Response

Again, I get back an instant response, but this is effectively saying that status queued. As soon as I initialize this call, OpenAI is writing the assistance response to my initial query. And so now if I go back to list messages, I get my actual AI response, which is here. So it's recommending that I explore the Tower of London.

Engaging with OpenAI Assistant

Let's do one more prompt message to and through in the API connector here to really demonstrate the different steps that are required. And then right away, I'm going to record the second part of this video because we'll be plugging this into a repeating group and a multi-line input on the front end and get a user engaging with it.

OpenAI Assistant and Threads API

That is how we can use the assistant and the threads API from OpenAI to take control, to make it in some ways we're handing over responsibility for dealing with the conversation on the messages to OpenAI. Let me know your comments feedback. Is this better than the previous ways of doing it where you had to handle all the messages or the JSON in Bubble? Or do you think that this is an incredibly important feature?

OpenAI Pricing and Upcoming Content

Also, let me know what you think about the pricing. Do go and check out how much it's going to cost to store all this data in OpenAI and make sure you're subscribed and you like this video here because part two will be coming out very shortly.

Latest videos