This is a guide on how to use the Query step in the template builder. To learn about using creating queries in the Integry App Creator, visit this guide.

Query is a step that is used to import data from one app into the other app. This step, when executed at the integration creation, is known as the initial data import. As illustrated in the query activity type document, let’s say you are creating an integration to import and sync your contacts from Mailchimp to Sendinblue. You will need to import all the existing contacts and their details from the Mailchimp account once. This is done through the query step.

As the data that needs to be fetched from another app can be in a large amount, a query usually runs in a loop and fetches records in a page-by-page manner. This is known as Pagination and you can learn more about it here. Pagination saves our systems from getting overwhelmed from importing large amounts of data in a single call.

A paginated query runs like a loop in the template. It fetches a page of records and runs all its child steps one by one. It keeps fetching the data until all the pages are exhausted. The query step usually takes longer to complete than other steps as it is fetching a large number of records from another app.

To use the Query step, create a new template or open an already created template. Add a new step through the Add Step button as shown below.

Whenever we need to run a query at the time of the integration creation, we add it in the Setup App step. The Setup App step runs all its child steps once when the user sets up the integration. So before the query step, you need to add the setup step from the list of steps as shown below.

After adding the setup step, you can add the Query step as its child.

Adding a setup step in the template and adding the query step as its child will look like this:

You can select any app that you want to import records from. For our running example, you need to import subscribers from MailChimp to Sendinblue. So you can select the MailChimp app here. After selecting the app, you will have to select from the queries that are created within that app. You will select a query that imports subscribers from a MailChimp list. Details about creating queries in an app can be found here

You will then have to provide a few basic details for your query and configure any fields that will get you input from the user at the time of integration.

In the example below, the activity field will ask the user to select a list from his MailChimp account from where he wants the subscribers to be imported.

After the query step that imports subscribers, you can add the action step in the template that creates a contact in Sendinblue. This step will keep creating the contacts that are imported in pages by the query until all the pages are exhausted and all the contacts are imported from MailChimp to Sendinblue. This complete loop of initial importing through a query will look similar to what is shown below.

Learn more how pagination works and how a query endpoint is created. More information about using loops in a template can be found here.

Details about creating a query activity type in the Integry App Creator are discussed here.

Did this answer your question?