This article provides installation, configuration, and implementation details when integrating xMatters On-Demand with Slack.
Slack is a popular cloud-based team collaboration tool.
Coupled with the power of xMatters alerts, the integration:
- Lets people know when they are needed to participate in a Slack conversation.
- Quickly identifies and notify on-call members of xMatters groups
- Allows for voice, SMS, and push messages to users.
- Allows users to reply with "Acknowledge" and "Ignore" from their device.
- Allows users to post responses back to Slack channel from their device.
Event injection is initiated when a custom "slash-command" is used in Slack to identify the xMatters groups you want to invite to a channel; for example:
Slack server builds a payload and sends it to the xMatters inbound integration URL configured in Slack's custom slash-command integration.
The integration includes the inbound integration "Inbound from Slack" that handles Slack submissions by notifying the xMatters group with the name that matches the one typed into the Slack channel.
Recipients can respond with "On my way" or "Can't make it". By default, the responses and delivery notifications are posted back to Slack channel.
NOTE: If you prefer not to receive delivery notifications, just disable the Delivery updates outbound integration.
The first step in setting up your integration is to configure xMatters.
To begin, download the communication plan (.zip file) attached to this article; it contains everything needed for this integration. You do NOT need to extract the contents - you can import it directly into xMatters.
This integration requires a user who can authenticate REST web service calls when injecting events.
This user needs to be able to work with events, but does not need to update administrative settings. While you can use the default Company Supervisor role to authenticate REST web service calls, the best method is to create a user specifically for this integration with the "REST Web Service User" role that includes the permissions and capabilities.
Note for trial users: If you are installing this integration into an xMatters trial instance, you don't need to create a new user. Instead, locate the "Integration User" sample user that was automatically configured with the REST Web Service User role when your instance was created and assign them a new password. You can then skip ahead to the next section.
To create an integration user:
- Log in to the target xMatters system.
- On the Users tab, click Add.
- Enter the appropriate information for your new user. Because this user affects how messages appear for recipients and how events are displayed in the reports and Communication Center, you may want to identify the user as specific to this integration; for example:
- First Name: Slack
- Last Name: Integration
- User ID: slack
- Assign the user to the REST Web Service User and set their password.
- Depending on your deployment, you might need to add one of the following roles so you can log in as the integration user and access the Developer tab: Full Access User, Developer or Limited Developer.
- Make a note of these details; you'll need them when configuring other parts of this integration.
- Click Save.
The integration will notify the xMatters group whose name matches the Slack channel. If the group does not exist, the xMatters event will not be created.
For more information about creating users and devices in xMatters, refer to the xMatters On-Demand help.
The next step is to import the communication plan you already downloaded. It contains all of the forms, properties, and integration details you'll need.
To import the communication plan:
- In the target xMatters system, on the Developer tab, click Import Plan.
- Click Choose File, and then locate the downloaded communication plan (.zip file).
- Click Import Plan.
- Once the communication plan has been imported, it should be automatically enabled. If it isn't click Plan Disabled to enable the plan.
- Click the Edit drop-down list for the plan, and select Access Permissions.
- Add the integration user you created above, and then click Save Changes.
- In the Edit drop-down list, select Forms.
- For the Invite to Channel form, in the drop-down list, click the Web UI, Web Service drop-down list, click Sender Permissions.
- Enter the integration user you configured above, and then click Save Changes.
You need to make sure the inbound integration is set to use URL authentication, and then retrieve the URLs to configure the app in Slack.
To configure an inbound integration and retrieve its URL:
- Log out of xMatters, and then log back in as the integration user you configured.
- Click the Developer tab, locate the Slack communication plan and click Edit > Integration Builder.
- Expand the list of inbound integrations, and then click the Invite to Channel integration to view its details.
- Make sure that the Authentication type is set to URL Authentication (it should be the default setting for a newly imported plan).
- If the integration is set to use a different type of authentication, select URL Authentication in the drop-down list, and then click Update Inbound Integration.
- Scroll down to the bottom of the page, and click Copy URL beside the field:
You will need the URL for the inbound integration service when configuring Slack.
Now that you've configured xMatters, you can configure Slack to integrate with xMatters.
Slack uses Slash Commands to initiate the xMatters events when assistance is required from an on-call group.
- Log into Slack and access the App Directory.
- The easiest way to do this is to click the arrow beside your Slack domain and select Customize Slack. A page to customize Slack opens in your browser. From there, click Configure Apps.
- Under Manage, click Custom Integrations then select Slash Commands.
- You can also use the search box at the top of the page to find the Slash Commands integration option.
- Provide a name for the Slash command, for example /xMatters, then click Add Slash Command Integration:
- Scroll down to the Integration Settings and set the value of the URL field to the inbound integration URL, and then save the integration.
To test the integration, enter the slash command you created into a Slack channel following by a space delimited list of groups you want to notify.
To invite the on-call members of the DBA and Operations groups to the current channel in Slack, enter the following command.
/xmatters DBA Operations
When troubleshooting why an event doesn't seem to make it over to xMatters, the best place to look is the Integration Builder Activity Stream. While on the Integration Builder tab, click the gear icon beside an integration service, and then click Activity Stream.
The Activity Stream contains the incoming (and for outbound integrations, the outgoing) request, any logging statements as well as the final event creation messages.
Integration Builder endpoints can now be configured to use Slack authentication. If you want to change the imported default endpoint to use the Slack authentication type, you will also need to update the outbound integration scripts.
To update the endpoint:
- In xMatters, navigate to the Integration Builder for the Slack communication plan, and click Edit Endpoints.
- Click the Slack endpoint, and then, in the Authentication drop-down list, select Slack.
- Click Connect.
- A new browser window will open to slack.com to authorize access to your Slack account. (Make sure your browser allows popups for this step.)
- Select or sign into the Slack team that you want to allow xMatters to access.
- Click Authorize.
- In the Integration Builder, expand the list of outbound integrations and then click Delivery updates.
- In the "Transform the content" section, click Edit Script.
- Locate the following line:
var slackPath = slackWebHookURL.substring(slackWebHookURL.indexOf(".com") + 4);
- Replace the above line with the following code:
var slackPath = 'chat.postMessage?token=' + http.authenticate( 'Slack' ) + '&channel=' + callback.eventProperties.channel_name + '&text=' + encodeURI( JSON.stringify( payload.text ) );
- Click Save.
- Repeat steps 7 through 10 for the Response updates outbound integration.