Solution: making API workflows to run on a schedule

we at Bubblewits, when working on a project for a client to synchronize their Harvest time tracking data with Bubble database through Harvest API, have come up with a solution to run an API workflow on a scheduled basis (for example every 1,5,15 minutes etc.) in the background, even when the app is not running.

We found out that AWS’s Lambda service allows to host any code in python or node.js and then trigger it on schedule using Cloudwatch.

so we have simply created a Lambda python function that sends a POST request to Bubble endpoint (or a list of endpoints) triggering associated workflow and configured the frequency with which this function gets triggered.

Let me know if there is any interest to this and I will share the step by step instructions and the lambda python code where you’d need to only replace the endpoint urls, and authorization.

Lambda service has a free tier which to my calculations should be enough for a lot of operations. So this is a better solution than using Zapier for triggering webhooks.

Beware that calling API workflow even if its condition is not met counts toward the monthly workflow limits.
And by the way AWS allows creating and hosting API gateways, with endpoints that can trigger any Lambda Function. So for example Bubble can call a certain API at AWS and that in turn will trigger a Lambda function to do something.

Thanks,
Levon.

Founder at Bubblewits - Bubble Certified Partner

http://iambubble.com - one page Bubble demo
http://builtonbubble.com - Collection of apps built on Bubble
Dev.zeroqode.com - Reach out if you need help creating something on Bubble
Private Bubble Lessons by Skype

11 Likes

Well done! Would like to see how you did it.

Nice, but don’t see how it is a better solution than Zapier. Even on free tier.

1 Like

I thought it’s better because it’s free :), zapier’s free plan is limited in terms of number of zaps you can trigger per month… Although I agree that it’s easier to configure and use Zapier

2 Likes

Ah, yes, task limit of 100 could get used up fairly quickly I guess.

exactly! :slight_smile:

1 Like

It’s formidable! I’ll contact Bubblewits when need this feature

Yes, AWS provides some pretty amazing products. I’ve been using EC2’s, VPC’s and some of the other products for a few years, but just recently learned about Lambda. Amazon has managed to make everything very modular and so easy to use. Just don’t forget to turn off an EC2 for a couple of weeks/months. You’ll be in for a very big suprise bill!

1 Like

So, here are the steps,

  1. create an AWS Lambda function using this step by step tutorial http://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-create-function.html
    make sure you name the handler: post.lambda_handler
  2. download this zip pack https://drive.google.com/file/d/0BzKv7KzSvu8VdmYzQlBBcFh4RVk/view?usp=sharing
  3. open the file main.py
  4. replace the URLs with your Bubble Endpoints
  5. replace the API token (Currently a dummy one)
  6. zip it back keeping the structure and upload it to lambda function’s code
  7. Enable the scheduled event in the event sources

Let me know if you encounter any difficulties.

7 Likes

Thanks!!!

Hi @levon,

Are above steps still working, or are there better/upgraded ways?

I am stuck at step #3. Cannot locate main.py.

edit: step#3 actually means editing the post.py inside the zip pack.

Happy to have successfully implemented the steps, and is working great!

Thanks for sharing your simplified steps with the code.

Thanks Carl, and sorry for the mistake. yes, it should hae beeen post.py
Does work fine now?

Levon Terteryan
Founder @ Zeroqode & Bubblewits

zeroqode-for-web-160x120

Bubble Templates
Bubble Plugins
Bubble Courses
Convert Web to iOS & Android
No-code Development Services

Yes, Levon, it is working fine. :slight_smile: Thanks a lot.

Hi @levon, is it also possible to be able to schedule the lambda function at specific days and time (eg. every mon, weds, & friday at 1am to 5am)? Does it require to change your python code?

In case, & since I do not know python, do you know whether aws lambda function is trigger-able thru zapier with use of schedule and webhooks?

Thanks again :slight_smile:

Hey Carl,
sorry i’m not sure about that, i didn’t play with Lambda since I wrote the post which is about 2 years now :slight_smile: So i’d suggest you to google that :slight_smile:
Thanks

Levon Terteryan
Founder @ Zeroqode & Bubblewits

zeroqode-for-web-160x120

Bubble Templates
Bubble Plugins
Bubble Courses
Convert Web to iOS & Android
No-code Development Services

I see. No worries. Thanks Levon

Hi,

Thank you so much for sharing this! Has absolutely been a game changer for my app. So many new possibilities.

I have now set it up to trigger an endpoint once a day within bubble, that send out some e-mail. However, the last time the endpoint was triggered 3 times from AWS lambda, sending the same email 3 times.

After doing some research I have understood 3x is the most amount of times AWS lambda will attempt to run a code (asychronously), so I figured something wasn’t working properly. The only thing that came up with was server time-out, so I have increased the timeout from 3 to 5 seconds, which seems to work properly now…

However, to be completely honest I am way outside my depth here, and have really no idea what I’m doing.

Has anyone experienced something similar? And have you found a good solutions to ensuring that you don’t get any errors from the AWS side?

Any help is greatly appreciated!

Cheers,

Hi, has anyone else experienced a lot of timeouts from lamdba using this code? After more research, I believe it has to do with the code, and the time it takes to execute. I keep pushing up with time-out limit.

It still didn’t work at 10second. Have now pushed it to 5 minutes to see if it would just take the same amount of time.

Any help would be greatly appreciated!

cheers,

@levon Hi! Very nice! I know that bubble now has scheduled workflows, but i would like to learn this method just for educational purposes. I am stuck at step 4. How do I configure this endpoint on Bubble?
Thanks in advance.

Thank you for the post. Yes a guide or the steps for this will be of great help.