Adding Multiple Connectors

If you want to create Integrations between two external apps (for example, integrating Slack and HubSpot) the Fusebit platform allows you to leverage as many connectors as you want in one Integration.

Adding a new Connector

When you create a new Integration (e.g. Slack), you will have one connector already pre-configured. In order to add another application (e.g. Hubspot) for the same Integration, you will have to add the connector to the Integration directly.

To do this, click on Add New and select the connector for the application you want to add to your Integration.

Referencing the Connector in your Integration

Once you've selected this Connector, Fusebit will automatically update the configuration of your Integration so that you can easily reference it in your code.

In your Integration configuration, take note of the connector name as you will need to reference this in your integrations.js file. In the example below, we are retrieving the number of contacts in HubSpot and posting a message through Slack with that information.

//Define your Connectors
const slackConnectorName = 'slackConnector';
const hubspotConnectorName = 'Hubspot-Connector';

router.post('/api/tenant/:tenantId/contacts', integration.middleware.authorizeUser('install:get'), async (ctx) => {
 //Reference your Connectors
  const slackClient = await integration.tenant.getSdkByTenant(ctx, slackConnectorName, ctx.params.tenantId);
  const hubspotClient = await integration.tenant.getSdkByTenant(ctx, hubspotConnectorName, ctx.params.tenantId);

  // Get the contacts in HubSpot
  const contacts = await hubspotClient.crm.contacts.getAll();
  
  // Get the Slack user ID associated with your tenant
  const slackUserId = slackClient.fusebit.credentials.authed_user.id;
  
  // Send a Direct Message to the Slack user
  const result = await slackClient.chat.postMessage({
    text: `You have ${contacts.length} Contacts in HubSpot`,
    channel: slackUserId,
  });
  
 
  ctx.body = result;
});

πŸ‘

Done

Now you should be able to build out a single Integration that works with multiple applications at once!


Did this page help you?