slack-send 1.1.4

dotnet add package slack-send --version 1.1.4                
NuGet\Install-Package slack-send -Version 1.1.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="slack-send" Version="1.1.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add slack-send --version 1.1.4                
#r "nuget: slack-send, 1.1.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install slack-send as a Cake Addin
#addin nuget:?package=slack-send&version=1.1.4

// Install slack-send as a Cake Tool
#tool nuget:?package=slack-send&version=1.1.4                

slack-send

A simple utility to send a Slack message using Slack Web API to your channels

slack-send

Installation

> sudo snap install slack-send

or

(https://snapcraft.io/slack-send)

Get it from the Snap Store

or

# use it in your project directly
> dotnet add package slack-send

Usage

slack-send --help

  -h, --help        (default: false) Prints this help message.
  -c, --channels    (default: 'general') Slack channels to send message, separated by ';', default is empty, which means use the channels in the configuration file.
  -d, --desc        (default: 'my description') description on the top of the message
  -t, --title       (default: 'my title') title to send
  -m, --message     (default: 'message to send') message body to send
  -s, --status      (default: 'good') Status good | warning | error, default is good
  -j, --json        (default: empty) JSON formated Slack message (https://api.slack.com/reference/messaging/attachments), it overrides the message and status options, if those values exist on JSON.
  --help            Display this help screen.
  --version         Display version information.

Example

# slack-send -m <message> -c <channel>
> slack-send -m "Hello, My Slack Channel!" -c "general"
or
# slack-send -m <message> -c <channel1>;<channel2> ...
> slack-send -m "Hello, My Slack Channel!" -c "general;random"
or
# slack-send -d <description> -t <title> -m <message> -c <channel1>;<channel2> ...
> slack-send -d "This is a description" -t "This is a title" -m "Hello, My Slack Channel!" -c "general;random"
or
# slack-send -d <description> -t <title> -m <message> -c <channel1>;<channel2> ... -j <json_string>
> slack-send -d "This is a description" -t "This is a title" \ 
  -m "Hello, My Slack Channel!" \
  -c "general;random" \ 
  -j "{\"color\":\"#36a64f\",\"pretext\":\"Optional pre-text that appears above the attachment block\",\"author_name\":\"author_name\",\"author_link\":\"https://flickr.com/bobby/\",\"author_icon\":\"https://placeimg.com/16/16/people\",\"title\":\"title\",\"title_link\":\"https://api.slack.com/\",\"text\":\"Optional `text` that appears within the attachment\",\"fields\":[{\"title\":\"A field's title\",\"value\":\"This field's value\",\"short\":false},{\"title\":\"A short field's title\",\"value\":\"A short field's value\",\"short\":true},{\"title\":\"A second short field's title\",\"value\":\"A second short field's value\",\"short\":true}],\"thumb_url\":\"https://placekitten.com/g/200/200\",\"footer\":\"footer\",\"footer_icon\":\"https://platform.slack-edge.com/img/default_application_icon.png\",\"ts\":123456789}"
Used with GitHub Actions events

Message with JSON payload

Note

  • You need to acquire your Slack API token from Slack in order for slack-send to send messages to your Slack channels, typically starts with 'xoxb-'.
  • The configuration file ~/.slack-send will be created when the app run first time to store your configuration.

Configuration file (~/.slack-send)

You can also update the ~/.slack-send to set the default values for the message, channel, and attachments.

  • ApiToken: Your Slack API Key for a bot, typically starts with 'xoxb-'.
  • ApiUrl: The Slack API URL for sending messages.
  • Channels: An array of channel names to send the message to.
  • Attachments: An array of attachments to send with the message. The format of the attachments is the same as the JSON format for attachments in the Slack API. Example:
{
  "ApiToken": "<your Slack API Key for a bot, typically starts with 'xoxb-'>", 
  "ApiUrl": "https://slack.com/api/chat.postMessage",
  "Channels": [ "<your channel #1>", "<your channel #2>" ],
  "Attachments": [
    {
      "author_name": "<your sender name, i.e. GitHub Actions>",
      "author_icon": "https://github.com/fluidicon.png"
    }
  ]
}

'Attachments' JSON Format

If you prefer to have fine control of your Slack message, you can use the Slack's own JSON format (Attachments) directly, which will override the message and status options in '~/.slack-send'.

Example:

{
    "channel": "ABCDEBF1",
    "attachments": 
    [
        {
            "mrkdwn_in": ["text"],
            "color": "#36a64f",
            "pretext": "Optional pre-text that appears above the attachment block",
            "author_name": "author_name",
            "author_link": "https://flickr.com/bobby/",
            "author_icon": "https://placeimg.com/16/16/people",
            "title": "title",
            "title_link": "https://api.slack.com/",
            "text": "Optional `text` that appears within the attachment",
            "fields": 
            [
                {
                    "title": "A field's title",
                    "value": "This field's value",
                    "short": false
                },
                {
                    "title": "A short field's title",
                    "value": "A short field's value",
                    "short": true
                },
                {
                    "title": "A second short field's title",
                    "value": "A second short field's value",
                    "short": true
                }
            ],
            "thumb_url": "https://placekitten.com/g/200/200",
            "footer": "footer",
            "footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png",
            "ts": 123456789
        }
    ]
}

Reference to Slack Web API

Reference

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.4 114 5/19/2024
1.1.3 106 5/19/2024
1.1.2 100 5/19/2024
1.1.1 90 5/8/2024
1.1.0 83 5/8/2024
1.0.1 148 5/23/2023
1.0.0 138 5/22/2023