Custom Integrations

Fusebit helps developers build flexible, code-first integrations. Using Fusebit, you can create custom automations and integrations with just a few lines of code, with all the boring stuff taken care of for you:

  • Automate a task for yourself or your team. You can solve your own automation challenges, like sending an SMS at 2 am to the developer on your team who broke the build, or a daily report from Salesforce to your sales team.
  • Integrations for your app. You can add integrations to your multi-tenant application for the benefit of your users, for example, to notify them by Slack or email when their order has shipped.

Once deployed, Fusebit integrations are managed by us and can be invoked with an HTTP call from your application, a webhook call from the system you are integrating with, or on a schedule you define.

Let's go!

Create Custom Integration

There are two ways to create a custom automation or integration in Fusebit: using a Maker Link or with the empty, Custom integration template from the integration gallery.

Using a Maker Link

You could have come across a Maker Link on Twitter, in a blog post, in a gist, or one may have been sent to you by a friend who really likes you. If you don't have a Maker Link already, here is one that creates a Slack+HubSpot integration you can experiment with:

https://manage.fusebit.io/make/slack-send-message+hubspot-crud-companies

When you open a Maker Link in a browser, a new custom integration will be scaffolded for you in Fusebit:

27202720

Fusebit Maker Link

If you don't have an account with Fusebit yet, a free account will be created for you automatically so that you can securely save your work.

Now move on to Implement Custom Integration to write the few lines of code that will add your custom integration logic.

Using Integration Gallery

Another way of creating a custom integration with Fusebit is to use the gallery of integration templates. First, create a new, empty integration using the Custom integration template. Next, select the set of target systems and the operations you want to perform on them by Adding Snippets. Once your integration is configured to communicate with the target systems you selected, you can move on to Implement Custom Integration to write the few lines of code that will add your custom integration logic.

Implement Custom Integration

Fusebit comes with an embedded web editor to allow you to edit your integration logic without installing any tools. (You can also use a CLI if you prefer local development or want to Set up CI/CD).

27202720

Fusebit Editor

Fusebit Platform brokers all communication between the target systems you want to integrate or between your application and the target systems. Fusebit integration logic can be executed by making an HTTP call from you app, in response to a webhook invocation from a target system, or on a schedule you define. You can go to Integration Programming Model to read more about how these scenarios are represented in the programming model.

The custom integration scaffolded by Using Maker Link or Using Integration Gallery specifies two entry points to your integration logic. One is the place you can write code that will execute when the integration receives a matching HTTP request. The other allows you to implement logic that will run on a schedule you define.

integration.router.post('/api/tenant/:tenantId/test', async (ctx) => {
  // TODO Implement HTTP-triggered integration logic here
  // ...
});

integration.cron.on('/cron', async (ctx) => {
  // TODO Implement CRON-triggered integration logic here
  // ...
});

The integration.js file that implements your integration logic also contains a number of Snippets that were either pre-selected for you when Using Maker Link or added by you when Using Integration Gallery. In case of the Slack+HubSpot integration example, these may look like this:

async function slackSendMessage(ctx, message, channel) {
  // ...
}

async function hubspotGetCompanies(ctx) {
  // ...
}

You can add more snippets at any time depending on your integration needs - see Adding Snippets.

Implementing your integration logic requires you to write your custom logic within one of the supplied entry points to the integration, likely using the helper functions implemented by Snippets. For example, to send a message to Slack that reports on the current number of companies that exist in your HubSpot instance, you would write the following code:

integration.router.post('/api/tenant/:tenantId/test', async (ctx) => {
  const companies = await hubspotGetCompanies(ctx);
  await slackSendMessage(ctx, `Total number of companies in HubSpot: ${companies.length}`);
  ctx.body = { result: 'success' };
});

The code above, wrapped in a KoaJs router, will execute in response to an explicit HTTP call. Such a call is normally issued from within your own application, but can also be simulated from within the Fusebit Editor for testing purposes.

Time to run your first integration!

Execute Custom Integration

