Looping through with Javascript in Bubble Backend Workflow
How to loop through a complex math equation in a backend workflow where you can't use Math.js
Unlock the power of AI: Learn how to manipulate timestamps and format data in Bubble's backend workflow
Master Bubble API magic: Convert milliseconds to YouTube-friendly timestamps with custom API connectors and JavaScript
Supercharge your Bubble app: Discover how to leverage backend workflows for efficient data processing and formatting
The Challenge of Manipulating Numbers in Bubble Backend Workflows
I want to describe to you a challenge that I faced when trying to manipulate numbers, do some maths, and do some reformatting in a Bubble backend workflow. Here's the challenge. I've been using AssemblyAI with an internal tool that we've got at Planet No Code to transcribe and generate content on our videos. Part of that is generating those nice timestamps chapters that you get in a YouTube description.
AssemblyAI's Timestamp Generation
AssemblyAI gets me this far, which is that they'll generate a transcript and I can then call a particular endpoint and I can get the paragraphs and I get a start and an end time for those paragraphs. Now the issue is that these timestamps are in milliseconds, so I want to convert them into kind of an MM colon SS format. It's quite simple to convert them into seconds. You would just divide them and then you get seconds. But that's not the format that YouTube wants.
YouTube's Required Format
They want that MM for minutes and colon SS for seconds. So how did I go about fixing this, or at least finding a solution? Well, I built my own API workflow endpoint called convert, and then I used ChatGPT I think, to generate some JavaScript here which takes in my milliseconds input and formats it as hour, hour, minute, minute, seconds. And then I'm using, I think it's the toolbox, the toolkit JavaScript plugin here, and then I return the data.
Implementing the Solution in Bubble Workflow
This means that in my workflow where I actually save this, I'm saving a timestamped transcript and the issue is that I want to loop it through with every paragraph. So I'm saying take my paragraph data format as text, I then call my own workflow API endpoint.
Using the API Connector in Bubble
So I've added this into the Bubble API connector and I use it as a data source. And so I have it here, I've validated it, initialized it in my API connector, and then I say put in the start time. So this is going to run this convert workflow for every paragraph that goes through this format as text statement. And then below I print my paragraphs text.
The Final Output
That means I get a nice format to save and then pass on into Claude or OpenAI, whatever I use to generate the chapter headings. I've got my minutes, seconds, and then I've got my paragraph below and I've got paragraph after paragraph with that for my whole transcript.
The Necessity of Custom JavaScript
I basically had to solve this because at least when I was last testing this, I found that AI's are not clever enough. At least the APIs that are available from Claude or OpenAI, they're not clever enough to say, here's milliseconds, convert it into minutes and seconds. So I had to use some custom JavaScript and I've just demonstrated the process for you here.
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Flexible Pricing Plans to Fit Your No-Code Journey
Choose the plan that aligns with your goals and start building your startup today.
Have questions?
We have answers!
Find answers to common questions about our membership plans, programs, and more.
Both plans offer full access to our learning resources, community, and support. The Annual plan provides a significant discount (over 15%) compared to paying monthly, and it allows you to lock in your rate for a full year.
Absolutely! You can easily upgrade or downgrade your membership plan at any time by logging into your account and selecting the desired plan. Any unused portion of your current plan will be prorated and applied to your new plan.
As a Planet No Code member, you'll receive a discount on our Bubble coaching sessions. Monthly members receive a 10% discount, while Annual members receive a 17.5% discount. To redeem your discount, simply log into your account and book a coaching session through our platform.
Our 8-week intensive mentorship program is designed to provide personalized guidance and support to help you accelerate your startup journey. You'll be matched with a startup expert who will work with you one-on-one to set goals, overcome challenges, and make rapid progress.
To apply for the Mastery Program, simply click the "Request Invitation" button on our pricing page and fill out the application form. Our team will review your application and schedule a call with you to discuss your goals and determine if the program is a good fit for your needs.
We accept all major credit cards, including Visa, Mastercard, American Express, and Discover.
While we don't offer a free trial, we do provide a 14-day money-back guarantee. If you're not completely satisfied with your membership within the first 14 days, simply contact our support team, and we'll issue a full refund.
If you decide that Planet No Code isn't the right fit for you, you can cancel your membership at any time by logging into your account and navigating to the subscription management page. Click the "Cancel Membership" button, and your membership will be terminated at the end of your current billing cycle.