Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel

Table of Contents
maxLevel2

Disclaimer

Your use of this download is governed by Stonebranch’s Terms of Use, which are available at https://www.stonebranch.com/integration-hub/Terms-and-Privacy/Terms-of-Use/

...

This Universal Extension creates a Slack Bot that provides the capability to directly interact with Universal Controller, by executing Slack Commands.

Version Information

Template NameExtension NameExtension Version
Slack Botue-slack-bot1.0.
0
2

Refer to Changelog for version history information.

...

Software Requirements for Universal Template and Universal Task

Requires Python 3.7.0 or higher. Tested with the Universal Agent bundled Python distribution.

...

  • Universal Agent for Windows x64 Version 7.31.0.0 and later with python options installed.
  • Universal Agent for Linux Version 7.31.0.0 and later with python options installed.

...

Universal Controller Version 7.31.0.0 and later.

Network and Connectivity Requirements

...

This Universal Extension provides Slack Commands that let 's a user gain information about reports, agents and task instances, or even alter the latter. These commands are the following:

Area of InterestAvailable Commands
Tasks and InstancesRerun a Task Instance.
Tasks and InstancesHold a Task Instance.
Tasks and InstancesForce Finish/Cancel a Task Instance.
Tasks and InstancesShow Task Instances for specific filter parameters.
Tasks and InstancesShow Late Task Instance with certain parameters.
Tasks and InstancesRetrieve the output of a Task Instance.
Tasks and InstancesRetrieve detailed information about a task instance.
Tasks and InstancesSchedule an ad-hoc run of a task instance by enabling a trigger.
AgentsShow the status of all available Universal agents
ReportsShow a Report.

Additionally, this extension provides the following features:

  • Help Menu: Quick access to all available commands.
  • Graphical & CLI interface: Trigger automation commands both through popup dialogs and "command-line" style interface.
  • Audit: Keep a detailed audit log on Slack users' interaction to the UAC Bot and the UAC.
  • Security & fine-grained access control (ACL): Limit the access to the UAC Bot using a private Slack channel (only members of this channel will be able to use the UAC Bot) & manage the level of access of your Slack users, on a resource level (making sure that the right users have access to available resources & actions).

How to

...

Start 

This extension is shipped with in-Slack dialogs available to your users, in order for them to be introduced to the basic Slack Bot functionality and provide on-going access to help menu. Here is a list of example screenshots that provide a step-by-step approach to a user for getting familiar to Slack Bot and successfully executing one Slack Bot command.

Step 1: Introduction of the Slack Bot to the users is done at the setup phase, where the Slack Bot greets the channel users with a small and informative message, guiding them on the next actions they could take.

Command InviteImage RemovedImage Added

Step 2: The help menu is available to the users whenever they need a list of available commands, from which they can even trigger the corresponding popup dialog (help menu is available though command /uacbot help).

Command HelpImage Removed>Image Added

Step 3: Triggering a Slack command from a popup dialog is helpful, as the dialog provides guidance on the available parameters and their values.

Command PopupImage RemovedImage Added

Step 4: Slack Bot command results are provided in-channel, with simple and informative messages.

Command ResultImage Removed |Image Added

Import Universal Template

...

  1. This Universal Task requires the the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true.

  2. To import the Universal Template into your Controller, follow the instructions here.

  3. When the files have been imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.

...

display_information:
  name: Stonebranch UAC Bot
  description: Integrate Slack Workspace with UAC platform
  background_color: "#000000"
settings:
  org_deploy_enabled: false
  token_rotation_enabled: false
  socket_mode_enabled: true
  interactivity:
    is_enabled: true
  event_subscriptions:
    bot_events:
      - app_mention
features:
  app_home:
    home_tab_enabled: false
    messages_tab_enabled: false
    messages_tab_read_only_enabled: false
  bot_user:
    display_name: UACBot
    always_online: true
  slash_commands:
    - command: /uacbot
      description: Send commands to UAC Bot
      usage_hint: " [command] [parameters]"
      should_escape: false
oauth_config:
  scopes:
    bot:
    - app_mentions:read
    - channels:read
    - chat:write
    - commands
    - files:write
    - links:write
    - users:read
    - groups:read

