You can use Sequin to build DronaHQ apps on top of APIs like Salesforce and HubSpot. Sequin will sync your API data to a Postgres database so you can write your integration in SQL. Changes you make to your database records will be applied to the API and your database at the same time.

While DronaHQ has connectors for some APIs, it’s much faster to build with DronaHQ’s Postgres adapter and Sequin. You don’t have to worry about rate limits and SQL is both familiar and expressive.

Setup a Sequin sync

Before you can use Sequin with DronaHQ, you’ll need to create a sync. Sequin will guide you through authenticating, selecting the data you want to sync, and connecting to your database. Read our getting started guide for step-by-step instructions.

Create a DronaHQ Resource

A connector in DronaHQ is a connection to a resource like Postgres.

Sequin uses a Postgres Proxy to interface with your Sequin-synced tables. The Proxy lets Sequin capture inserts, updates, and deletes you make in your database and commit them to the API.

To add Sequin’s Postgres Proxy as a DronaHQ connector, you can treat it as a regular Postgres resource and enter the connection details in the connector configuration:

Step 1: Go to your DronaHQ dashboard, click “Connectors” on the left rail, then click ”+ Add Connector.”

Step 2: Select PostgreSQL from the list.

Step 3: This opens up a new configuration page. Give it a name and paste in the connection string from the Connection instructions tab of your Sequin dashboard.

You can use the connection instructions to connect your service to Sequin.

Step 4: Under “Connection Options”, be sure two options are enabled: “Enable converting queries to prepared statements” and “Connect using SSL.” These two options will ensure your queries to the database are efficient and encrypted.

Step 4: After testing the connection, click “Save.”

Using the Postgres connection in DronaHQ

Now, Sequin is syncing your API data to Postgres. You’ve also connected DronaHQ to Postgres via Sequin’s Proxy. To query this data in your DronaHQ app, go back to your DronaHQ dashboard and select your app:

Step 1: From the DronaHQ dashboard, click “Apps” then open your app.

Step 2: Click on “Data Queries” on the left rail (the database icon). Click ”+ New” then “Connector Query” in the bottom drawer.

Step 3: Select the Sequin Postgres Proxy connection as the connector.

Step 4: Compose your query. The schema for your Sequin-synced tables is available on the right rail.

Step 5: Click “Test” in the top right to make sure your query runs as expected.

Here’s an example Salesforce query that finds all the Salesforce Contacts belonging to a given account:

select * from salesforce.contact
-- use a query variable, {{account_id}}
where account_id = '{{account_id}}'
limit 100;

Writing back to the API

With Sequin, you can also make mutations via your database as well. Inserts, updates, and deletes you make to Sequin-synced tables are first applied to the API. If they pass validation, they’re committed to your database.

In DronaHQ, you can use custom-built or auto-generated forms to insert or update data in your Sequin-synced tables. You can generate a form by finding “Controls” on the left rail, then selecting “SQL form.”

Next, you’ll connect the “Submit” button of your form to a database mutation:

Step 1: Select the “Submit” button and click “Actions” (the lightning bolt icon). Click on the event button_click.

Step 2: Click the ”+” icon to add a new actin. Then click “Server-side actions” and select your Sequin Postgres Proxy connection.

Step 3: Click ”+ Add Query.”

You can compose an insert query by populating values with various input fields in your application. For example, if you have a form with inputs named first_name, last_name, and email, the corresponding insert query would look like this:

insert into salesforce.contact (first_name, last_name, email)
values ('{{first_name}}', '{{last_name}}', '{{email}}');

You can find the available variables for your application under the “Use Keywords” drop-down.

Configuring an insert query in the DronaHQ interface.

Once you’ve configured the query trigged when clicking the “Submit” button, you can then save the success or failure responses from this query in variables and use them later in the workflow:

Configuring the insert query to bind success and failure responses to variables

Errors

When Sequin’s Proxy encounters an error trying to apply your mutation in the upstream API, the Proxy returns a standard Postgres error. You can configure your app to display this as an alert notification.

Step 1: Back in the button_click action workflow editor, click the ”+” icon underneath “Error.”

Step 2: Select an “On-Screen Action” such as “Toast,” which you can use to display an error message to the user. In the “Message” field, you can render the error result from the insert data query. (Be sure to bind insert errors to variables, as described in the previous section.)

Here’s an example of configuring a “Toast” to display an insert error:

Configuring a Toast to display when there is an insert error

Now, if a user attempts to perform an insert and it fails, they’ll see the validation error that was returned by Salesforce.

Next steps

You can now use DronaHQ to build on top of sources like Salesforce, Airtable, and HubSpot. If you have any questions, please reach out to us.

Was this page helpful?