Skip to main content

Actions

Actions are the steps in a workflow that do the work. Learn how to add them, control when they run, use data between steps, and use native mobile actions.

Written by Sofia Maconi

Actions are what make things happen in your app. They're the part of a workflow (see Key terms) that does the actual work, such as changing something in the database, showing or animating an element, or sending the user to another page.

A diagram of a workflow, with an event pointing to actions.

An event starts the workflow, and the actions do the work.

Actions run as the result of an event (see Key terms), and together they make up the workflow.

Events decide when to do something, and actions decide what to do.

You can chain actions together to perform a set of tasks in sequence, and each step can use information from a previous step. You can also add a condition to any step, so it only runs when something is true.

Working with actions

In the Workflow tab, a workflow's actions appear as soon as you create or open it, listed in order underneath the event.

The workflow canvas showing a Button Sign up is clicked event labeled Event, and a Sign the user up action below it labeled Action.

The event sits at the top of the workflow, with its actions underneath.

Creating actions

To add the first action to a workflow, click the + icon underneath the event. You'll see a list of actions sorted into categories.

You can add more actions to use across your app by installing plugins, or by adding API calls in the API Connector with Use as set to Action.

When you add or click an action, Bubble shows its properties in the workflow property editor. Here's the Make changes to a thing (see Key terms) action:

A Make changes to User action, with Thing to change set to Current User and the Name field set to Jane Doe.

This action changes the current user's name to Jane Doe.

Thing to change sets the data source (see Key terms) of the thing you want to change. Once you've picked it, Bubble shows the fields (see Key terms) on that data type (see Key terms). In the example above, we change the user's name to a static text value.

Setting conditions for running an action step

A workflow can have as many steps as you need, but sometimes a step should only run in certain situations. For example, a step might require the user to be logged in, and if they aren't, you can show an error message instead.

That's what the Only when field is for. As the name suggests, it tells Bubble to only run this action when a condition is true. Conditions are dynamic expressions (see Key terms) that return a yes or no value.

This step uses dynamic expressions to set up conditions. If you're new to these, it can help to read these articles first:

Article: Dynamic expressions
​Article section: Conditions

To stop an action from running at all without deleting it, you can turn on its Disable Action toggle.

The order in which actions are triggered

A workflow is built as a list of steps, but a lot happens behind the scenes when it runs, and steps don't always finish in the order you placed them.

Some actions run in the user's browser, others, like database operations, run on Bubble's server, and some run in both places. When a workflow mixes these, the order things happen in can differ from the order in the workflow.

To keep things fast, workflows run in parallel across the user's device and the server. Even though steps are numbered, a step doesn't necessarily wait for the previous one to finish before the next one starts. These rules explain how workflows run:

Rule

What it means

Frontend actions start in order

Actions start in the order you placed them, but an action doesn't wait for the previous one to finish.

Backend workflows start right away

A Schedule API workflow action starts as soon as the workflow runs, even if it's the last action in the workflow.

Custom events run in sequence

If a workflow triggers a custom event, the custom event finishes before the rest of the workflow continues.

Searches may lag behind

A search may not include a thing you just created or changed, so don't rely on it in a later step. Getting the thing from Result of step X is safe.

These tips can help your workflows run the way you expect:

Situation

What to do

One trigger can lead to different results depending on conditions

Create separate workflows with conditions on the workflow itself, instead of one workflow with conditions on each action.

Step 2's condition depends on a search affected by step 1

Move step 1 into a custom event, so it finishes before step 2 runs.

A backend workflow should start after other steps

Schedule it from a custom event placed after those steps.

A step needs data from an earlier step

Use Result of step X instead of a search. See Using data from a previous step.

An action needs to wait for something

Bubble can't make an action wait for a workflow to finish, but the Add a pause before next action action often works. It only delays client-side actions.

Understanding workflow execution rules

Using data from a previous step

Sometimes an action needs data from an earlier step in the same workflow. If you get that data indirectly, for example with a search, the change from the earlier step may not have caught up yet. The Result of step X data source gives you the result of that step directly.

Let's say you use Make changes to a thing to change a product's name in step 1. In step 2, you use Set state of an element (see Key terms) to save that name in a custom state.

