This IntegrationIntegration - An integration is the place the you write your code to get things done! Written in NodeJS, an integration runs in Fusebit's secure and scalable environment to translate between the needs of your backend application and the remote service or services you're connecting to. allows full access to the Slack Web API for cloud-hosted instances from your application. Fusebit's multi-tenant approach makes it easy for you to manage multiple Slack connections on behalf of your app's users. Our Node.js-based programming model and lightweight deployment story make it easy to customize the Integration with any necessary business logic.

Getting Started

  1. Use the Fusebit Management PortalFusebit Management Portal - The Fusebit Management Portal enables you to easily setup and manage all your integrations in one place. Link: to create an account and log in.
  2. Create a new Integration using one of our Slack templates
  1. You will then be able to run the Integration, download it's code, modify it, and deploy your changes. Detailed instructions on how to get started with an Integration are available here.

Invoking the Slack API

The Integration template comes pre-configured with some example calls that invoke Slack's API, for example:

const result = await{
  text: 'Hello world from Fusebit!',
  channel: 'demo',

The slackClient object provided by Fusebit is an instance of the @slack/web-api npm package. The full reference documentation for the package is available here.

Fusebit ensures the above SDK object is already bootstrapped with the Slack credentials of the user invoking the integration. You do not need to worry about obtaining an access token or refresh token -- Fusebit does that for you automatically.

Creating your own Slack App

Out of the box, Fusebit's Slack Integration uses our own demonstration application in the Slack App Directory. This is to make it easier to get started, however you will likely need to register your own Slack App in case:

  • the Slack method you are executing via the SDK requires more advanced permissions
  • you want to receive inbound messages via the Slack Events API
  • you want to deploy your Integration in production and you want end-users to see your own branding instead of Fusebit branding

To create your own Slack App:

  1. Go to and create an App "from scratch". Pick your company workspace for development, the app will be installed on your customer workspaces once it has been set up.
  1. Note the Client ID and Client Secret shown on the next screen.
  1. If the method(s) you want to invoke against the Slack API require certain permissions see here, add the appropriate scopes under Features > OAuth & Permissions > Scopes > Bot Token Scopes.

The following permissions are necessary to run the example provided later: channels:join, channels:read, chat:write, users:read.

  1. Back in the Fusebit Portal, find the Integration you would like to connect to the new Slack App you just created. Select the ConnectorConnector - A connector is the package from Fusebit that manages the relationship between one or more integrations and a specific service. One of the most common types of connector is an OAuth connector, which takes care of the OAuth negotiation between your customers and the service you're integrating, so that you don't have to! tied to that integration


If more than one Integration is linked to that same Connector, they will all use the new Slack App you are about to configure.

  1. Select Enable Production Credentials in the Connector Configuration and then paste in the Client ID and Client Secret you obtained earlier from the Slack App you created. Also, list the permissions your code requires in the Bot Token Scopes field. To use the example provided later in this guide, specify the following scopes: channels:join channels:read chat:write users:read.


When switching a Connector to a different Slack App, all IdentityIdentity - An identity is a unique relationship one of your customers has with a service. An identity can be used by multiple integrations to act on that service on behalf of your customer. objects associated with that Connector will be deleted. Your users will need to re-authenticate against Slack after you make the change.

  1. Navigate back to your Slack App and over to Features > OAuth & Permissions > Redirect URLs and paste the URL provided by Fusebit in the Slack Configuration section under OAuth2 Redirect URL


Good Job!

Any time a new user installs your Integration, you should now see your Slack App information displayed during the authorization step.

Also, now that you've configured your own app, you can also leverage our Webhooks SDK to receive events from Slack!

Receiving events from Slack (Event API support)

With this Slack App configuration, your Fusebit Integration will be able to post messages as a bot (or on behalf of users if you configured that functionality). But you will likely also want to get notified when users respond to your messages OR when they post certain keywords or commands. We can achieve that by configuring Slack’s Event API and connecting it to Fusebit

  1. Make sure you are using your own Slack App and have configured your Connector with that app's secrets
  2. In your Connector, paste the Signing Secret you find under App Credentials in your Slack App

In your Connector, note the Events API Request URL as you will need it in the next step. Go to the bottom of the page and click save

  1. In your Slack App configuration, go to Features > Event Subscriptions:
    1. Toggle Enable Events
    2. In the Request URL field, paste the URL you copied from Fusebit in the previous step
  1. You need to decide what event types you would like to listen to, and ensure your app is registered for those events and has requested the relevant scopes. In this example, we will subscribe to the message.channels Bot User event which requires the channels:history scope.
    1. In Features > Event Subscriptions under Subscribe to bot events (or Subscribe to events on behalf of users) add the event type message.channels
    2. In Features > OAuth & Permissions > Scopes > Bot Token Scopes, add channels:history
    3. In your Connector, make sure you add the channels:history scope in the Bot User Token Scopes field.

Once you have configured Slack Events API support in your Connector, you can receive events in your Integration. The Connector will route all events from the workspace (team) that your Integration was authorized for when it was created.

  1. Depending on the permissions you requested, your Bot User may need to be a member of a channel to receive events for activity in that channel. In this example, given the message.channels event type we subscribed to and the associated channels:history permission we requested, you need to add the bot to the channel. You can do that by going to the channel details and selecting More > Add apps
  1. At the bottom of integration.js edit the following handler, which will echo any messages sent to the channel.
integration.event.on('/:componentName/webhook/event_callback', async (ctx) => {
  const slackClient = await integration.service.getSdk(ctx, ctx.params.componentName, ctx.req.body.installIds[0]);
  const messagingUser =;
  const authorizedListeningUser =[0].user_id;

  // Don't echo our bot's own messages
  if (messagingUser !== authorizedListeningUser) {
    const text =;{
      text: `User <@${messagingUser}> sent message: \n\n "${text}"`,
  1. Type in a message in the channel where the bot was added, you should see your message echoed back in the channel.

Handling Slash Commands

In addition to leveraging your app to respond to keywords in Slack Channel, you can also leverage Fusebit's Event handler to respond to interactivity items such as Slash Commands.

There are two main components to handling interactivity:

  • Acknowledgement Response: Must happen within 3000 ms or the user will get a timeout
  • Message Response: Can take longer and must be targeted back to the original Slack Message

Both of these must be defined in an Integration based on the unique needs of your Slack App.

Configure your Connector

First, in Fusebit, update your ConnectorConnector - A connector is the package from Fusebit that manages the relationship between one or more integrations and a specific service. One of the most common types of connector is an OAuth connector, which takes care of the OAuth negotiation between your customers and the service you're integrating, so that you don't have to! configurations:

  1. Update the Bot Token Scope to include commands
  2. Define an Integration ID that will be used to handle both the Acknowledgment & Message Responses
Slack Connector Configuration to handle InteractivitySlack Connector Configuration to handle Interactivity

Slack Connector Configuration to handle Interactivity

Next, in the Slack App Dashboard, update your Slack App as well:

  1. In the dashboard for your app, navigate to Features > OAuth & Permissions > Scopes and add the commands OAuth scope.
Slack App Dashboard - OAuth ScopesSlack App Dashboard - OAuth Scopes

Slack App Dashboard - OAuth Scopes

For your app, you will also have to enable "Slash Commands" from this dashboard and also configure the actual commands you want to make available to your users. It's fairly straightforward to do, but you you can also follow along this guide from Slack.

Set up your Integration

The Integration ID you defined in your Connector will be responsible for Acknowledgement & Message Responses.


Fusebit Code Snippets

Instead of copying and pasting, you can leverage Fusebit's Code Snippets feature from the editor to add the code samples below directly to your integration.

Acknowledgement Responses

Slack requires all incoming interactivity requests to receive an HTTP 200 Acknowledgement within 3000 ms, it also allows you to customize a message that will be displayed to the user.

Fusebit takes care of this for you, but you must define the following endpoint in your integration.

// Acknolwedgement Response'/api/fusebit/webhook/event/immediate-response', async (ctx) => {
  const { command } = ctx.req.body;
  ctx.body = {
    text: `:hourglass_flowing_sand: Command received ${command}, Thinking!`,
    response_type: 'ephemeral',


Acknowledgement Responses Timeout

While you can customize the message sent back in Acknowledgement Responses, it is highly recommended you respond back with static text such as 'Looking into this' or 'Command Received!'. If the response takes longer than 3000ms, the Slack user will receive a 'timeout' response and the interactivity will fail.

Message Responses

In addition to the static immediate 'Acknowledgement' Response, you will want to respond to the message with contextual data based on what the User has requested.

For all Slash Commands, the incoming request body will consist of two items:

  • Slack Interactions Payload under the data object.
  • Fusebit Event Metadata which includes items such as related Integration ID, related Installation IDs etc.
  data: {
    token: 'LVGaG1ijm6mcT4ZdxJ8MawUz',
    team_id: 'T02A14HFYDP',
    team_domain: 'shehzadakbar',
    channel_id: 'D03FRNN3U93',
    channel_name: 'directmessage',
    user_id: 'U03FN160NLE',
    user_name: 'shehzad037',
    command: '/fusebot',
    text: '',
    api_app_id: 'A03FCRX58P2',
    is_enterprise_install: 'false',
    response_url: '',
    trigger_id: '3570274972370.2341153542465.fbcced0ce22255e0ea000b692493b143'
  eventType: 'slash-command/shehzad',
  entityId: 'SlashCommandsDocs',
  webhookEventId: 'webhook/SlashCommandsDocs/T02A14HFYDP/A03FCRX58P2',
  webhookAuthId: 'T02A14HFYDP/A03FCRX58P2',
  installIds: [

To respond back to the message, you can leverage the Fusebit's Event Handler to receive and respond back to the message:

// Add this to the top of your integration
const { IncomingWebhook } = require('@slack/webhook');

// Message Response
integration.event.on('/:componentName/webhook/slash-command/:slashCommand', async (ctx) => {
  const webhook = new IncomingWebhook(;
  await webhook.send({text: 'Ask and you shall receive!'});


Add @slack/webhook dependency

In order to respond back to incoming events with a message response, your integration requires the @slack/webhook package. Fusebit's Integration Programming model allows you to add any npm package you need directly into your integration.

To add @slack/webhook to your Slack integration:

  • In your package.json' file, add "@slack/webhook": "^6.1.0"` under dependencies.
  • In your integration.js file, add const { IncomingWebhook } = require('@slack/webhook');


Slash Commands Enabled!

Congratulations, now your Fusebit Integration can handle Slash Commands on your behalf.

Did this page help you?