Limited Time Offer: Watch All Our Bubble Tutorial Videos for Only $99 per Year!

Bubble.io & OpenAI - Improve your workflow and data structure

In this Bubble tutorial video we demonstrate a simple way you can improve and simplify your OpenAI API workflows in your Bubble app.

Here's a quick tip for how to improve the efficiency of your OpenAI integration with your Bubble app.

If you're learning Bubble and you haven't checked our website, planetnocode.com, then you need to check it out because we've got even more Bubble tutorial videos than you can find on our YouTube channel, and many of them are member exclusives, and you can sign up today to become a member and get access to all of our videos.

Working with OpenAI Integration

But this is the bit that I want to draw your attention to with the OpenAI integration. Remember, with OpenAI, you need to supply all of the previous messages in a conversation in order for it to respond with understanding the historical context of each message. So the way we do that is that we do a search for messages. And when this first became possible, when OpenAI released GPT-3.5 turbo, and suddenly all of these things that we had in our brains, how can we create them, these AI tools, and now you can build them, I came up with this way of formatting it, which is that you have a text field, like a human-readable field, and then you also have a JSON field. So whenever you create a message, you create the JSON structure for the user here, and then the equivalent in here, and you can see that I need to update this.

Improving the Efficiency of OpenAI Integration

Let's fix this and let's put in the step that I want to share with you about making this much more efficient. Instead of saying search for messages, then show the each item's JSON, instead, we shall say format as text. And then that allows, and I'm going to have to copy the example they give here. I'll copy that from the OpenAI documentation. That allows us to format the JSON in the midst of the workflow rather than having to save it to our database. The delimiter, that's the computer science term for what separates them and what separates them is a comma and a space. And then we can just add in dynamic data here. So this message is... I don't think I'm saving role, am I? Okay, so I need to save role. I think you can see where this is going. So the role here is user. And then the role here is assistant. Oh, no, I'm not adding a new field. I'm saying role. Okay, that then means that in the format as text, I can say this message is role.

Autofill assistant and user roles

And then in here, I'm going to get rid of everything, including the speech marks, because I'm going to make it JSON-safe. I can say this message is text, json-safe. Okay. Because JSON-safe wraps it in its own speech marks. And that is also going to ensure that I don't get any syntax errors. If someone puts in a colon or any other punctuation that's going to cause an issue with the JSON, Bubble protects against that by using this modify here and format it as json-safe.

Avoiding unnecessary JSON saving

Because I've got that in place, I now no longer need to save JSON, so I can remove the field there. And then just because I'm coming back to this demo, I'm just going to fix this bit, which is to say save the results step two first items message content. Yeah, because that's the reply that open the items back. Anyway, that's a really quick little tip.

Improving your no code OpenAI Integration

It's a small thing you can change, but if you're trying to reduce workload units, if you approach app development how I do, which is that if you can make it simpler to do, then this is something that you can do to make your app simpler, which is to use the format as text to take out multiple fields and format them in a way that you're trying to structure your data. In this case, we're trying to structure it as the appropriate JSON syntax to be sent over to OpenAI.

Latest videos

menu