VOOZH about

URL: https://www.nuget.org/packages/Slack.Webhooks/

⇱ NuGet Gallery | Slack.Webhooks 1.1.6




👁 Image
Slack.Webhooks 1.1.6

dotnet add package Slack.Webhooks --version 1.1.6
 
 
NuGet\Install-Package Slack.Webhooks -Version 1.1.6
 
 
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.Webhooks" Version="1.1.6" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Slack.Webhooks" Version="1.1.6" />
 
Directory.Packages.props
<PackageReference Include="Slack.Webhooks" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Slack.Webhooks --version 1.1.6
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Slack.Webhooks, 1.1.6"
 
 
#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.
#:package Slack.Webhooks@1.1.6
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Slack.Webhooks&version=1.1.6
 
Install as a Cake Addin
#tool nuget:?package=Slack.Webhooks&version=1.1.6
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Slack.Webhooks 👁 Continuous Stuff
👁 NuGet Version

Even simpler integration with Slack's Incoming/Outgoing webhooks API for .net

IMPORTANT

On Feb 19th 2020 Slack will end support for TLS version 1.0 and 1.1. This means you may (depending on your .NET version) need to force the use of TLS1.2.

If you receive an error stating that "The underlying connection was closed:" it's quite possibly a TLS issue. You can work around this by setting the default TLS version using the following:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Change Log

v1.1.4
  • Add Block elements to Attachments
v1.1.3
  • Fixes potential deadlock issues
v1.1.2
  • Fix SlackMessage.Clone does not clone all properties
v1.1.0
  • Support Slack's Block Kit with SlackMessage.Blocks property
  • Support Thread replies with SlackMessage.ThreadId property
  • Changed the whole Emoji setup. SlackMessage.Emoji is now a string and Emoji.* are constants. This shouldn't cause problems in the most part!
  • Allow HttpClient to be injected into SlackClient.
  • SlackClient implements IDisposable to match the contained HttpClient instance even though this isn't the recommended usage. SlackClient, like HttpClient, there should only be a single instance of this class within the lifecycle of your application, for more information on why see: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

v1.0.0 BREAKING CHANGES

We no longer use RestSharp in favour of HttpClient - this however means that .NET 4.0 and below are no longer supported.

Also, the PostAsync method signature has changed. The return type is now Task<bool> in place of Task<IRestResponse> which was tied directly to RestSharp.

Outgoing Webhooks

Blog Post

Incoming Webhooks

Requirements:

  1. You must first enable the Webhooks integration for your Slack Account to get the Token. You can enable it here: https://slack.com/services/new/incoming-webhook
  2. Slack.Webhooks depends on JSON.net
  3. Compatible with .NET Standard 2.0. If you need .NET Framework 4.5 or older .NET Standard support, use version 1.1.5 or earlier.

Download:

Package is hosted on Nuget and can be installed from the package manager:

PM> Install-Package Slack.Webhooks

For older .NET framework support:

PM> Install-Package Slack.Webhooks -Version 0.1.8

Then, create a SlackClient with your Webhook URL.

var slackClient = new SlackClient("[YOUR_WEBHOOK_URL]");

Create a new SlackMessage

var slackMessage = new SlackMessage
{
 Channel = "#random",
 Text = "Your message",
 IconEmoji = Emoji.Ghost,
 Username = "nerdfury"
};

By default the text can contain Markdown but this default behaviour can be disabled:

slackMessage.Mrkdwn = false;

More info on message formatting can be found in the Docs

Attachments can be added to a message:

var slackAttachment = new SlackAttachment
 {
 Fallback = "New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>",
 Text = "New open task *[Urgent]*: <http://url_to_task|Test out Slack message attachments>",
 Color = "#D00000",
 Fields =
 new List<SlackField>
 {
 new SlackField
 {
 Title = "Notes",
 Value = "This is much *easier* than I thought it would be."
 }
 }
 };
slackMessage.Attachments = new List<SlackAttachment> {slackAttachment};

Please see the Docs for further info on attachments.

You can also provide a list of Block objects in SlackMessage.Blocks to create more interactive content:

Blocks.Divider

slackMessage.Blocks = new List<Block>
 {
 new Blocks.Divider()
 };

Blocks.Image

slackMessage.Blocks = new List<Block>
 {
 new Blocks.Image
 {
 AltText = "Sexy Skyline",
 ImageUrl = "https://placekitten.com/500/500",
 Title = new TextObject("Hello, this is text")
 }
 };

Blocks.Context

slackMessage.Blocks = new List<Block>
 {
 new Blocks.Context
 {
 Elements = new List<Interfaces.IContextElement>
 {
 new TextObject("_markdown_")
 {
 Type = TextObject.TextType.Markdown
 },
 new Elements.Image
 {
 ImageUrl = "https://placekitten.com/200/300", AltText = "Random Kitten"
 }
 }
 }
 };

Blocks.Section