3. Press "Save Changes".

4. After this step make sure the following settings are set correctly:

  • Basic Information > Add Features and functionality > Slash Commands: Only one command was created with name '/uacbot'.
  • Basic Information > Add Features and functionality > Event Subscriptions: Should be enabled, and socket mode identified as enabled.
    • "Subscribe to bot events" list includes only event "app_mention".
    • "Subscribe to events on behalf of users" list should be empty.
    • "App unfurl domain" list should be empty.
  • Basic Information > Add Features and functionality > Bots:
    • Verify that Display Name (Bot Name) equals "UACBot".
    • Verify that Default Name equals "uacbot".
    • Verify that "Always Show My Bot as Online" is checked.
    • Verify that Show Tabs > Home Tab is disabled.
    • Verify that Show Tabs > Messages Tab is disabled.
  • Basic Information > Add Features and functionality > Permissions:
    • Verify that in Scopes > Bot Token Scopes list only these scopes are included:
      • app_mentions:read
      • channels:read
      • chat:write
      • commands
      • files:write
      • links:write
      • users:read
    • Verify that Scopes > User Token Scopes list is empty.

Application installation in workspace

...

  1. Navigate to "Basic Information" (navigation bar on the left).
  2. Scroll down to the "Display Information" section.
  3. Upload the icon provided here:

Stonebranch Slack Bot iconImage RemovedImage Added

Configure a slack channel

...

The input fields for this Universal Extension are described below.

FieldInput typeDefault valueTypeDescription
Slack Bot tokenRequired-CredentialsThe Slack bot token as obtained from Slack App. It is used to connect Slack Application with a Workspace.

The Credentials definition should be as follows:
  • A desired name for the token as "Runtime User".
  • Slack Bot Token as "Token".
Slack App tokenRequired-CredentialsThe Slack app token obtained from Slack App. It is used to connect the Slack Bot with the corresponding Slack App.

The Credentials definition should be as follows:
  • A desired name for the token as "Runtime User".
  • Slack App Token as "Token".
