Using JSON-safe with Bubble.io and the OpenAI API
This Bubble tutorial is a follow up to our ChatGPT chatbot video where we demonatrated to how create a conversation with the OpenAI API using GPT-3.5-turbo. This videos demonstrates an improvement to our initial chatbot by using the Bubble.io text modifier :formatted as JSON-safe. This can solve many of your JSON syntax errors and OpenAI API errors by correctly escaping punctuation and formating your text input.
Master JSON safe formatting: Unlock the power of OpenAI in your Bubble app with this essential technique!
Escape punctuation like a pro: Learn how to avoid API errors and seamlessly integrate API connections in your no-code projects.
Bubble's JSON safe magic revealed: Discover the secret to sending complex data structures without syntax headaches!
Introduction to JSON-safe Formatting in Bubble.io
We've had a lot of great responses from our ChatGPT chatbot video and quite a few questions around using the API connection Bubble and JSON safe and JSON syntax. So I want to create a video showing how to use the text modifier formatted as JSON safe and this forms a good follow-up video to our ChatGPT chatbot video.
Demonstrating JSON-safe Formatting
To demonstrate it, I'm just going to add a text label here. To understand everything that I've built here, check out our ChatGPT chatbot video. Diving in with this, if I look at the multi-line input value and then I say formatted as JSON safe and then we preview that, you'll see that as I start to type it puts everything within speech marks. If I start putting some punctuation elements into the multi-line text input here, it formats those in a JSON safe way.
Understanding JSON Formatting
In many instances, the term kind of from traditional coding is that it escapes punctuation. This is where the problem is introduced: the format that OpenAI expects for their API text generator is JSON like this. You have a number of different fields or parameters here, and they're all kind of a combination of a label in speech marks and then the data to go along with that label. You also have arrays here so you can list more than one element.
The Importance of Proper JSON Syntax
The point is that you can't just go around putting speech marks anywhere you like in JSON or commas outside of speech marks anywhere you like because you will get a syntax error. You'll get an error back from the API, and so using formatted as JSON safe is one way to get around that.
Using JSON-safe Formatting in Practice
Let's illustrate that here by saying, "Well, sometimes I do want to send speech marks to OpenAI because it might be a way of highlighting." You could have a "summarize this text" and you'll want to send a colon and you'll also want to send some speech marks "hello world". You can see that Bubble has done a number of really helpful things here. It has added the backslash n to symbolize the two line spaces I've got, and it adds a backslash before the speech marks which are to be treated as speech marks and are not to be misinterpreted as speech marks within JSON.
Modifying the Initial Workflow
This allows me to modify my initial workflow. Again, if you're unsure about any of this, go and check out the full video. I want to change this here to JSON formatted as JSON safe, but I also (and this is where I've seen and it's caused me a number of headaches in the past) it gives you the speech marks. So at the moment, I'm going to get double speech marks here, so I changed that and I remove that.
Testing the Modified Workflow
Now let's test it. What could I have as a good follow-up to this conversation going on here? I could say "tell me five facts about" and then there's not a good reason to do this, but to demonstrate that the speech marks are made JSON safe, I'm just going to put "the shard" in speech marks and let's have a go.
Reviewing the API Response
We're waiting for a response from OpenAI and there we go, we've got our response back. I've not got an error, nothing has popped up as a browser prompt saying that OpenAI's API has returned an error.
Examining the Database
Perhaps this is something that I should have included in my initial video to make it an even better demonstration. I just wanted to demonstrate to you how JSON formatted as JSON safe can solve a lot of your problems with JSON syntax and then also how to use that properly with Bubble. If I go into the database, I can just show you what's going on there with I think it's messages here.
Verifying JSON Syntax in the API Connector
The JSON that I sent is here and you can see that it escapes the speech marks around "the shard" but it puts in the speech marks needed to indicate what is the content. So then if I go back into the API connector, we can see that as a message to go in my messages, it's all correct. There are no syntax errors.
Troubleshooting JSON Syntax Errors
If you are getting additional syntax errors, do go into your database. Check that your punctuation is being escaped, check that you've got formatted as JSON saved correctly, and that there aren't any issues with it. I would also check what you've got in this box here, that you've not got a comment out of place. Simplify all the way down to the bare essentials, get it working, and then begin to add in extra parameters, extra messages.
Conclusion and Further Assistance
If you've got a question about using the OpenAI API Bubble, leave it in the comments. We read every single one of them.
Ready to Transform Your App Idea into Reality?
Access 3 courses, 400+ tutorials, and a vibrant community to support every step of your app-building journey.
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 400+ 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.
Valued at $80
Valued at $85
Valued at $30
Valued at $110
Valued at $45
14-Day Money-Back Guarantee
We’re confident this bundle will transform your app development journey. But if you’re not satisfied within 14 days, we’ll refund your full investment—no questions asked.
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Frequently Asked Questions
Find answers to common questions about our courses, tutorials & content.
Not at all. Our courses are designed for beginners and guide you step-by-step in using Bubble to build powerful web apps—no coding required.
Forever. You’ll get lifetime access, so you can learn at your own pace and revisit materials anytime.
Our supportive community is here to help. Ask questions, get feedback, and learn from fellow no-coders who’ve been where you are now.
Absolutely. If you’re not satisfied within 14 days, just reach out, and we’ll issue a full refund. We stand by the value of our bundle.
Yes, this is a special limited-time offer. The regular price is $350, so take advantage of the discount while it lasts!