Ask questions to database, get analysis and charts - AI integration

Hello great people!
So I stumbled upon this interesting tool that after feeding the data into, you can ask questions and it analyses it and then gives a reply, also creating a specific chart if requested:

I was wondering, how can this be made in bubble? Any pro has an idea on how to make something similar? I’d like to add it in my app, so that the user can insert data, store it in the bubble database, and then ask questions about it or request it visualised in any chart he wants.

Thanks so much for help, think this could be really useful and powerful if paired with bubble!


A little off topic but one of the biggest challenges with implementing something like this will be security. As of today, I believe there is no good way of ensuring the charts your users ask your AI to create would not contain data from other users. See prompt injection.

Of course, if you do silo / deploy your bubble apps in a way that they’re all single tenant, that issue disappears. But other data leaks could still happen without carefully restricting the training set given to your AI. Bubble’s privacy rules would almost always not protect data in this scenario.


Hey Zelus, thanks for the contribution! That’s a really valid point and something to absolutely address before going live. Another thing i’m thinking is also how much this could cost. For the response and chart generation, the best I’ve found until now, is to ask GPT to firstly respond to the question in plain english, and then to make an unformatted html with javascript code, ideally feeding this in an html input in bubble so to get both the written reply and a visual representation such as a chart. The prompt + response could even cost 5 cents per chart created, that’s not cheap.
I still miss the part where the ai is connected to the bubble database to get the data and reply to the question. That’s where I’m struggling at the moment and hope someone can point me in the right direction.

Conceptually I think this should happen:

  1. User asks question in a multiline input
  2. A workflow triggers an API that tells gpt to check the whole database filtered for that user (possibly with the data type privacy rules already in place)
  3. Gpt reads all the database and finds a suitable reply
  4. It sends the prompt response to an html element in bubble with the whole reply, both the text and the html code with the js script and chartjs library link to display the chart.

I have managed to do this correctly by hand, so giving gpt4 some data, making the prompt for the reply, and then inserting manually the code in the html element in bubble. Works great, now its a matter of making it all in bubble and then experimenting with it to see privacy, injections, costs etc.

If someone can help please do so :slight_smile:

This is what I have managed to accomplish until now.

Feeding data in Chatgpt:
(this ideally is the bubble database to which gpt is connected already)

Giving it instructions in a prompt:
(not perfect, can be much improved, but its ok for now)

Getting a response:

Copying the response in a HTML element in bubble:

Viewing the result in a live webpage on bubble frontend:

Now, is anyone able to help me automate this in bubble with API connector and workflows?
What I struggle with now, is how to connect GPT to database, then seems more straightforward.
Anyone has a clue how to do this and can help?
Thanks guys :slight_smile:

hi there, for sure you should not be using consumer chatGPT for this, preferring instead to use LangChain , chaining the prompts, then using that chain as an API for your calls and responses

1 Like

A small update, found this other forum post where multiple users are working to achieve similar results and there’s plenty of useful resources and even video tutorials!

In the following weeks I’ll try to build what I’m needing, if I succeed I’ll chime back in and update with the findings and results. If in the meantime anyone gets there first and has a good solution to achieve this, let us know!
Cheers and thanks for contributions! :slight_smile:

1 Like