Forum Academy Marketplace Showcase Pricing Features

How to use instance.triggerEvent to initiate workflow?

I tried using instance.triggerEvent(eventName) within a button click function but it doesn’t want to trigger it. I’m probably doing something wrong but I don’t see much documentation on this other than Bubble saying that it is possible.

Any help will be greatly appreciated!

Are you sure your onClick handler is working?

Yes I tried it with a simple alert and it worked.

I’m getting a ‘eventName is not defined’ error in the console though. Would I declare it in the plugin editor?

Can you show your code you use to trigger the event.

I’d place a console log just after the trigger event code if it doesn’t log, there’s an issue but you’d likely get an error in the console too.

If everything is spelled correctly in the code, can you do me check you’ve included the event in the app?

Do you happen to have added the plugin to the app and be using the app to simultaneously test the plugin?



Events aren’t triggered that way.

You need to declare a trigger here

And it’s called like this with parenthesis


You’re not triggering a custom event from within the app. You trigger events from the plugin you’re building. What you are doing won’t work

Okay so then would I be able to call a specific workflow using a different method?

Bubble buttons all have a click handler that triggers events . If you want to trigger an event from a button you created in your plugin with html, you need to define an event in the plugin and then call it in the code.

I’ll give it a shot. Thank you!

What if the button is created outside of the plugin? I’m trying to check when a button is clicked using it’s ID Attribute and then activate a custom workflow. Is this possible?

I’m also not exactly sure what’s going on in your code as well. You’re triggering an event that you created above but what is it actually triggering?

sure. you need the id of the button
look for the button in your javacript
add an onclick handler
trigger an event

Think about triggerEvent like a way to tell the bubble app, “some action as occurred within my plugin so go ahead an run another workflow defined in the bubble app”

If you’re interested in booking a private session, I can help you build this functionality out in your own plugin!!

That was my exact thought process but no event gets triggered when I click the button.

if no event is triggered, then you arent finding the event.

try something more simple to start

console.log("If my button exists, I'll find out here", document.getElementById("btnTrigger"))

If I replaced the triggerEvent function with an alert, it shows up on click. So I know it can find the button and run through the function but it can’t see the custom event I’ve created.

I get an error saying event_clicked is not defined when it actually is…

Have you followed these steps?

when you follow these steps above you’ll find your action in the workflow menu like this

That did it. Thanks!

My only problem now is that when combining this with a ‘beforeunload’ function, the prompt asking if I’d like to go or stay shows up first even though the line right before it should’ve made the offer popup visible. I’m doing this to give the user one last chance of getting a custom lower rate. I understand that the background will be blurred or partially visible but it’s better than checking the location of the mouse.

Would you happen to have any idea how I can possibly work around this? Perhaps making it an async function to make sure it loads prior to fully returning? Unfortunately, you can’t modify the unload text prompt but I’ve seen someone inject some css as a header in the background as an alert.