A workflow with a Make changes to Product action as step 1, and a Set states action as step 2 that saves Result of step 1's Name in the Product name custom state.

The numbers match the table below.

Number

What's set up

1

Step 1 changes the product's name.

2

Step 2 saves Result of step 1's Name in a custom state, which is the product as it looks after step 1 has run.

Native mobile actions

If you're using Bubble for native mobile apps, you also get actions that use the features of a phone, such as navigating between views (see Key terms), sending push notifications, and getting the user's location.

Navigation

Mobile apps don't have pages. Instead, users move between views, and there are a few ways to take them there.

Go to view

The Go to view action takes the user to another view. Its Navigation type decides how the view opens: as part of a stack, or as a modal.

Stack

Stack navigation is a pattern where users move through a "stack" of screens as they go deeper into your app. Take the Spotify app as an example. When you're on a tab, such as Home or Your Library, and open a playlist, you're looking at a new screen while the original tab stays active underneath. The new view is "stacked" on top of the base view, which is the tab itself. To go back, you tap the back arrow in the upper-left corner.

The top bar of a mobile view, with a back arrow next to the title Check in.

The presence of a back button in the top left is an indicator that you’re navigating through a stack of views.

Reset navigation stack

When the user navigates to a new view, the original stack stays active, so they can go back with the built-in back button or by swiping. If you don't want them to go back, turn on Reset navigation stack in the Go to view action. This clears the navigation history completely.

A Go to view action with Navigation type set to Stack, and the Reset navigation stack checkbox highlighted.

Resetting the navigation stack is performed within the Go to view action.

For example, if a stack shows a login form and the user logs in, you probably don't want them to go back to the login screen. Resetting the stack lets them start fresh from the new view.

Resetting the stack removes the original stack from Bubble's memory. You can no longer use any data from the original view, such as form content, and actions that target that stack, like resetting the form, will fail.

Modal

A modal opens a view as a full-screen sheet over the current view. Use one when you want to give the user a focused task that needs the whole screen. A good example is the new message screen in the iOS Messages app. You don't need the messages underneath while you write, so the modal takes up the full screen, but you can quickly get back to your messages when you're done.

To open a view as a modal, use the Go to view action and set Navigation type to Modal. Users can swipe down to close a modal, but it's a good idea to add a close button too. To do that, add an app bar to the view you're opening as a modal, and add a trailing button with a Go to previous mobile view action.

An app bar with the title Current view title and a Done button highlighted on the right.

A trailing button in the app bar gives users a clear way to close the modal.

Modals are similar to sheets, since both give the user a more focused experience. A modal is a whole view, so it works best when you don't need data from the view underneath, such as the data source of a group on that view.

Go to tab

The Go to tab action works like Go to view, but the target view has to be connected to a tab. When the action runs, the tab bar updates to show the new tab.

Set current view's property

The Set current view's property action sets the value of a property on the view that's currently open. To use it, you first need to define one or more properties on the view.

Push notifications

Push notifications let you send updates, reminders, and alerts straight to a user's device, even when they aren't using your app. Whether it's a personal message, an offer, or news about activity in the app, they help keep users connected to your app's content.

Push notifications use the built-in features of iOS and Android, and they only work in native mobile apps, not in web apps.

Before you can use push notifications, you need to add your push notification settings to your app.

Article section: Push notification ID and key (iOS)
​Article section: Play Store push notification settings (Android)

The devices data type

Using push notifications adds a built-in data type to your app called devices. It holds key information about each user's devices, and you use it to tell the Send push notification action where to send a notification.

The devices data type is read-only, so you can't rename it, rename its fields, or add new fields. It's also protected by a built-in privacy rule (see Key terms), since the push notification token it holds is sensitive.

The data type is added as a field on the user, so you can reach it with expressions such as:

Current User's devices

Do a search for:User's devices

Overriding the built-in privacy rule

The push notification token is sensitive, so it generally shouldn't be shared. If you need to send it outside your app, for example to a third-party system, you can use a backend workflow and check Ignore privacy rules when running this workflow.

Requesting permission to send push notifications

Both iOS and Android need the user's permission before you can send them push notifications. Ask for it with the Request push notification permissions action, which opens the operating system's standard prompt. The prompt is the same in every app, so you can't customize it.

