Can bubble run python scripts?

Is it possible for bubble to run python scripts?


Hi @orensaldanha

You can’t directly do this that I am aware of, but you do have other options close to hand.
Both Zapier and Blockspring allow you to write simple Python scripts and it is pretty easy to trigger those from Bubble. Help pages pasted below.

If your Python script is a little more complex then you might be looking to host on a dedicated server and make a call to it from Bubble. Something like PythonAnywhere allows you to simply to host your code and you would make an API call to it from Bubble, once you have setup an endpoint in your Python script.



Woah, I think that’s exactly what I want !

Cant wait to try it!

Thanks a lot, Edward

Thanks a lot for this idea. Pythonanywhere helped me immensely.

1 Like

Follow up - my Pythonanywhere Flask app console seems to need a restart every week or so, as it appears to stop running. If you have experience, do Pythonanywhere apps have bad uptime, or am I just using it incorrectly?

Hey @spencer,

Can’t comment on pythonanywhere, but I’ve really been happy with Google Cloud functions now that they added Python 3.7 runtimes. If you can’t find a pythonanywhere solution, you might check into this, or Lambda if Amazon is your infrastructure choice.

1 Like

Have you tried using their scheduled tasks or their ‘Always On’ tasks?

1 Like

Thanks - I think that’s going to be a winner.

1 Like

I’m curious to know what some of your use-cases are for running python scripts? Has anyone made a machine learning app?

Sure, here’s one use case – CSV uploads:

CSV uploads have too many limitations right now in Bubble, so I offload that to python. A user uploads a CSV file, which I send off to python. Python parses the headers and evaluates the data, and then returns to Bubble the column headers. I take those column headers and allow the user to map those fields, to Bubble fields. This is done so the user does not have to provide a CSV with exact matches in the header row.

Once the mapping is done, I give python the map and have it perform the actual upload into the Bubble db. It breaks the CSV into batches that conform to any limits on the Bubble side, and uses the data api to send it all over – or alternatively, it does individual posts of new data in the case of needing to check for dupes, modify existing records, etc.

When finished, I trigger a post back to a Bubble workflow that generates an alert to the user so they know the process is complete.

Along those same lines, there is a nightly polling of a remote ftp server, that spins through any files and processes them much like I described above.

Another use case is dealing with unique identifiers – I basically use python and a mysql db to do record locking in situations where race conditions occur, or when I need very tight assurance that a value is not used twice.


I use python for a number of things. For instance, I have a discord bot written in python which interacts with bubble as the frontend experience and allows me to create a more holistic experience for users.

Similarly, I use python scripts for dynamic bulk data creation to bubble since the 'Schedule a workflow on a list" and “recursive scheduling” can be slow at times.

Essentially, I use python to address some of the bubble’s limitations without having to worry about maintaining a whole codebase that comes with building the whole application with code.

Re: Machine Learning. That’s something I intend to try my hand at in the coming weeks with the bot.


I just use it to interact with an API using a set of logic that Bubble can’t provide. I POST to the same endpoint in a loop until it returns a success code, and then I GET from a different endpoint with data from the first result.


Hey guys wonder if anyone can help me on this -

I want to grab some numbers saved in my Bubble database, use some python code (or any other way you can suggest) to perform some if/or logic and calculations on the numbers. The output would then be a number that I want to save back into my database.

Bit stuck on this and would appreciate any help on it! Cheers

Unless you’re doing complex computation on large datasets then the easiest way to do this is locally using Javascript.

The simplest way to do that in Bubble is to use the Toolbox plugin and use the Run javascript workflow action.

You can bring variables or arrays into your script just how you would normally bring dynamic data into text / search fields.


Thanks @exception-rambler that looks like exactly what I need, certainly no complex computation.

Guess I’ll have to learn some Javascript!

Really appreciate the help, many thanks :facepunch:

Happy to help if you get caught on the script - DM me or put it in a new thread here.
But having some Javascript skills will grant you Bubble superpowers so it’s time well spent.


Thanks again @exception-rambler - one thing I’m not sure of is how to handle cases where there is no value in the database?

Say for example I want to grab a users age and run some logic on it, but if they haven’t entered their age then use a default value of 0

When I’m building plugins I’ll normally include a function that helps me cover the different possibilities of no value. As follows:

function isEmpty(property){
  if (property === '' || property === null || property === undefined) return true;
  else return false;

You could add this at the start of your script and then say something like:

if (isEmpty(**Search for your item:first item**)) let newValue = 0;
else { **calculate new value**}

One thing that isn’t 100% straightforward is getting a value back out of your script to use later on.

To do this you’ll need to an a Javascript to Bubble element to your page (this will have come with Toolbox). This workaround is needed because Bubble carefully controls how you can get data back into your workflows / database, so it has to come via a plugin.

Set it up as follows - I’ve used a generic name ‘fetchValue’, you could use anything:

Then finally, back in your workflow, you will finish the script with:

bubble_fn_fetchValue(newValue); where newValue is the name of the variable carrying your adjusted number.

That value will now be available throughout Bubble - either in a Text element / something similar, or in a workflow - by referencing JavascripttoBubbleA’s value


Once again @exception-rambler, thanks a million for this. All working great for me now, really appreciate the detailed explanation and think that your isEmpty function will quickly become a staple of mine…

Hey @exception-rambler - another question I hoped you’d be able to help out with. Wanted to know how private the code I put in my Javascript script will be?

I’m putting some business logic in there which ideally wouldn’t be public so just wanted to check…

Cheers, Lee