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 & wait until it is approved/rejected.

Once the request is responded to, a message will be posted to Slack containing the following:

  • Whether the request was approved or rejected
  • The username of the person who responded to the request

Example screenshots of all 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: 2.0.1

Input
  • token: The slack app / bot user token

  • channel: A Channels dictionary

  • message: A simple message to send, along with the approval request

Output

A dictionary with the following keys:

  • approved: true if the request was approved, false if it was not

  • responder: the PPA user who submitted the response

Example
1
2
3
4
5
6
- slack.messages.send_approval_request:
    message: Please approve this request
  load:
    channel: approval_channel
    token: slack_bot_token
  save: approval_response
Approval Request Screenshot

approval-request

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