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. MI Slackbot deployment
  2. Building a bot app for Slack

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:

  1. Make sure you are logged in as Admin User
  2. 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)
1.1. Access Dataset Editor > Data tab
  1. Access Dataset Editor > Data tab via New > Datasets > Create New
  2. Configure the Settings:
    1. Data Source for the Dataset should be set to "Dashboard DB"
    2. Enter the SQL statement (exact statement is provided in Section 1.2)
  3. Validate
  4. Save
  5. 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

1.2. Copy the SQL statement from this section
    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, as element_name,
    sv.value_display_name as segment_value, as segment_name,
    ert.reporting_tool_name as external_report_type,
    last_sv.metric_last_measurement_value_formatted as metric_last_measurement_value,
    GROUP_CONCAT( separator ',') AS keywords,
    '' AS slack_channels,
    de.description, 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)
        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

2.2. Name your External Application
  1. Access External Applications page> click [+ New External Application]
  2. Name: provide a meaningful name for your External Application
  3. Save to proceed
2.3. Get credentials for External App
  1. User management access: set to "yes" in order for Slack App to be able to access MI Users
  2. Cross Domain access: switch from default to "yes" if your MI Slackbot is installed on a different server than the main MI application
  3. Show credentials: click to obtain access credentials
    1. 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

3.1. Go to Admin > Utilities > Slack Integration

From the Admin menu, select Slack Integration 

3.2. Slack Integration Editor > Info tab

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:

  1. App Credentials: available at the Slack App configuration page under Settings > Basic Information.  For details, see Section 3.3 below
  2. Access Tokens: available on the Slack App configuration page under Features > OAuth & Permissions.  For details, see Section 3.3 below
  3. Slackbot Share Proxy URL:  replace the hostname with your own and leave this part of the URL /slack/image?token=<token>  as is
  4. Slack Event Subscription URL: is generated automatically
3.3. Obtain Slack App credentials

To get Slack App credentials:

  1. Go to
  2. Select the App
  3. Find Basic Information > App Credendials
    • Copy all of the App Credentials
  4. Go to Features > OAuth & Permissions
    • Copy Tokens for Your Workspace

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:

  1. Open the Channels tab
  2. Click [Synchronize Channels]
  3. 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 /opt/mi/iv/engine/config/slackbot.ini


  1. When the MI Slackbot is installed, the emtpy Slackbot.ini file is generated
  2. The first time the MI Slackbot is launched, its configuration file will contain the following values (view below)
  1. instance_hostname: Bot User OAuth Access Token
  2. api_token: Bot User OAuth Access Token
  3. bot_token: OAuth Access Token
  4. app_id: Application ID (Obtained from External Application in Metric Insights. See details in Section 2)
  5. app_key: Application Key (Obtained from External Application in Metric Insights. See details in Section 2)
  6. app_user: Username of a Metric Insights User with admin rights
  7. dataset_id: replace the default "0" value with the ID of the Dataset built for MI Slackbot
  8. 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


Add your comment

E-Mail me when someone replies to this comment