Set this up before you start sending notifications.

Sending push notifications

Once the user has given permission, you can send push notifications with the Send push notification action, which you'll find in the Emails and notifications category.

The properties of a Send push notification action, with a title, subtitle, body, devices, tap destination fields, and an Only when condition.

The properties of the Send push notification action.

Property

What it does

Title

The main header

Subtitle

The sub-header

Body

The main message

Devices

The devices to send the notification to, from one or more users. To send it to the current user, use Current User's devices.

On tap, navigate to

The view to open when the user taps the notification. See Configuring a tap destination.

Your app icon is shown in the notification, and you can't change it for individual notifications. The properties work the same way on iOS and Android, and the notification looks much the same on both.

Configuring a tap destination (optional)

By default, tapping a push notification opens your app as it normally starts. You can also send the user straight to a specific view:

Property

What it does

On tap, navigate to

The view to open. The dropdown lists all the views in your app, and the default is the root view. Picking a view turns on the other fields.

Overlay (optional)

A sheet or floating group on the destination view to open after navigating. The dropdown only lists those elements, and the field is disabled if the view has none. Picking an overlay overrides any conditions on it that would otherwise hide it.

Navigation type

Appears when the destination isn't a tab view. Stack pushes the view onto the navigation stack, and Modal opens it over the current context. If the destination is a tab view, the app switches to that tab instead.

Base view (optional)

Appears when the navigation type is Stack or Modal. A user who arrives from a notification has no navigation history, so this sets where the back button leads. The app builds a stack of the base view and then the destination view. If you leave it empty, the back button goes to the root view.

View parameters

Appears when the destination or base view has view properties, with a field for each property. Values can be static or dynamic expressions.

View parameters are evaluated when the notification is sent, and the resulting values are included in the notification. Nothing is evaluated on the device when the user taps it.

How tap destinations work at runtime

Situation

What happens

The app is closed

The app launches, reads the destination, navigates to the view, opens the overlay if one is set, and fills in the view parameters.

The app is in the background

The app comes to the foreground and does the same. If the user is already on the destination view, the parameters are refreshed and the overlay opens again. If they're on the base view, the destination view is added to the stack.

The app is already open

The destination view and its base view are used no matter where the user is in the app, and they're stacked on top of the current navigation.

If something goes wrong, the app falls back like this:

Situation

What happens

The destination view can't be found

For example, if it was deleted after the notification was sent. The app goes to the root view.

The user's session has expired

The app goes to its default logged-out state, and the destination isn't kept through the login flow. This is uncommon, since push notifications are only sent to logged-in users.

The destination is a tab view

The app switches to that tab and marks it as active in the tab bar.

Example: deep linking to a detail view

A common use is telling a user about a new comment and taking them straight to the post:

1. Create the backend workflow

Create a backend workflow that runs when a new comment is created, and add the Send push notification action.

2. Write the notification

Set the title and body, such as New comment on your post.

3. Set the destination

In On tap, navigate to, pick your post_detail view, and set Navigation type to Stack.

4. Set the base view

Set Base view to your main feed view, so the back button takes the user to the feed.

5. Pass the post

In View parameters, pass the post's unique ID to the destination view's property.

When the user taps the notification, they land on the post. Tapping back takes them to the feed.

Deep linking limitations

  • Payload size: iOS and Android limit the size of a notification to about 4KB, so a lot of view parameters can push it over the limit. Keep parameter values short.

  • No deferred deep linking: If the user has uninstalled the app, the destination isn't kept if they install it again.

  • No resume after login: If the user has to log in again, the destination isn't kept, and they land on the default logged-out state.

Scheduling push notifications

To send a push notification at a later time, use the Send push notification action in an API workflow in the Backend workflows tab (see Key terms), and schedule it with the Schedule API workflow (see Key terms) action.

Testing push notifications

Push notifications can't be tested in web preview, and they can't be sent to a simulated device. To test them on a real device, use a dev build, or deploy your app and add it to TestFlight.

Create a mobile deep/universal link

The Create a mobile deep/universal link action creates a URL that opens a specific view in your native mobile app. You can use the URL in any later step: save it in the database, include it in an email or text message, copy it to the clipboard, or show it to the user.

