Connecting Slack App to Metric Insights
This article details how to establish connectivity between the Metric Insights Slack App and a Metric Insights Server (Metric Insights Slack App = MI Slackbot + Slack App).
1. Build a Dataset for MI Slackbot
The Dataset for MI Slackbot will contain information about all elements in Metric Insights.
Before building a Dataset:
- Make sure you are logged in as Admin User
Check that there is at least one Element in Metric Insights.
- If there are no elements in the MI application, it will be impossible to Validate the Dataset (as the SQL query will not return any results)
- Access Dataset Editor > Data tab via New > Datasets > Create New
Configure the Settings:
- Data Source for the Dataset should be set to "Dashboard DB"
- Enter the SQL statement (exact statement is provided in Section 1.2)
Dataset ID: copy the Dataset ID from the URL
- It will be required for MI Slackbot configuration. See details in Section 5
For more information on how to create a Dataset, refer to Create a Dataset from any Data Source
select de.element_id, IFNULL(last_sv.segment_value_id, 0) as segment_value_id, IFNULL(de.segment_id, 0) as segment_id, IFNULL(last_sv.element_short_name, 'no_name') as name, de.name as element_name, sv.value_display_name as segment_value, seg.name as segment_name, de.type, ert.reporting_tool_name as external_report_type, de.certified_ind, last_sv.metric_last_measurement_value_formatted as metric_last_measurement_value, last_sv.last_measurement_time, GROUP_CONCAT(t.name separator ',') AS keywords, '' AS slack_channels, de.description, mint.name as interval_name, IFNULL(devl.view_count, 0) as view_count FROM dashboard_element AS de JOIN dashboard_category AS dc ON (dc.category_id=de.category_id) LEFT JOIN measurement_interval mint on mint.measurement_interval_id = de.measurement_interval_id LEFT JOIN segment as seg on (de.segment_id=seg.segment_id) LEFT JOIN dashboard_element_topic AS det ON (det.dashboard_element_id=de.element_id) LEFT JOIN topic AS t ON (t.topic_id=det.topic_id) LEFT JOIN last_dashboard_element_segment_value as last_sv on (last_sv.element_id=de.element_id) LEFT JOIN segment_value as sv ON (last_sv.segment_value_id=sv.segment_value_id) LEFT JOIN external_report_type as ert ON (ert.external_report_type_id=de.external_report_type_id) LEFT JOIN ( select sum(total_view_count) as view_count, element_id, segment_value_id from dashboard_element_view_log group by element_id, segment_value_id) AS devl ON devl.element_id=de.element_id and devl.segment_value_id=last_sv.segment_value_id WHERE last_sv.last_measurement_time_flag='Y' GROUP BY de.element_id, last_sv.segment_value_id ORDER BY de.element_id, last_sv.segment_value_id
2. Create credentials in MI Application
Application ID and Application Key credentials are used to configure MI Slackbot (Slackbot.ini file) as described in Section 5.
These credentials will be encrypted to prevent third-party breaches. For more information, go to Slack App Encryption
- User management access: set to "yes" in order for Slack App to be able to access MI Users
- Cross Domain access: switch from default to "yes" if your MI Slackbot is installed on a different server than the main MI application
Show credentials: click to obtain access credentials
- Application ID and Application key are required to configure MI Slackbot.ini file. The details on how they are used are provided in Section 5
3. Set Slack Integration in the MI application
From the Admin menu, select Slack Integration
To establish connectivity between Slack and Metric Insights, enter the Slack App credentials in the Metric Insights.
Refer to Section 3.3 of this article to see where Slack App credentials are obtained.
Specify the following:
- App Credentials: available at the Slack App configuration page under Settings > Basic Information. For details, see Section 3.3 below
- Access Tokens: available on the Slack App configuration page under Features > OAuth & Permissions. For details, see Section 3.3 below
Slackbot Share Proxy URL: replace the hostname with your own + and leave this part of the URL
- Slack Event Subscription URL: is generated automatically
4. Setup access to the MI data
- Channel syncing will display your Slack Workspace Channels in Metric Insights.
- MI User Groups must be linked to Slack Channels to allow data sharing.
- Users who are not members of respective Groups will be restricted from sharing MI content in Slack Channels.
To learn more about managing access for MI Groups, go to MI Slack App Security
In the Slack Integration Editor:
- Open the Channels tab
- Click [Synchronize Channels]
- Manage Groups: specify which MI Groups will have access to these Channels.
5. Configure Slackbot.ini file
To access the Slackbot.ini file, you must be an admin with root privileges.
In the production version of 6.x (General Availability) the Slackbot.ini file will be populated automatically.
In order to allow the MI Slackbot to communicate with the Slack App, you need to connect via SSH to the server with the installed MI Slackbot and modify the Slackbot configuration file.
Slackbot.ini file is to be found at
- When the MI Slackbot is installed, the emtpy Slackbot.ini file is generated
- The first time the MI Slackbot is launched, its configuration file will contain the following values (view below)
- instance_hostname: Bot User OAuth Access Token
- api_token: Bot User OAuth Access Token
- bot_token: OAuth Access Token
- app_id: Application ID (Obtained from External Application in Metric Insights. See details in Section 2)
- app_key: Application Key (Obtained from External Application in Metric Insights. See details in Section 2)
- app_user: Username of a Metric Insights User with admin rights
- dataset_id: replace the default "0" value with the ID of the Dataset built for MI Slackbot
- slack_signing_secret: Signing Secret for Slack App
6. Restart MI Slackbot
In order to restart the MI Slackbot, run the following command:
sudo docker restart mi-slackbot
7. What's next?
Having restarted the MI Slackbot, you can make full use of the available functionality (getting data from Metric Insights and sharing it in a Slack Channel).
For more information, refer to Access content via a Slack App