slackMessage.Blocks = new List<Block>
 {
 new Blocks.Section
 {
 Text = new TextObject("_markdown_")
 {
 Type = TextObject.TextType.Markdown
 },
 Fields = new List<TextObject>
 {
 new TextObject { Text = "Field 1" },
 new TextObject { Text = "Field 2" },
 new TextObject { Text = "Field 3" }
 }
 }
 };

Blocks.Section with Accessory

var confirmation = new Confirmation
 {
 Confirm = new TextObject("This OK?"),
 Text = new TextObject("This is the Text"),
 Deny = new TextObject("This is the Deny Text"),
 Title = new TextObject("Title")
 };

var options = new List<Option>
 {
 new Option
 {
 Text = new TextObject("OPtion1"),
 Value = "option1"
 },
 new Option
 {
 Text = new TextObject("OPtion2"),
 Value = "option2"
 },
 new Option
 {
 Text = new TextObject("OPtion3"),
 Value = "option3"
 },
 };

var optionGroups = new List<OptionGroup>
 {
 new OptionGroup
 {
 Label = new TextObject("Label 1"),
 Options = options
 },
 new OptionGroup
 {
 Label = new TextObject("Label 2"),
 Options = options
 }
 };


Elements.Element element;
element = new Button
 {
 Text = new TextObject { Text = "Button Text" },
 ActionId = "Button1_Click",
 };

element = new Elements.Overflow
 {
 Confirm = confirmation,
 Options = options
 };

element = new Elements.DatePicker
 {
 Placeholder = new TextObject("Select a date")
 };

element = new Elements.SelectUsers
 {
 Placeholder = new TextObject("Select a user..."),
 Confirm = confirmation
 };

element = new Elements.SelectChannels
 {
 Placeholder = new TextObject("Select a channel"),
 Confirm = confirmation
 };

element = new Elements.SelectConversations
 {
 Placeholder = new TextObject("Select a conversation"),
 Confirm = confirmation
 };

element = new Elements.SelectStatic
 {
 Options = options,
 Placeholder = new TextObject("Options Placeholder")
 };

element = new Elements.SelectStatic
 {
 OptionGroups = optionGroups,
 Placeholder = new TextObject("OptionGroup placeholder")
 };

element = new Elements.MultiSelectUsers
 {
 Placeholder = new TextObject("Select a user..."),
 Confirm = confirmation
 };

element = new Elements.MultiSelectChannels
 {
 Placeholder = new TextObject("Select a channel")
 };

element = new Elements.MultiSelectConversations
 {
 Placeholder = new TextObject("Select a conversation")
 };

element = new Elements.MultiSelectStatic
 {
 Options = options,
 Placeholder = new TextObject("Options Placeholder")
 };

element = new Elements.MultiSelectStatic
 {
 OptionGroups = optionGroups,
 Placeholder = new TextObject("OptionGroup placeholder")
 };

slackMessage.Blocks = new List<Block>
 {
 new Blocks.Section
 {
 Text = new TextObject("_markdown_")
 {
 Type = TextObject.TextType.Markdown
 },
 Accessory = element
 }
 };

And Post it to Slack

slackClient.Post(slackMessage);
Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (52)

Showing the top 5 NuGet packages that depend on Slack.Webhooks:

Package Downloads
Ark.Tools.NLog

NLog configuration helper and extensions for Ark standard configuration using code and not config files.

Reo.Core.Serilog.Sinks.SlackWebHook

Package Description

Ark.Tools.Solid

SOLID base for Handler pattern

Ark.Tools.ResourceWatcher

Watcher over listable resources with support for change detection, retry limit and state.

Ark.Tools.FtpClient.Core

Core abstractions for FtpClient

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Slack.Webhooks:

Repository Stars
thomhurst/ModularPipelines
Write your pipelines in C# !
Version Downloads Last Updated
1.1.6 3,492 6/10/2026
1.1.5 8,001,724 2/9/2021
1.1.4 1,479,550 4/30/2020
1.1.3 1,071,426 3/2/2020
1.1.2 10,285 2/26/2020
1.1.1 2,926 2/26/2020
1.1.0 137,914 11/26/2019
1.0.6 2,287,122 2/4/2019
1.0.5 383,385 5/17/2018
1.0.4 17,668 4/25/2018
1.0.3 32,881 3/20/2018
1.0.2 13,147 3/9/2018
1.0.1 3,698 3/9/2018
1.0.0 16,185 2/27/2018
1.0.0-rc2 12,942 12/7/2017
1.0.0-rc1 2,314 12/6/2017
0.1.8 108,700 8/6/2017
0.1.7 149,232 10/14/2016
0.1.6 335,094 10/15/2015
0.1.5 15,311 8/18/2015
Loading failed

Targets .NET Standard 2.0, updates Newtonsoft.Json, and keeps compatibility for sending Slack webhook messages with attachments and blocks.