You can use either of two methods to deploy your workspace to a Slack app:
-
Use the Conversation tool if you want to quickly deploy your app with just a few clicks.
-
Use manual deployment if you want to deploy your app by modifying configuration files and running scripts. You might want to use this method if you are customizing the Conversation connector, or if you need to repair or update components of an existing deployment.
Note: This process is intended to connect an existing Watson Conversation workspace to a Slack app. If you have not yet built a workspace, you must do so first. For more information, see the Conversation documentation.
Note: The manual deployment process is supported only on Linux/UNIX and macOS systems.
-
Clone or download this GitHub repository to your local file system.
-
If you have not done so already, install the following prerequisite software:
- The Cloud Foundry command-line interface
- The Node.js runtime, including the npm package manager
-
Log in using the following command:
cf login -a https://api.ng.bluemix.net/
Select the Bluemix organization and space where you want to deploy.
Note: Currently, only the US South region is supported.
-
Go to https://console.ng.bluemix.net/openwhisk/learn/cli and then do the following:
-
Click the account information in the upper right corner, and confirm that the organization and space shown are correct.
-
Scroll down and click on Looking for the wsk CLI??
-
If you have not done so already, follow the instructions to install the wsk CLI.
-
Copy the command in step 2 ("Target a Region and Namespace"), and run it in your CLI.
-
-
Go to https://slack.com and make sure you are signed in to the Slack workspace where you want to deploy your bot.
-
Go to https://api.slack.com/apps/. Sign in with your Slack credentials if necessary.
-
Click Create an App.
-
Specify an app name, select a development Slack workspace, and then click Create App.
Note: If you have already created the app you want to use, select it from the Your Apps list.
-
In the navigation menu, click Bot Users.
-
On the Bot User page, click Add a Bot User. Verify the display name and bot username, and then toggle Always Show My Bot as Online to On. Click Add Bot User and then Save Changes.
-
Click Event Subscriptions. Toggle the Enable Events switch to On.
-
Scroll down to Subscribe to Bot Events and click Add Bot User Event. You must select at least one event. For most bots, the following events are good choices:
message.im
message.channels
message.mpim
message.groups
Click Save Changes.
-
Click Basic Information and scroll down to App Credentials.
-
In the root directory of your local copy of the repository, edit the
providers.json
file. -
On the Slack page, copy the client ID, client secret, and verification token, and paste them into the corresponding fields in the
slack
object in theproviders.json
file. -
In
providers.json
, make sure the channelname
is set toslack
. -
In
providers.json
, edit the pipelinename
to specify a name for your deployment. This name will help you find your Cloud Functions assets later. Only alphanumeric characters (A-Z and 0-9) are kept. -
In
providers.json
, edit theconversation
object to specify the username, password, and workspace ID of the workspace you are deploying. Save the changes to the file. -
Run
npm install
. -
Run
./setup.sh
. This creates the required Cloud Functions packages in your Cloud Functions space.Note: If you are not already signed in to your Slack workspace, you will be redirected to the sign-in page so you can enter your Slack workspace credentials. If this happens, you must run the
setup.sh
script again after you sign in. -
When the script pauses, copy the generated Slack redirect URL from the terminal window (look for a message that begins
Your Slack Redirect URL is:
. Leave the script paused for now. -
In the Slack app settings in your browser, click OAuth & Permissions.
-
Under Redirect URLs, click Add a new Redirect URL, and paste in the redirect URL you copied from the terminal window. Click Save URLs.
-
Go back to the terminal window and copy the request URL (look for a message that begins
Your Request URL is:
). If you need to find the endpoint URL later, follow these steps:-
Under My Actions, click <pipeline_name>_slack/receive>.
-
Click View Action Details.
-
Confirm that Enable as Web Action is selected. Copy the URL from the Web Action URL.
-
In the Slack app settings, click Event Subscriptions.
-
Under Enable Events, paste in the request URL you copied from the terminal window. Toggle the switch at the top to On. After Slack has verified the URL, click Save Changes.
-
Optional: If you want to enable interactive components, click Interactive Components, and then click Enable Interactive Components. In the Request URL field, paste the same request URL you specified in the previous step, and then click Enable Interactive Components.
-
Go back to the terminal window and press Enter to resume the script.
-
When prompted in your browser, sign in to your Slack workspace and authorize the app.
That's it. You're all set. You can now go to your Slack team and talk to your bot!