The action creates one of two kinds of links, depending on its Fallback property:

Link type

When you get it

How it works

Universal link

Any Fallback other than None

A standard https:// link on your app's domain. If the app is installed, it opens the app to the destination view. Since it's a regular web link, email apps, text messages, and social media handle it well, and it falls back to the option you choose when the app isn't installed. Use it for links shared outside your app. Universal links need some one-time setup.

Deep link

Fallback set to None

A link that uses your app's custom scheme, such as myapp://. It opens the app if it's installed, but it has no fallback: If the app isn't installed, or the link is opened on a computer, nothing happens.

Use this action whenever you need a shareable link that opens your app in a specific place, for example:

  • A link to a new message or an order confirmation in an email

  • A link users can copy to share the content they're looking at

  • An invite or onboarding link that opens a specific view

  • A link saved in the database to use later

Setting the destination

The action uses the same destination properties as a push notification tap destination: On tap, navigate to, Navigation type, Overlay, Base view, and View parameters. For links, Base view appears whenever the destination isn't a tab.

View parameters are evaluated when the action runs, and the values are saved in the URL. The link is a snapshot of the data at that moment, not when someone opens it.

Choosing a fallback

The Fallback property decides what happens when the link is opened on a device that doesn't have your app, or on a computer:

Option

What happens

None (default)

The action creates a deep link with no fallback.

Web app page

The link opens a page in your Bubble web app, which you pick in the Page field. If the page has a content type, a Data to send field appears too, like in the Go to page action, and it's evaluated when the link is created. This option is only available if your project has a web app.

External webpage

The link opens the URL you enter in the URL field, starting with http:// or https://.

App store

The link sends iOS users to your App Store listing and Android users to your Google Play Store listing. For iOS, this needs your iOS App Store ID. On a computer, there's no app store, so the link shows a not-found page.

The fallback options need the Universal linking device permission. If it's turned off in the Settings tab, the Fallback field is disabled, and the issue checker flags workflows that use one.

Universal links also need the store setup and a new build of your app. Until then, a universal link opens in the browser like any other web link.

The result

The action returns one value: the URL, as text. You can use it in later steps with Result of step X.

A deep link uses the app scheme you've set up for your app, and a universal link uses your app's live domain, which is your custom domain if you have one. Both kinds of links also carry the destination, overlay, base view, and view parameters. Use the result as it is, rather than building or editing these URLs yourself, since the format may change.

Where you can use the action

Workflow type

Notes

Frontend workflows, on web pages and mobile views

Create links from button clicks, page loads, or any other event.

Backend workflows

Create links in API workflows, scheduled workflows, and recurring events. Creating a link doesn't need a mobile device, only opening it does.

How links work when they're opened

If the app is installed, a link opens the same way as a push notification tap destination. See How tap destinations work at runtime.

If a universal link is opened without the app, on a device that doesn't have it or on a computer, it opens in the browser and follows the fallback you picked.

Example: shareable content link

Here's how to let users share a link to the content they're looking at:

1. Add a share button

Add a Share button to your detail view, and add the Create a mobile deep/universal link action to its workflow.

2. Set the destination

Set On tap, navigate to to your detail view, set Navigation type to Stack, and set Base view to your main feed or home view, so the back button leads somewhere useful.

3. Pass the content

In View parameters, pass the content's unique ID to the destination view's property.

4. Set a fallback

Set Fallback to Web app page and pick the content's web page, or to App store if your project has no web app. That way the link still works for people who don't have the app.

In the next step, use an action like Copy to clipboard or Send email with Result of step X.

When someone taps the link, they land on the content with the right item loaded, and tapping back takes them to the feed.

Example: link in a backend email workflow

1. Create the backend workflow

Create a backend workflow that runs when a new order is placed, and add the Create a mobile deep/universal link action.

2. Set the destination

Set On tap, navigate to to your order_detail view, and pass the order's unique ID in View parameters.

3. Set a fallback

Set Fallback to any option other than None. Email apps often strip deep links, so links in emails should be universal links.

4. Send the email

Add a Send email action, and include the link in the body with Result of step X.