Slack Channel IDRequired-TextThe Slack channel ID that the bot will connect. to.
ACLRequired-ScriptThe JSON script that contains the ACL rules for your Slack. users.
Universal Controller URLRequired-TextThe URL of the target UC (e.g. http://ue.stonebranch.org:8080/uc).
Universal Controller CredentialsRequired-CredentialsThis extension uses RESTful Web Services API as a client, and in this field the corresponding username & password should be provided. This user should have Web Service Access enabled (directly or through System Default). It is strongly advised not to reuse admin or any existing user but create a new one used only for this specific integration.

The Universal Controller Credentials definition should be as follows:
  • User's username as "Runtime User".
  • User's password as "Runtime Password".
UC REST API TimeoutRequired20TextThe timeout (in seconds) that the Slack Bot will wait for UC to respond. If the UC won't respond in the specified time limit Slack will display a corresponding error to the user.
AuditingOptionalTrueCheckboxA variable that if selected the bot will provide auditing logs.

ACL

ACL (Access Control List) is responsible for granting or denying permissions to your Slack users, on accessing specific functionality & resources on UC, through Slack commands. The access rights granted can be fine-grained, using rules that describe the explicit access right for a specific user, providing his e-mail local part(what everything is included before @ symbol) on a specific resource type and the corresponding action on that resource.

...

The ACL configuration is based on UC Scripts (of type Data Script), and more specifically expressed with JSON format. It is expected to be consisted of rules for each user, where each rule has the following fields:

KeyDescription
resourceWhether a command is related to instances, agents or reports. Can be equal to "*" to refer to all available resources.
actionAvailable actions that can be performed in a resource. Can be equal to "*" to refer to all available resources.
permissionWhether the permission of the combination of specified action and resource is allowed or forbidden.

ACL Rules to Slack Command Mapping

CommandResourceAction
rerun task instanceinstanceinstance.rerun
hold task instanceinstanceinstance.hold
force finish task instanceinstanceinstance.finish
schedule ad hoc runinstanceinstance.schedule
get task instancesinstanceinstance.query
get late tasksinstanceinstance.query
get task instance outputinstanceinstance.query
get task instance infoinstanceinstance.query
get agentsagentagent.query
run reportreportreport.run

Usage Examples

The order in which the rules are provided is essential. The first rule has the most priority whereas the last rule is the lowest priority.

  • Granting access to user with email "john.doe@company.com" to execute rerun task instance command.

...

  • Granting access to user with email "alice.smith@company.com" to execute rerun task instance and show agents status commands.

...

  • Granting access to user with email "john.doe@company.com" to execute all commands related to instances and allow user with email "alice.smith@example" to only run reports and hold task instances.

...

  • Granting access to all users to execute all the commands.
{
  "*": {[
    {
        "resource": "*",
        "action": "*",
        "permission": "ALLOW"
    }
  }]
}
  • Granting access to all users to execute all the commands but forbid a user with user with email "john.doe" to run reports.

...

Example of UE Slack Bot Universal Task for starting the execution of the Slack Bot.

Task ExampleImage RemovedImage Added

Task Output

Since this universal task is designed to operate endlessly, task output is provided only in case of an error in initialization phase or during task instance cancel.

...

The output only fields for this Universal Extension provide operational information of the Slack Bot and are described below.

FieldTypeDescription
Total Requests HandledTextThe total request slack bot has handled since starting
Total Requests SucceededTextThe total request slack bot has returned a successful response
Total Requests FailedTextThe total request slack bot has returned a failed response
Total Validation ErrorsTextThe sum of validation errors that slack bot raised
Total Permission ErrorsTextThe sum of permission errors that slack bot raised

STDOUT and STDERR

STDOUT and STDERR provide additional information to the user. The populated content can be changed in future versions of this extension without notice. Backward compatibility is not guaranteed.

...

<datetime> AUDIT - user:john.doe, channel:C049CHU74P9, command:Get Agents Status, parameters:['groupby:"operating system"'], result: SUCCESS

...

Available Commands

All the available commands can be executed in two different ways, through Slack's popup interface or directly as a command with parameters. Moreover, all commands require the /uacbot prefix followed by the command name to be recognized as commands by Slack.

...

Command Name: rerun task instance

ParametersDescriptionValues and ConstraintsRequiredDefault
idsys_id used within the Universal Controller to identify this task instanceSame with Universal ControllerTrue-

Command Examples

/uacbot rerun task instance id:'<some_valid_id>' 

...

Command Name: hold task instance

ParametersDescriptionValues and ConstraintsRequiredDefault
idsys_id used within the Universal Controller to identify this task instanceSame with Universal ControllerTrue-

Command Examples

/uacbot hold task instance id:'<some_valid_id>' 

...

Command Name: force finish task instance

ParametersDescriptionValues and ConstraintsRequiredDefault
idThe identifier of the task instance to be force finished or canceled.Same with Universal ControllerTrue-
haltIf set to True it prevents successor task instances of the specified task instance id in a Workflow from being run.True / FalseFalseFalse
cancelIf set to True cancels the task instances.True / FalseFalseFalse

Command Examples

/uacbot force finish task instance id:'<some_valid_id>' halt: 'true'   

...

Command Name: get task instances

ParametersDescriptionValues and ConstraintsRequiredDefault
nameThe name of the task instances. This field also accepts wildcards "?" or "*".Max 255 length string (case insensitive).False-
typeFilter the tasks being queried, by task type attribute.Valid Universal Controller task types (case insensitive).False-
statusFilter the tasks being queried, by task status attribute.Valid Universal Controller statuses (case insensitive).False-
lastupdatedFilter instances that have been updated in the last X hours/minutes.Timestamps in hours or minutes format, e.g 1h, 20m.False-
showFilter to fetch all instances or only the last updated instances that match the rest of the input fields.Latest / AllFalseAll

Command Examples

  • Fetch the latest task instances that contain "slack" in their name of type Linux with statuses Finish and Success that have been last updated in the past two days.

...

Command Name: get late tasks

ParametersDescriptionValues and ConstraintsRequiredDefault
nameThe name of the task instances. This field also accepts wildcards "?" or "*".Max 255 length string (case insensitive).True-
lastupdatedFilter instances that have been updated in the last X hours/minutes.Timestamps in day, month or minutes format, e.g. 1h, 20m.False24h
typeFilter tasks based on available late time options.Late start / Late finish / Early finish / AllFalseLate Start

Command Examples

  • Fetch task instances that contain "slack" in their name that have been last updated in the past two days and have late type of either late start, late finish or early finish.

...

Command Name: get task instance output

ParametersDescriptionValues and ConstraintsRequiredDefault
instanceThe id of the task instance to be retrieved.Max 255 length string (case insensitive) or valid Universal Controller sys_id format.True-
outputtypeRetrieve instance output by type.Long list of values, including: STDOUT, STDERR, EXTENSION. Full list of values is available in popup drop-down list.FalseSTDOUT
lengthNumber of lines to fetch from the outputtype.Positive integerFalse20
fetchfromFetch the output logs from the start or from the end.Start / EndFalseStart

Command Examples

  • Fetch last twenty lines of the newest active instance that matches the name slack-bot.

...

Command Name: get task instance info

ParametersDescriptionValues and ConstraintsRequiredDefault
instanceThe name or the id of the task instance to be retrieved.Max 255 length string (case insensitive) or valid Universal Controller sys_id format.True-
criteriaThe last updated criteria of the task instance. Mandatory when the query is made with task name.Newest Instance, Oldest Instance, Newest Active Instance, Oldest Active Instance.FalseNewest Instance

Command Examples

/uacbot get task instance info instance:'<slack-bot>' criteria:'Oldest Instance'

...

Command Name: schedule ad hoc run

ParametersDescriptionValues and ConstraintsRequiredDefault
triggernameThe name of the triggered to be created.Max 255 length string (case insensitive)True-
tasknameThe task name to be binded with the created trigger triggername.Max 255 length string (case insensitive)True-
dateThe date which the taskname will be run.YYYY-mm-dd formatTrueCurrent date
timeThe date which the taskname will be run. In combination with date filed it must be after current time.HH:MM formatTrueCurrent time + 1 minutes
timezonethe timezone of the specified time.UTC-12 to UTC+14TrueUTC

Command Examples

/uacbot schedule ad hoc run triggername:'<valid_trigger_name>' taskname:'<valid_task_name>' date:'YYY-mm-dd' time:'HH:MM' timezone: 'UTC'

...

Command Usage

Command Name: get agents

ParametersDescriptionValues and ConstraintsRequiredDefault
nameThe name of the agent to be retrieved. This field also accepts wildcardsMax 255 length string (case insensitive)False-
osFilter based on the operating system the agent is based on.Windows, Linux, z/OS (case insensitive)False-
versionFilter based on agent version.Valid Universal Controller version formatFalse-
statusFilter based on agent status.Active / Offline (case insensitive)False-
suspendedFilter agents that are temporarily suspended.True/FalseFalse-
groupbyFilter to control the grouping of the output message.A value of all previous available fields.FalseOperating System

Command Examples

  • List and groupby os all active, non-suspended agents which run linux operating system and 7.2 UC version with a specified name.

...

Command Usage

Command Name: get agents

ParametersDescriptionValues and ConstraintsRequiredDefault
nameThe name of the report to be retrieved.Max 255 length string (case insensitive)True-

Command Examples

/uacbot get agents name:'<valid_report_name>' 

...

This document references the following documents.

Document LinkDescription
Universal TemplatesUser documentation for creating, working with and understanding Universal Templates and Integrations.
Universal TasksUser documentation for creating Universal Tasks in the Universal Controller user interface.
Slack Bot APIUser guide for Slack Bot API.

Changelog

ue-slack-bot-1.0.2 (2022-12-15)

  • Bugfix: Extension is available for 7.1 and 7.2 UC versions'

ue-slack-bot-1.0

...

.1 (2022-11-22)

  • Bugfix: Ignore trailing slash character in field 'Universal Controller URL'

ue-slack-bot-1.0.0 (2022-11-21)

  • Added: First ReleaseInitial Version