Edit this page on GitHub

Home > docs > plugins > Slack Tasks

Slack Tasks

The slack plugin supports interaction with the Slack messaging platform.

Configuration

This slack plugin is provided automatically by Concord and the target Slack server instance has to be configured as part of the server installation.

The bot user created for the API token configuration e.g. concord has to be a member of the channel receiving the messages.

Slack Task

A message text can be sent to a specific channel identified by a channelId with the long syntax or you can use the call method.

flows:
  default:
    - task: slack
      in:
        channelId: "exampleId"
        username: "anyCustomString"
        iconEmoji: ":information_desk_person:"
        text: "Starting execution on Concord, process ID ${txId}"

    - if: "${!result.ok}"
      then:
        - log: "Error while sending a message: ${result.error}"

    ...

    - task: slack
      in:
        channelId: "exampleId"
        ts: ${result.ts}
        username: "anyCustomString"
        iconEmoji: ":information_desk_person:"
        text: "Execution on Concord for process ID ${txId} completed."

The channelId can be seen in the URL of the channel or alternatively the name of the channel can be used e.g. C7HNUMYQ1 and my-project-channel. To send a message to a specific user use @handle syntax:

- task: slack
  in:
    channelId: "@someone"
    text: "Hi there!"

Not that @handle works only for users that did not change their Display Name in their Slack profiles.

Optionally, the message sender name appearing as the user submitting the post, can be changed with username. In addition, the optional iconEmoji can configure the icon to use for the post.

The task returns a result object with three fields:

  • ok - true if the operation succeeded;
  • error - error message if the operation failed.
  • ts - Timestamp ID of the message that was posted, can be used, in the following slack task of posting message, to make the message a reply.

The optional field from the result object ts can be used to create a thread and reply. Avoid using a reply’s ts value; use it’s parent instead.

Slack Channel Task

The slackChannel task supports creating and archiving channels and groups of the Slack messaging platform.

Possible operations are:

The slackChannel task uses following input parameters

  • action: required, the name of the operation to perform create, archive, createGroup or archiveGroup
  • channelName the name of the slack channel or group you want to create, required for create and createGroup that you want to create or
  • channelId: the id of the slack channel that you want to archive, required for archive and archiveGroup
  • apiToken: required, the slack API token for authentication and authorization. The owner of the token as has to have sufficient access rights to create or archive channels and groups. Typically this should be provided via usage of the Crypto task.

Create a Channel

This slackChannel task can be used to create a new channel with the create action.

flows:
  default:
  - task: slackChannel
    in:
      action: create
      channelName: myChannelName
      apiToken: mySlackApiToken
  - log: "Channel ID: ${slackChannelId}"

The identifier of the created channel is available in the context after the successful task execution output variable as slackChannelId.

Archive a Channel

This slackChannel task can be used to archive an existing channel with the archive action.

flows:
  default:
  - task: slackChannel
    in:
      action: archive
      channelId: C7HNUMYQ1
      apiToken: mySlackApiToken

The channelId can be seen in the URL of the channel e.g. C7HNUMYQ1

Create a Group

This slackChannel task can be used to create a group with the createGroup action.

flows:
  default:
  - task: slackChannel
    in:
      action: createGroup
      channelName: myChannelName
      apiToken: mySlackApiToken
  - log: "Group ID: ${slackChannelId}"

The identifier of the created group is available in the context after the successful task execution output variable as slackChannelId.

Archive a Group

This slackChannel task can be used to archive an existing group with the archiveGroup action.

flows:
  default:
  - task: slackChannel
    in:
      action: archiveGroup
      channelId: C7HNUMYQ1
      apiToken: mySlackApiToken