Comment on page
Bubble App Connector
This section covers the Bubble App Connector plugin, used to connect two Bubble applications to each other
The Bubble App Connector plugin lets you access the database and API Workflows of a second Bubble app
Bubble can connect to most other apps by using the API Connector and/or the SQL Connector. Sometimes you may want to connect to another Bubble application, and we have made that option simple to set up using the plugin Bubble App Connector plugin.
The plugin does three things:
- It lets you authenticate with the second Bubble application by using an API key or OAuth authentication.
- It connects to the Bubble Data API
- It connects to the Bubble Workflow API
While this could be done with the API Connector plugin, the Bubble App Connector simplifies the process and gives you a visual representation of the second app's data types and workflows.
Throughout this article, we will refer to the app that initiates the connection as the first app and the app that you want to connect to as the second app.
In the example above, we have connected to a second Bubble application using an API key.
- 1.Public-workflow is an API Workflow set up in that application (Workflow API)
- 2.Task is a data type set up in that application (Data API)
As you can see, we can get simple access to both data and API workflows using a dropdown.
The Bubble App Connector is not a built-in feature but an optional plugin that needs to be installed through the plugin store. To install it, search for "App Connector" and install the plugin in the first app as illustrated below:
Make sure that the plugin you select has the By Bubble stamp in the lower right corner of the plugin entry.
Click install to install it in your app.
When integrating two apps using the App Connector plugin, it's only necessary to install the plugin in the app that initiates the connection. The app being connected to doesn't require the plugin to be installed.
You need to ensure some settings are properly configured in the second app. The settings depend on what kind of data and/or actions you want to share. First, navigate the Bubble editor in the second app to Settings - API.
If you want to initiate API Workflows in the second app from the first app, you need to enable the Workflow API by checking Enable Workflow API and backend workflows.
All the workflows that you want to trigger in the second application need to have Expose as a public API workflow enabled.
To share data from the second application, you need to enable the Data API by checking Enable Data API and then enabling the data types that you want to share.
Each of the data types you enable in the Data API will become available in the dropdown in the Bubble App Connector plugin.
To get full admin access to the second application, we will set up an API key. This method gives you unrestricted access to the workflows and data in the second application.
In Settings - API under the the API Tokens header, click the Generate a new API token button. You will be provided a randomly generated 32-character string that serves as the API key. You can provide a label for the token to keep track of where it's used. The label is only for your internal use and does not affect the connection in any way.
Now that we have installed the plugin and set up the second application to expose workflows and/or data, we can set up the connection and check that it works.
Let's look at each of the fields and what they mean:
- 1.App domain: this is the name of the second Bubble app, as visible when you preview the app:
- 2.App name: This is the name of the application: this field will be automatically filled after you enter the domain in step 1.
- 3.Match versions: Enable this option if you want the development environment of the first app to interact with the development environment of the second app. We recommend keeping this checked unless you have a specific reason not to.
After going through these four steps, Bubble will present you with the exposed workflows and data types. In the example below, we have an API workflow called Public-workflow and a data type called Task.
Next to the workflow or data type, there's a dropdown that lets you select between setting up the call as a data source or an action. This determines where in the first app you will be able to refer to it.
In the example below, it makes sense that the API workflow is set up as an action, meaning we can call it as an action in the workflow editor. The Task is set up as Data (data source) since we want to use to download Task data. In this case, the Tasks will be available by using the Get data from an external API data source in an expression.
Let's dig a bit deeper into how you can use the API workflow from the second application in an action. Using it as an action means that we can add it as a part of a workflow along with actions relates to the first app.
After the plugin and connection has been set up, you will find all queries set up as actions under Plugins:
- 1.Add a new action to a workflow
- 2.Click the Plugins submenu
- 3.Find the relevant action in the list that Bubble automatically generates. The label uses the following formatting: Run [app name] [action name]
This way you can keep track of actions from more than one application if necessary.
To query data from the second application, we'll use the Get data from an external API data source. Let's say we want to list the tasks from the second application in the first application. We'll set up a Repeating Group and set up the expression as follows:
- 1.As the type of content we select the Second Bubble app Task. The formatting Bubble will use here is:
[App name] [Data type]
- 2.As the data source, select Get data from an external API
- 3.The data source will open up the window on the left. In API provider you will see your data sources listed in the format:
Get [App name][Data type]
- 4.In the three fields, you can select the sorting, cursor and number of items to return: Sort by: lets you pick a field on the data type to sort by, and whether to sort ascendingly/descendingly. Cursor: lets you set the item from which to start sending data, similar to Item from # in Bubble Number of items to return: lets you specify how many things to return.