Before a Fusebit integration can be executed, it must obtain authorization to the target systems you want to connect to, for example Slack and HubSpot:

  • Automation for your team. When you are creating an automation for yourself or your team, it is often convenient for you to authorize access to the target systems. The simplest way to do it is Using Fusebit Editor. This is also what you would do when testing integrations meant to be added to your multi-tenant application.
  • Integrations for your app. When you are creating an integration for you multi-tenant application for the benefit of your users, you will normally ask your users to authorize access to their instance of the target systems, for example their Slack workspace or their HubSpot account. Fusebit helps you with the authorization process on behalf of your users and subsequently management of their credentials - read Connecting Fusebit with Your Application to learn more.

Regardless whether you are implementing an integration for yourself or for the users of your app, the simplest way to run your integration logic is by Using Fusebit Editor.

Using Fusebit Editor

The Fusebit Editor supports an integration runner that can issue a test HTTP request to your integration and display the results. Before the request is made, if your integration requires an authorization to any of the target systems it connects with, you will be taken though the authorization process (you can read more in Run the Integration):

27202720

Authorizing access to target systems

If you are creating an automation for you yourself or your team, the credentials collected during this authorization process are the credentials the integration will be running with once you enable its production use. If you are building an integration to be added to your multi-tenant application for the benefit of your users, these credentials are only relevant during testing. You will be taking your users through a similar authorization process to their instances of the target systems while Connecting Fusebit with Your Application.

Using HTTP

You can invoke the integration logic within your integration that is implemented as a route of a KoaJs router by issuing an HTTP request to the Fusebit integration. This is typically done on behalf of one of the users of your application when using Fusebit to add integrations to you app for the benefit of your users. For example, if you want to send a Slack notification to your user's Slack workspace when your application just shipped an order to them, you would make an HTTP call to the Fusebit integration and indicate the Tenant this call is made on behalf of. From there, Fusebit will figure our the right set of credentials to use to make the call to the target system like Slack. You can read more about calling Fusebit integrations from your app using HTTP in Connecting Fusebit with Your Application.

The Fusebit Editor which is part of the Fusebit Management Portal can also issue HTTP test requests to your integration. This method is handy during development, testing, and debugging. Read more in the previous section, Using Fusebit Editor.

Using a Schedule

You can invoke your automation or integration logic on a schedule you define. Fusebit keeps the clock and makes sure it happens on time.

To execute your integration logic on a schedule, first implement it in the scheduled handler entry point:

integration.cron.on('/cron', async (ctx) => {
  const companies = await hubspotGetCompanies(ctx);
  await slackSendMessage(ctx, `Total number of companies in HubSpot: ${companies.length}`);
});

Then, within the Configuration section under Settings in the Fusebit Editor, define the specific schedule you want this logic to be invoked on. You can specify a CRON string and the timezone.

27202720

Scheduling integration execution

You can read more on scheduling Fusebit integrations at Scheduling Jobs.

πŸ“˜

NOTE

We recommend you first test your integration logic by invoking it over HTTP by using the Fusebit Editor Run functionality before enabling it to be run on a schedule.

Using Webhooks

Your automation or integration logic can be invoked in response to a webhook request issued by one of the target systems you are integrating with. Fusebit helps you in this case by automatically registering your webhooks for you as well as mapping the webhook requests to the correct Tenant. Given the differences in webhook implementation between the target systems, this is a more advanced topic that is specific to the target system you are integrating with. See the documentation of the system you want to integrate with for details.

Adding Snippets

Fusebit is an integration platform for developers, and Snippets for common tasks help you cut to the chase by providing convenient code samples that can be meshed, combined, and modified.

You can add snippets to any Fusebit integration using the Snippets button in the Fusebit Editor. It pops up a gallery of available snippets:

27202720

Add a Snippet

Adding a snippet to your integration does two things:

  • Adds code. The snippet will append code to your integration.js that contains helpful functions to perform specific operations on the target system you chose. Adding the functions by itself does not change your integration logic. You need to use these functions from within the integration logic you implement.
  • Adds a connector. If the snippet requires the use of a new Connector your integration is not yet associated with, a new connector will be created for you automatically.

You can add as many snippets as your integration logic requires, combining any number of target systems to take part in the integration transaction.


Did this page help you?