Configuring a monitor for Slack Web API

You can use the Slack Web API as an interface to query information and perform a change in the Slack workspace. For more information, see Using the Slack Web API. You can use the Slack platform to extend, expand, and automate your workspaces. For more information on Slack, see An introduction to the Slack platform.

In IBM Process Mining, you can use the Bot user authorization key that is generated by using the Slack App software and create slack service. You can then use this service to configure a new or existing monitor event. For more information on various types of monitors and on how to create a monitor event, see Types of Monitors.

You can use this example to create a public Slack App and a Bot user authorization key. The created Bot user authorization key is then used to create a Slack service on the Action Hub page of IBM Process Mining.

Creating a public Slack App

Use the following steps to create a new app in the Slack API website:

  1. Create a Slack account and a Slack workspace. For more information, see Create a Slack workspace.

  2. Go to Your Apps and then click Create an App to create a public Slack App.

  3. In the Create an app dialog, click From scratch.

  4. In the Name app and choose workspace dialog, type a name for the Slack app and choose the workspace to develop the app.

  5. In the left pane, go to Features > OAuth & Permissions.

You can use the OAuth & Permissions page to set authentication permissions and allow a bot or a user to interact with your workspace within the defined scope.

  1. Go to Scopes > Bot Token Scopes, click Add an OAuth Scope, and then from the list, click chat:write.

You can define the scope based on the requirement. For more information on available authentication scopes, see Web API methods.

  1. In the OAuth Tokens for Your Workspace section, click Install to Workspace to install the newly added scope to the Slack workspace.

  2. In the OAuth Tokens for Your Workspace section, copy the Bot User OAuth Access Token that is displayed on the page.

    Locating the Bot User OAuth Access Token Figure 17: Bot User OAuth Access Token

You can use the Bot User OAuth Access Token when you create a Slack service on the Monitor page.

Creating an activity monitor with a Slack service

Use the following steps to configure an Activities monitor with the Slack service in IBM Process Mining:

  1. Open a project and then go to the Action Hub page.

  2. On the Action Hub page, click Create service.

  3. In the Create new service dialog, ensure that the Service Type is Rest API, and then in the Service title field, type the name of the service (for example Slack API Service).

  4. In the Description field, type a description for the service that you create.

  5. In the URL field, type https://slack.com/api/chat.postMessage.

  6. Set Allow self-signed certificates to True.

  7. Set Share with others to True to share the Slack service within the organization.

  8. In the Authentication type section, click API key.

  9. In the Position field, select Header.

  10. In the API key name field, type Authorization.

  11. In the API key value box, type the Bot User OAuth Access Token obtained in Figure 17.

  12. Click Create.

  13. On the Action Hub page, click Create monitor.

  14. In the Details step of creating a monitor, specify the name for the activity monitor, provide a description for the monitor, and then click Next.

  15. In the Monitor step of creating a monitor, complete the following steps:

    a. In the Monitor type field, select Activities.
    b. Select the activity to monitor.
    c. Click Manage filters to add a filter to the monitor. For more information on how to apply filters on monitors, see Applying filters in Action Hub.
    d. Click Next.

  16. In the Schedule step, define the criteria for running the monitor, and then click Next.

  17. In the Service step, select the service that is created by using Slack, and then click Next.

    Selecting the slack service Figure 18: Selecting the service for Slack

  18. In the Parameters step, do the following steps:

    a. In the HTTP method field, select POST.

    b. In the Body parameters section, click Customised Body, and then type the following json script in the field:

    {
    "channel": "Type the channel number or name",
    "text": "Hello world from process $__project__"
    }
    

    c. Click Verify Connection to check the connection, and then click Create.

    Setting the parameters page Figure 18: Setting the parameters page

    In the JSON script, you must update the value for channel. You can do the following steps to get the value for channel:

    1. Go to the workspace that includes the created Slack App.
    2. Right-click the Slack App and then go to Copy > Copy link.
    3. Paste the copied link and use the last suffix as the channel number.

    Example: If the copied link is https://your_workspace.slack.com/archives/C1231231230, then the value for the channel is C1231231230.

  19. On the Action Hub page, click the more options button on the created monitor event, and then click Run.

For more information on the fields in the Create Activity monitor wizard and its related values, see Setting a monitor for Activities.