The functionality described in this article is available in XRay versions 1.5 and greater.
XRay Slack integration offers the following benefits:
- Create alerts that send Slack messages to individual users or channels based on specific criteria.
- Send queries directly from the XRay user interface.
- Send a link to any viewlet (even shared viewlets) directly from the XRay user interface.
Jump ahead |
Step 1. Create a Slack application
The first step to setting up Slack integration in XRay is to create an application in Slack. Creating and configuring an application in Slack allows XRay to interact with Slack. You can do this from a browser or through a desktop client.
- On the Slack website, begin the process of creating an app.
- Log into Slack.
- Go to https://slack.com/apps.
- Click (in the upper-right corner).
- Click Create an App.
- On the Create an app dialog, select From Scratch >.
- Enter an App Name. For future reference, make sure the name indicates that the app is for XRay.
- If applicable, specify a workspace.
- Click Create App.
- Set up permissions for the app.
- In the left panel, under Features, select OAuth & Permissions.
- In the Scopes section, under Bot Token Scopes, click Add an OAuth Scope.
- Add the following permissions. As you type, suggested permissions will be listed for you to choose from.
- team:read
- channels:read
- users:read
- profile:read
- users:read.email
- chat:write
- Add Redirect URLs.
- In the Redirect URLs section, provide the address of the XRay site in the format <host>/xray/SlackProviderServlet. At a minimum, the address you provide must include the entire URL up to and including the /xray/ subdirectory. For example:
https://xraytest.nastel.com/xray/SlackProviderServlet. - Click Add.
- Click Save URLs.
- In the Redirect URLs section, provide the address of the XRay site in the format <host>/xray/SlackProviderServlet. At a minimum, the address you provide must include the entire URL up to and including the /xray/ subdirectory. For example:
- The Client ID and Client Secret are generated by Slack and are needed to add the Slack application to XRay. Go to the Basic Information section in the left pane and make note of these two values. Click Show to view the value in text form so you can copy it for use in XRay setup.
Step 2. Set up Slack as a Provider in XRay
Before performing step 2, complete the following prerequisite steps to configure Slack as an XRay external data source:
1. Load config-slack.xml from the jkool-dbapi/jkool-dbapi-solr-1.5.X/config/ext-data-src folder.
2. Restart the CEP server and Tomcat.
Now you’ll use the Client ID and Client Secret values from Step 1 to add Slack as a Provider in XRay.
- From Main Menu > Admin Settings >Providers, select Slack.
- Click Create.
- Enter the Client ID and the Client Secret that were generated when you created the Slack app in Step 1.
- Click Submit. The Slack web page displays a prompt that asks you to allow the app to access the workspace.
- Click Allow. You are returned to the XRay interface.
Step 3. Set up XRay Actions for Slack
By setting up an XRay Slack action, you lay the framework for messages to be sent to users or channels (groups of users). Slack actions send Slack messages; email actions send emails. (To learn how to set up an email Provider, see Setting up an Email Provider.) In Step 4, you’ll associate these actions with alerts so that messages are sent in certain cases.
Slack Actions
A Slack action sends a message to a Slack users, Slack channels, or both. Messages can include text, variables, or both.
To create an action:
- From Main Menu > Admin Settings > Actions, select Slack.
- Click Create.
- Enter an Action Name.
- Select the Provider Name. Users and channels are made available based on the provider you select.
- Enter users, channels, or both.
- Enter one or more Users in the field provided.
- Enter one or more Channels in the field provided.
You can remove a user or channel at any time by clicking the X on the user or channel you want to remove.
- Enter a Message. For more information about creating and formatting messages, see Templates and Message Formatting.
- To verify that messages can be sent through the provider, click Test. XRay displays a confirmation message to inform you that the Slack message was sent successfully.
- Check the user account or channel to ensure that a test message has arrived.
- Click Save.
Step 4: Create Alerts to Trigger XRay Actions
Alerts inform individuals or groups about specific scenarios.
You can create an alert that is based on a set of objectives. Alerts are associated with actions, which send an email or a Slack message based on the defined objectives.
Follow the instructions for creating an alert in Alerts. At the Actions stage, select the Slack action you want to associate with the alert.
Send Queries and Links from Viewlets to Slack
You can send queries and links directly to Slack from the XRay user interface.
Send Queries to Slack
To send queries to Slack as described here, you must have a Slack action named "QueryToSlack". For suggested message templates, see Templates and Message Formatting.
From a viewlet, you can send a query to Slack.
- Click the Slack icon in the viewlet tool bar.
- Select Send query to Slack.
XRay displays a confirmation message when the message is sent.
- Click OK.
A Slack message has been sent with the query.
Send Links to Slack
To send links to Slack as described here, you must have a Slack action named "LinkToSlack". For suggested message templates, see Templates and Message Formatting.
You can send a link to any viewlet, including shared viewlets, to Slack.
- Click the Slack icon in the viewlet tool bar.
- Select Send link to Slack.