Connect OpenAI to Bubble Database?

Can the OpenAI API be connected to a Bubble database to access real-time data? Has anyone accomplished this or done something similar? I’ve seen many apps launch data analysis chat-bot experiences inside of their application where they ask the bot questions on the data in their database. I’m curious to see if anyone has accomplished this using Bubble.

Example: https://www.triplewhale.com/moby

2 Likes

Leverage functions.
In this example here Azure AI ChatGPT on your Data Plugin Demo I send weather info from Bubble to ChatGPT to answer user’s query.

1 Like

How would this work with a Bubble database?

1 Like

You send back to GPT whatever data required for a specific function, including from Bubble DB.

The issue with function calling is that I’d have to create a million different functions to answer user questions :frowning: @redvivi

What’s your use-case and DB structure?

I’ve built an app that takes data from multiple apps that a customer uses for their business (ex. quickbooks) and builds dashboards so they can visualize their data.

My goal is to build an AI chatbot that allows the user to ask questions about their data in real-time.

Examples of questions:

  • How much revenue did we do last year?
  • How much did I spend on software in May?
  • What are my outstanding invoices?

Each of these questions would require different functions to fetch the data, so the set up sounds like a nightmare.

If I export my database into CSVs and feed to AI models like chatGPT, it can easily answer these questions but feeding CSV files is extremely inefficient and wouldn’t provide real-time data to the AI.

Please help :sob: I’m an AI noob.

2 Likes

Hi, I’m interested in this topic as well!

I’ve just successfully set up OpenAI Assistant Integration (just using the basic API to OpenAI), which took me forever to finally get working, even with the helpful tutorial video from one of the Bubble engineers.

Now, I’d love to set up function calling to the Bubble Database. I have two specific use cases:

  • Function calling to particular data types that are public, such as research articles or resources
  • Function calling to users’ data, which needs to state private to the user

Are there any good tutorials on function calling? I’m also new to AI commands and don’t quite understand how function calling is different from training the model on a file – or how it works, exactly.

Bryan

2 Likes

Hey @bwm561 @franklyn1 I made a guide here explains how I do this in my Bubble app:

Pretty much you need to make a backend workflow in you bubble app that can be triggered by an API call.

You could set it up to be a Get call and return the value of whatever datatype you need.

Then the Ai assistant can have a function that makes the API call to your endpoint and gets the information of it before answering a question or other use case you may have :slight_smile:

Let me know if you need further help!

1 Like

Thanks for your response @design.agx ! But not entirely what I’m looking for but is a perfect solution for @bwm561 . In your example, it’s seems like standard function calling which I’ve already figured out how to do. You have an API that does something specific (replace pokemon) (and also used a 3rd party tool which I don’t think was entirely necessary :slight_smile:) where in my case, I would need an unlimited amount of functions to return values for all different types of user questions since the data would live across multiple things.

I’m currently in the middle of researching vector databases to see if this is my solution but it’s incredibly cumbersome :sob:

Someone please help…

@franklyn1 oh yeah I use Buidlship as it’s faster to work with Open ai assistant than in bubble in my opinion :slight_smile:

Have you thought to make a table containing all the fields from multiple sources? :thinking:

Can you share more about your database structure please?

1 Like

Yes, but that won’t seem to solve my issue, unfortunately. My database has multiple things, with each table being related through a custom unique id. I think the main issue is creating functions to return results isn’t efficient.

For example, I could create a set of functions, each returning things like count, sum, averages, etc. But it would be extensive to start returning more specific data.

In the example of quickbooks data I mentioned above, I could set a function to answer “How much revenue have we done?” by creating an API that returns the sum of revenue and allow date filters to sort the data. But if a user asks “Give me my top 5 clients by revenue”, I’d have to create another function that doesn’t return the sum, but instead, returns a list of clients.

I’m worried that this would turn into rabbit hole plus not to mention the limits on the amount of functions you could give an AI assistant, the limit of records bubble will return without pagination, etc…

There HAS to be a way to have AI simply have access to the database and all of the tables in real-time. CSV exports of my entire database that is then uploaded to GPT actually works – can’t figure out how to get it to access real-time data.

@emmanuel We need your help! :hearts:

Another example is Zapier Chatbot/Tables.

Zapier has a tool called Tables, which is basically a database inside of Zapier. They also have a tool called Chatbot that allows you to connect “Knowledge Sources” like websites, files, and even their own Tables.

I would’ve been able to replicate my bubble database in Zapier Tables in order to use their chatbot, and embed the chatbot in my app BUT there are limitations…The chatbot will MAX read 1,000 records making it unusable…

Are all the calculations/analytics already pre-computed and available in your DB or do you expect the chatbot to do the calculation as per the user requests?

Mind you that generative AI returns the most probable token each after another…so don’t expect a general usage LLM to do analytics over n-dimensions out of the box…so if you have the data at hand, that’s what we need.

I’ve formatted the data so that an LLM can answer general questions about the data. I just can’t figure out how to “speak” to my bubble database.

Looks like I can send my data to Buildship (rowy) and build a chatbot on that database…but that would require me to create a replica of my database and maintain it each time something changes…not ideal.

If the data is already formatted, I would try to determine the “primitives” of the user queries.
You mentioned sum, average, top of revenue or spendings by clients/suppliers. Those are primitives that may answer say 90% of your user query. Either by individual or sequencial calls the LLM will figure out.

I would define those functions, so when the user query for instance a top 5 revenue for December, it will query the top function with arguments “revenue”, “5”, “2023-12”.
Then based on this, you have a search for taking into account those arguments to return the right data to the LLM.

1 Like

@franklyn1 I don’t think you need to move your database to an external one (rowy).

@redvivi has the best approach. A backend workflow that takes some filters can help simplify this!

And the function of the assistant should explain what filters the Ai can use.

@franklyn1 I would recommend you to look into Buidlship, create a backend workflow that’s accepts filters, and use Buidlship tool to let the Ai fill the necessary filters when doing an API call to your backend workflow.

2 Likes

Curious to know if you had good results, I have a similar project to develop! :thinking:

Reading the whole discussion I feel you have a B2B app with OpenAI being able to scan them through and answer your questions - kind of the usability in Microsoft Dynamic 365 Enterprise edition.

I don’t know your specific use case, but doing that in bubble seems moderately easy yet complicated as I searched the forum for similar queries. I suggest you use a cloud provider to store your data in an SQL DB and use a service like Data Factory or Big Data services in the case of Azure Cloud. In GCP you can do this in Vertex AI Studio where you can directly feed the Vertex AI model with your SQL DB data easily and allow Gemini or any other model to return your answer and connect with bubble using API to show your answer in your app.

My suggestion seems technical, but as of now, this is an alternate solution to what you are looking for.

1 Like

If that’s the use case, Azure On Your Data does this heavy lifting for you.

Once configured through Azure’s tutorial, connect with the API connector or if you need streaming a suggestion is Azure AI - ChatGPT on your Data Plugin | Bubble and you are all set.