Contents
This topic describes how to run the sample applications for the TIBCO StreamBase® Slack Adapters.
The samples, Slack.sbapp
, SlackBot.sbapp
and SlackRTMInputAdapter.sbapp
, demonstrate how to use Slack Client Adapter to chat and interact with Slack channels. They also demonstrate how to use shared
Slack Real Time Messaging Input Adapter to subscribe to certain events and send real-time messages.
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select
> . -
Enter
Slack
to narrow the list of options. -
Select Slack Adapter from the StreamBase Standard Adapters category.
-
Click
.
StreamBase Studio creates a single project for the Slack adapter samples in your current Studio workspace.
You must create a Slack application ("Slack app") and obtain a user access token in order to run this sample. Log into https://api.slack.com/apps and perform the following steps (as written, the steps are current as of 10.6.0):
-
Click
, assign a name to your app, and select the workspace where you want to set the app. -
Add User Token Scopes: channels:write, im:read, mpim:read, groups:read, groups:write, im:write, mpim:write, channels:read.
-
Then click Install App to Workspace from the StreamBase Standard Adapters category.
-
Look for your generated OAuth Access Token.
To get a Bot User OAuth Access Token, go to the Bot Users tab to add a bot to your Slack app.
Run this sample in Studio as follows:
-
In the Project Explorer view, open this sample's folder.
Keep an eye on the bottom right status bar of the Studio window. Make sure any
Updating
,Downloading
,Building
, orRebuild project
messages finish before you proceed. -
Open the
src/main/eventflow/
folder.packageName
-
Double-click to open the
Slack.sbapp
application. -
From the Operator Properties tab, enter the generated OAuth token that starts with
xoxp-
. -
Make sure the application is the currently active tab in the EventFlow Editor, then click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Manual Input view, enter
createchannel
to command,testchannel
to channelName, and then click . -
In the Output Stream view, look for status of successfully created a new channel. Make sure your OAuth scope has channels:write.
-
In the Manual input, enter
sendmemessage
to command,testmessage
to text,test message
to chat.sendMeMesssage.text, then click . -
In the Output Stream view, look for status of successfully sent message. Make sure your OAuth scope contains chat:write:user.
-
Explore other commands.
-
When done, press F9 or click the Stop Running Application button.
Run this sample in Studio as follows:
-
In the Project Explorer view, open this sample's folder.
Keep an eye on the bottom right status bar of the Studio window. Make sure any
Updating
,Downloading
,Building
, orRebuild project
messages finish before you proceed. -
Open the
src/main/eventflow/
folder.packageName
-
Double-click to open the
SlackBot.sbapp
application. -
From the Operator Properties tab, enter the generated OAuth token that starts with
xoxp-
. -
From the Events Properties tab, make sure Message Event, UserTyping Event, and ChannelJoined Event are selected.
-
Make sure the application is the currently active tab in the EventFlow Editor, then click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In your Slack workspace, start typing in any channel. Look for your bot replying to the message.
-
Try join a channel, expecting a welcome message from your bot. Make sure your OAuth scope has chat:write:bot.
-
In the Output Stream view, look for status of all events you have selected.
-
When done, press F9 or click the Stop Running Application button.
Run this sample in Studio as follows:
-
In the Project Explorer view, open this sample's folder.
Keep an eye on the bottom right status bar of the Studio window. Make sure any
Updating
,Downloading
,Building
, orRebuild project
messages finish before you proceed. -
Open the
src/main/eventflow/
folder.packageName
-
Double-click to open the
SlackRTMInputAdapter.sbapp
application. -
From the Operator Properties tab, enter the generated OAuth token that starts with
xoxp-
. -
From the Events Properties tab, make sure Message Event, UserTyping Event and ChannelJoined Event are selected.
-
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Output Stream view, look for status and data output for all of your selected events.
-
When done, press F9 or click the Stop Running Application button.
Use the control port to send action commands to the adapter. Tuples enqueued on this port will connect or disconnect the adapter, as well as change the OAuth value at runtime.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Important
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
studio-workspace
/sample_adapter_embedded_Slack
See Default Installation Directories for the default location of studio-workspace
on your system.
streambase-install-dir
/sample/adapter/embedded/Slack