Start integrating with ONEiO for free!
SIGN UP

How to configure Slack for integration with ONEiO

Introduction

This document shows an example of what needs to be done on Slack to make it integration-ready with the endpoint in your ONEiO. Note also that the amount of fields used in integrations might vary.

ONEiO utilises Interactivity, Slash Commands and Incoming Webhooks features of Slack App.

For any questions related setting up the integration, please send mail to support@oneio.cloud.

Create Slack Endpoint Type

Before go any further, first a new Slack endpoint should be created.

Screenshot_2022-09-27_at_14.17.28.png

As first step Create and Save your endpoint type.

  • Enter your endpoint type name
  • Select your timezone
  • Insert any value on Bot User OAuth Token. This field will be updated in next steps.

As second step Edit your endpoint type and Generate new password.

Screenshot_2022-09-30_at_15.11.21.png

As third step  Copy Target URL to clipboard

Screenshot_2022-09-29_at_10.31.51.png

Store your generated URL for usage in next steps.

Lastly, Save the changes on endpoint.

For more details of you can check Endpoint Configuration Guide - Slack 

Sending messages from Slack to ONEiO

In this part, focus is how to setup a Slack app and adjust its settings for sending messages to ONEiO.

Create an App in Slack

Log in to your Slack account (https://api.slack.com) with your account administrator user and click Your Apps from the top right corner of your screen.

Start by clicking Create New App

Screenshot_2022-09-26_at_9.32.13.png

Go on with From scratch;

Screenshot_2022-09-26_at_9.34.59.png

Write the app name and select the workspace for app;

Screenshot_2022-09-26_at_9.35.55.png

Fill out the basic information/ display information

Screenshot_2022-09-26_at_9.38.10.png

Navigate to Add features and functionality.

Screenshot_2022-09-26_at_9.39.06.png

Select Interactivity & Shortcuts and Activate the feature.

Screenshot_2022-09-27_at_13.23.20.png

Enter your Generated URL from Slack Endpoint Type. Details are on Create Slack Endpoint Type

Screenshot_2022-09-27_at_13.25.25.png

Create Slash Command on Slack

To be able to send messages from Slack to ONEiO, first you need to define slash command.

Go to Slash Commands on the app menu and create a new slash commands;

Screenshot_2022-09-26_at_8.05.03.png

You are going to see a form to create slash command. Create your command, write your description and usage hint. To fill Request URL, first it is needed to create URL on ONEiO.

Screenshot_2022-09-26_at_8.05.15.png

command Slash command keyword. "/incident"
Request URL

https://[USERNAME]:[PASSWORD]@rest-receiver.service-flow.com/api

The URL generated on Create Slack Endpoint Type step above.

Short Description Description of your slash command
Usage Hint Additional text field to describe functionalty of slash command

Configure Scopes for Slack App

Go to App Menu, OAuth & Permissions and then navigate through Scopes. Configure the scopes below to your bot user of Slack App.

Screenshot_2022-09-27_at_14.03.52.png

To activate your app in Slack, Install to Workspace.

Screenshot_2022-09-26_at_10.16.07.png

In next page, select an existing channel to posting messages from app or create a new channel for app to post messages via Incoming Webhooks.

Note: As soon as you install your app into channel you decided, an Incoming Webhooks is created for selected channel.

Screenshot_2022-09-27_at_13.55.41.png

Even though, you selected a channel for Incoming Webhooks of Slack App, by default, Slack endpoint type Slack API methods. To enable to use message types within default configurations of Slack endpoint type, please add the app preferably in same channel.

Go to channel which you want to install application and navigate to View channel details

Screenshot_2022-09-30_at_14.37.47.png

Navigate to Integrations and Add an app

Screenshot_2022-09-30_at_14.39.21.png

Type your app name and Add app. 

Screenshot_2022-09-30_at_14.45.17.png

After adding app, pop-up window will be automatically closed and you will a message on channel.

Screenshot_2022-09-30_at_14.47.09.png

Congratulations! Slack App setup is completed.

Sending messages from Slack to ONEiO

Go to Endpoint Type page and create a new endpoint.

Screenshot_2022-09-27_at_14.17.28.png

  • Enter your endpoint type name
  • Select your timezone
  • Insert Bot User OAuth Token

To insert your Bot User OAuth Token, go to your Slack App menu, navigate to OAuth & Permissions 

Screenshot_2022-09-27_at_14.21.15.png

Copy your token and insert your token as Bearer xoxb-*** on Both User OAuth Token.

Then go right top corner of the page and Create the endpoint.

Setting Routing Rules

Create Rule for Slash Commands

When a user enters a slash command on Slack channel, Slack sends a POST request to Request URL in it. On ONEiO, in order to react with a slash command at least one rule needed to be created. In sample rule below, ONEiO responds slash command with Slack Modal, designed in Block Kit Builder tool of Slack. 

Go to Routing Rules and Create New Rule;

Make sure you select Response Template as Message Type on the right side.

Screenshot_2022-09-27_at_14.31.55.png

Then go to Mappings 

Set Outbound mappings as below

Screenshot_2022-09-26_at_8.55.17.png

${trigger_id} trigger_id
modal json view

The example modal JSON body can be found below;

 {
    "type": "modal",
    "callback_id": "incident",
    "title": {
        "type": "plain_text",
        "text": "ServiceNow Incident"
    },
    "submit": {
        "type": "plain_text",
        "text": "Submit",
        "emoji": true
    },
    "close": {
        "type": "plain_text",
        "text": "Cancel",
        "emoji": true
    },
    "blocks": [
        {
            "type": "input",
            "block_id": "short_description",
            "label": {
                "type": "plain_text",
                "text": "Short Description"
            },
            "element": {
                "type": "plain_text_input",
                "action_id": "add_short_description",
                "multiline": false
            }
        },
        {
            "type": "input",
            "block_id": "description",
            "label": {
                "type": "plain_text",
                "text": "Description",
                "emoji": true
            },
            "element": {
                "type": "plain_text_input",
                "action_id": "add_description",
                "multiline": true
            },
            "optional": true
        },
        {
            "type": "input",
            "block_id": "worknotes",
            "label": {
                "type": "plain_text",
                "text": "Work Notes",
                "emoji": true
            },
            "element": {
                "type": "plain_text_input",
                "action_id": "add_worknotes",
                "multiline": true
            },
            "optional": true
        }
    ]
}

For more details about Slack Modals you can follow Slack instructions.

You can also modify the example modal easily or create new modals with Slack's Block Kit Builder

Field name Details
callback_id callback_id is used as identifier for what modal template is used. It is used in rules.
block_id block_id is used as identifier for modal field in block elements. It is used in rules.

Set Conversation Variables as below

Screenshot_2022-09-27_at_14.37.59.png

Source Value Conversation variable
${response_url} sf:conversation:response_url
${trigger_id} sf:conversation:trigger_id
${token} sf:conversation:slack_token
${text} sf:conversation:slack_text
${channel_id} sf:conversation:channel_id

Rule for responding Slash command is set now. Next step is to define a rule for directing and mapping inbound message which is created by Slack after clicking Submit on Slack Modal.

Create rule to integrate Slack to ServiceNow;

Assumption: You already set up ServiceNow or similar ITSM tool on your subscription.

Screenshot_2022-09-27_at_14.42.22.png

Set Outbound Mappings;

Screenshot_2022-09-27_at_14.43.31.png

Set Conversation Variables

Screenshot_2022-09-27_at_14.43.41.pngThen save your rule. 

In order to be notified that your incident successfully is created, another rule should be set;

Go to the rule Slack to ServiceNow - Create Incident and click Edit Rule on right top of the page. You will see Response Rules section below Outbound side of the rule structure. Create new response rule.

Screenshot_2022-09-27_at_14.48.07.png

A rule edit page is seen below. On Outbound side, select Message as Message Type.

Screenshot_2022-09-27_at_14.50.27.png

Then go to Mappings tab and set Runtime Variables;

Screenshot_2022-09-27_at_14.51.33.png

${result.number} incident_number
   

Then set Outbound Mappings;

Screenshot_2022-09-27_at_14.54.25.png

channel id channel
Incident ${sf:virtual:incident_number} created successfully. text

Channel field must filled with channel_id value. It must be same channel where you app is installed. Go to that channel then open channel menu and copy link.

Screenshot_2022-09-27_at_14.59.32.png

Select and copy channel_id from the URL. https://service-flow.slack.com/archives/"channel_id" and paste on outbound mappings.

After rules' setup is complete, slash command can be tested. Go to any channel you like and enter defined slash command. On our example, it is defined /incident

Screenshot_2022-09-26_at_9.16.11.png

As soon as you enter the slash command, a modal will be appear over the Slack application.

Screenshot_2022-09-26_at_9.17.49.png

After filling the modal, when form is submitted. ONEiO send response message to designated app channel, which app is installed by admins.

In this tutorial, how to create slack app, how to set up Slack Bilateral endpoint type and setting basic rules with ServiceNow are covered.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.