Table of contents
This node.js example connector allows you to make your Teneo bot available on Slack. The connector acts as middleware between Slack and Teneo and uses the Slack Events API to receive messages from Slack. This guide will take you through the steps of creating a new Slack app and deploying the connector to respond to events sent by Slack.
You can find the source code of this connector on
The Slack Events API requires that the connector is available via https. On this page we will be using Heroku to host this connector, for which a (free) Heroku account is needed. You can however also manually install the connector on a location of your choice, see
Running the connector locally. Teneo Engine
Your bot needs to be published and you need to know the engine url.
You will need a Slack account with permission to add apps to your workspace.
Create a Slack app
Create a new Slack app here:
https://api.slack.com/apps. Give it a name and add it to the appropriate workspace. On the page that appears, scroll to the bottom of the screen and copy the
Signing Secret. You will need it later when you deploy the connector. Add bot user to your Slack app
In the left navigation menu under 'Features' choose 'Bot Users'
Give your bot a name and a username. This is how your bot will appear in Slack.
You might also want to turn on 'Always Show My Bot as Online'.
Install App to Workspace
Under 'Settings' in the left navigation menu, select 'Install App'.
Then, select 'Install App to Workspace' and authorize.
Copy the second field:
Bot User OAuth Access Token (it should start with xoxb), you will need it in the next step when you deploy the connector. Deploy the connector
Click the button below to deploy the connector to Heroku:
Give the app a name (lowercase, no spaces)
In the 'Config Vars' section, add the following:
SLACK_SIGNING_SECRET: The 'Signing Secret' you copied when you created the Slack app.
SLACK_BOT_USER_OAUTH_ACCESS_TOKEN: The 'Bot User OAuth Access Token' you copied when you installed the app to your workspace.
TENEO_ENGINE_URL: The engine url. Click 'Deploy app'.
When Heroku has finished deploying, click 'View app' and copy the url of your Heroku app, you will need it in the next step.
Subscribe to events
Go back to your app on Slack. In the left navigation menu under 'Features' choose 'Event Subscriptions'. Then:
In the left navigation menu under 'Features' choose 'Event Subscriptions'.
Turn on Enable Events.
Enter the following URL in the Request URL field:
https://[yourherokuappname].herokuapp.com/slack/events (replace [yourherokuappname] with the name of your app on Heroku).
Under 'Subscribe to Bot Events', subscribe to the following event:
message.im. Save changes.
That's it! Your bot should now be available in Slack and responding to messages that are sent to it. 🕺
Test your bot
Open the Slack app or visit
slack.com in your browser and go to the workspace in which you added your bot.
In the navigaton on the left, click on the plus sign next to Direct Messages.
Search for the name of your bot, select it and click 'Go'.
Adding message attachments
message attachments, this connector looks for an output parameter slack in the engine response. The value of that parameter is assumed to contain the attachement JSON as defined by Slack.
If we look at Slack's JSON specification of
attachments, to attach an image the value of the slack output parameter would need to look like this:
"fallback": "Image description as fallback",
Note: although it is possible to add multiple attachments to a Slack message, this connector assumes the output parameter contains just the JSON for a single attachment.
For more details on how to populate output parameters in Teneo, please see:
How to populate output parameters in the Build your bot section. Running the connector locally
If you prefer to manually install this connector or run it locally so you can extend it, proceed as follows:
latest release of the connector from Github Install dependencies by running
npm install in the folder where you unzipped the connector.
Make sure your connector is available via https. When running locally you can for example use ngrok:
ngrok.com. The connector runs on port 3000 by default.
ngrok http 3000
Start the connector with the following command (replacing the environment variables with the appropriate values):
SLACK_SIGNING_SECRET=<your_slack_signing_secret> SLACK_BOT_USER_OAUTH_ACCESS_TOKEN=<your_slack_bot_oauth_token> TENEO_ENGINE_URL=<your_engine_url> node server.js