Hi, I'm Ask INFA!
What would you like to know?
ASK INFAPreview
Please to access Ask INFA.

Slack Message Handler

Slack Message Handler

Step 5. Create a webhook in Slack

Step 5. Create a webhook in Slack

Configure a Slack app to call an API whenever a new message arrives.
To configure a Slack app, perform the following steps:
  1. Create a Slack app.
  2. Enable the events API.
  3. Subscribe to the event.
  4. Set the required OAuth scopes.
  5. Enable token rotation.
  6. Add the bot to a channel.

Step 1. Create a Slack app

  1. Go to
    https://api.slack.com/apps
    and log in to your account.
  2. Click
    Create New App
    From scratch
    .
  3. Enter the app name, select your workspace, and then click
    Create App
    as shown in the following image:
    The image shows the Name app & choose workspace dialog box
								where you can enter the app name and select your workspace.
  4. Select your app, go to
    Basic Information
    App Credentials
    , and copy the client ID and client secret.

Step 2. Enable the events API

  1. From the left navigation bar, go to
    Event Subscriptions
    .
  2. Turn on the toggle switch to enable events.
  3. In the
    Request URL
    field, enter the service URL that you get after publishing the process.
    Slack sends a
    challenge
    request to verify the URL as shown in the following image:
    The image shows the Event Subscriptions dialog box where you can
								enter the service URL after publishing the process.

Step 3. Subscribe to the event

  1. In the
    Subscribe to bot events
    section, click
    Add Bot User Event
    and add one of the following events:
    • message.channels
      — to receive messages from public channels.
    • message.groups
      — for private channels.
    The event allows your app to receive messages from channels it belongs to as shown in the following image:
    The image shows the Event Subscriptions page where you can add bot
								events.

Step 4. Set the required OAuth scopes

  1. Go to
    OAuth & Permissions
    .
  2. In the
    Bot Token Scopes
    section, click
    Add an OAuth Scope
    and add one of the following OAuth scopes:
    • channels:history
      — to read public channel messages.
    • groups:history
      — to read messages from private channels, if needed.
    • chat:write
      — if your bot needs to send messages.
  3. In the
    Redirect URLs
    section, click
    Add New Redirect URL
    and add the redirect URLs in
    <POD URL>/oauthcallback
    format and save the URLs.
    For example,
    https://na1.dm-us.informaticacloud.com/oauthcallback
    . The following image shows the redirect URLs:
    The image shows the redirect URLs.
  4. Install the app using the
    Install App
    section.

Step 5. Enable token rotation

  1. Go to
    OAuth & Permissions
    .
  2. In the
    Advanced token security via token rotation
    section, click
    Opt In
    as shown in the following image:
    The image shows the Opt In option on the OAuth & Permissions
								page.
  3. Save the bot OAuth token.

Step 6. Add the bot to a channel

  1. In Slack, go to the required channel.
  2. Invite the bot using
    /invite @<your-bot-name>
    .

0 COMMENTS

We’d like to hear from you!