When the user taps the link in their email, they land on the order in the app.

Link limitations

  • Deep links have no fallback: Some email apps, such as Gmail and Outlook, may block or strip deep links, and some social media platforms may not show them as tappable links. If the app isn't installed, or the link is opened on a computer, a deep link does nothing. Use a universal link for anything shared outside your app.

  • No deferred deep linking: If someone without the app follows a universal link to the app store, installs the app, and opens it, they land on the app's first view, not the destination.

  • No login: The URL doesn't include any credentials, so you can't use it for magic link logins or guest access on its own.

  • View parameters don't update: Parameters are set when the link is created, so values that depend on data that hasn't finished loading on the page may be empty or out of date.

Location services

Native mobile apps have two actions for location services:

Native mobile apps can also take photos and pick images from the user's photo library.

Build actions with Bubble AI

You can ask the Bubble AI Agent to add and change actions in your workflows. Select the workflow or action you're working on, describe what should happen, and then check the result in the Workflow tab.

The Agent supports a set list of action categories in frontend workflows: account, navigation, data, email and notification, element, and plugin actions. In backend workflows, it can add common actions, such as creating, changing, and deleting things, API calls, and Schedule API workflow, and it can add Only when conditions to individual actions. It declines very complex workflows, and it can still explain how to set up things it can't build.

Here are a few prompts to try:

Add an action to this workflow that sends the user to the dashboard page after they sign up.

Create a workflow that runs when the user clicks the Save button. It should create a new Task using the value from the Task name input, then show the Saved group.

Explain the order the actions in this workflow run in.

Why isn't the second action in this workflow using the updated data from the first one?

How do I send a push notification when someone comments on a post?

FAQ: Actions

What's the difference between an event and an action?

The event decides when a workflow runs, such as when a button is clicked. The actions decide what happens next, such as saving data or showing an element.

Article: Events

Do actions always run in the order I place them?

They start in that order, but an action doesn't always wait for the previous one to finish. See The order in which actions are triggered.

How do I use data from an earlier step?

Use the Result of step X data source. It's more reliable than a search, which may not have caught up with the change yet.

How do I skip an action or stop a workflow?

To skip an action in some situations, add a condition in its Only when field. To skip it every time without deleting it, turn on its Disable Action toggle. To end the whole workflow at a certain point, use the Terminate this workflow action.

Do actions use workload?

Actions that run on Bubble's server, such as changing data or sending emails, use workload. Actions that run only on the user's device, like showing an element, don't.

Can I use native mobile actions in a web app?

Most of them, like Go to view and Send push notification, only work in native mobile apps. Create a mobile deep/universal link is an exception, since you can use it in workflows on web pages, mobile views, and in the backend.

Is the push notification token secure?

The token is stored in the devices data type, which a built-in privacy rule protects. If you need to send the token to another system, you can do it from a backend workflow that ignores privacy rules. See Overriding the built-in privacy rule.

Key terms

Workflow: A workflow is the combination of an event and one or more actions.

Article: Workflows

Event: An event is what starts a workflow, such as a button being clicked.

Article: Events

Make changes to a thing: Make changes to a thing saves changes to a specific thing in the database, such as a user's name or a product's image.

Data source: A data source is any place from which Bubble can retrieve data, such as the database, the current user, or an external API.

Fields: Fields are where a data type stores its information. You can create as many fields as you need, and each one has a type, such as text, number, or image.

Data type: Data types are like containers for a specific kind of information, made up of fields. User is a built-in data type, and you can add your own, like Product or Blog post.

Dynamic expressions: Dynamic expressions are like live formulas that update based on user input, database changes, and other things happening in your app.

Set state of an element: Set state of an element sets the value of a custom state on an element. Custom states are like variables that store information temporarily, until they're updated or the page is reloaded.

Article: Custom states

Views: A view is the top-level element in a native mobile app, serving the same role that a page does in a web app.

Privacy rule: Privacy rules decide which data each user is allowed to see, before anything is sent to their device.

Backend workflows tab: Backend workflows run on Bubble's server, so they don't need anyone to have your app open.

Article series: Backend events

Schedule API workflow: The Schedule API workflow action runs an API workflow at a time you choose.

Did this answer your question?