Skip to content

Slack Slack: Messages

Summary

This module contains actions for sending messages & approval requests to a Slack channel.

Before you Start

Ensure you have created a PPA Slack app, & enabled the relevant slack app scopes.

See the Integration page for more information

Supplying Sensitive Data

You should always use a PPA Vault integration to provide sensitive data to a plugin action.

Actions

slack.messages.

send_approval_request

Send an approval request to a Slack channel.

This action only sends the request to a channel, it does not activate the request.

The example below shows the PPA plugin, this action, & send_approval_response used together.

An example screenshot of the Slack message can be found under the example.

Slack Channel

The message will be sent to the channel supplied to the action.

Minimum Plugin Version: 6.0.0

Minimum PPA Version: 3.3.0

Input
Output

Nothing is outputted by this action.

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 1 - Create the approval request
- ppa.events.create_approval_request:
    request_message: >
      ### Example Request Message

      A user has requested temporary access to some group(s).

      *User:* {{ active_directory_user.cn }}

      *Groups:*

      {% for group in selection.all %}

        - {{ group.cn }}

      {% endfor %}
  save: approval_request

# 2 - Push it to a private Slack channel
- slack.messages.send_approval_request:
    assignees:
      - john.smith
      - clare.jones
  load:
    channel: approval_channel
    token: slack_bot_token
    approval_request: approval_request

# 3 - Wait for a response
- ppa.events.wait_approval_response:
    assignees:
      - john.smith
      - clare.jones
  load:
    approval_request: approval_request
  save: approval_response

# 4 - Push the response to a private Slack channel
- slack.messages.send_approval_response:
  load:
    channel: approval_channel
    token: slack_bot_token
    approval_response: approval_response
Approval Request Screenshot

approval-request

slack.messages.

send_approval_response

Send the response to an approval request to a Slack channel.

The example below shows the PPA plugin, send_approval_request, & this action used together.

An example screenshot of the Slack messages can be found under the example.

Slack Channel

The message will be sent to the channel supplied to the action.

Minimum Plugin Version: 6.0.0

Input
Output

Nothing is outputted by this action.

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 1 - Create the approval request
- ppa.events.create_approval_request:
    request_message: >
      ### Example Request Message

      A user has requested temporary access to some group(s).

      *User:* {{ active_directory_user.cn }}

      *Groups:*

      {% for group in selection.all %}

        - {{ group.cn }}

      {% endfor %}
  save: approval_request

# 2 - Push it to a private Slack channel
- slack.messages.send_approval_request:
    assignees:
      - john.smith
      - clare.jones
  load:
    channel: approval_channel
    token: slack_bot_token
    approval_request: approval_request

# 3 - Wait for a response
- ppa.events.wait_approval_response:
    assignees:
      - john.smith
      - clare.jones
  load:
    approval_request: approval_request
  save: approval_response

# 4 - Push the response to a private Slack channel
- slack.messages.send_approval_response:
  load:
    channel: approval_channel
    token: slack_bot_token
    approval_response: approval_response
Approved Message Screenshot

requested-approved

Rejected Message Screenshot

request-rejected

slack.messages.

send_file

Send a file to a Slack channel.

File Considerations

  • For the possible file types please see here

  • There is a 1 megabyte file size limit for files uploaded as snippets.

Minimum Plugin Version: 2.0.1

Input
  • token: The slack app / bot user token

  • channel: A Channels dictionary

  • message: A simple message to send, along with the file

  • file_name: The name of the file that has been saved to the workspace (must be supplied within quotation marks "")

Output

Nothing is outputted by this action.

Example
  • Save a file to the PPA workspace

  • Send the file to a selected slack channel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
- ppa_tools.files.write_json_file:
    name: example_file.json
  load:
    contents: sample_message

- slack.messages.send_file:
    message: Please read the example file
    file_name: "example_file.json"
  load:
    channel: ind_channel
    token: slack_bot_token

slack.messages.

send_message

Send a message to a Slack channel.

Slack Channel & Rich Messages

View the Slack block kit builder here for more information on creating rich messages.

Minimum Plugin Version: 2.0.1

Input
  • token: The slack app / bot user token

  • channel: A Channels dictionary

  • message: the message to send to the channel

Output

Nothing is outputted by this action.

Simple Message
1
2
3
4
5
- slack.messages.send_message:
    message: "Hello from PPA!"
  load:
    channel: channel
    token: slack_bot_token_dev
Markdown Message
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- slack.messages.send_message:
    message:
      blocks:
        - type: section
          text:
            type: mrkdwn
            text: 'Hello from PPA!'
  load:
    channel: single_channel
    token: slack_bot_token_dev