Skip to content
Client used to build and send Slack messages to a channel, using a slack incoming webhook which can easily configured
Branch: master
Clone or download
Latest commit ab39f8e Feb 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
SlackWebhook.Tests Bumped nuget packages Sep 14, 2018
SlackWebhook Bumped nuget packages Sep 14, 2018
.gitignore Added Rider gitignore Mar 17, 2018 Highlight example Sep 14, 2018
LICENSE Initial commit Oct 23, 2017 Reformated `` and changed links to relative rather than abso… Aug 8, 2018 Upgraded Vsxmd where macOS support was added Sep 14, 2018
SlackWebhook.sln Tried enabling VsxMd, to see if it works on macOS yet, it didn't Aug 7, 2018
SlackWebhook.sln.DotSettings Finished implementing the new actions for attachments Sep 14, 2018
appveyor.yml Updated nuget API key Feb 11, 2019
demo.png Demo Oct 27, 2017
icon.png Added SlackClient and simple integration test Oct 27, 2017


Build status NuGet

Provides a simple .Net client for using Slack's Incoming Webhooks URL's to send messages to a slack channel of your choosing.

The Webhooks API is pretty simple, but it always preferable to have a typed interface to use rather than an untyped (and undocumented) JSON object. So using this library should make it simpler to build a slack message and send it using a webhook URL.

See changelog for version history.



How to use

First install the nuget package:

PM> Install-Package SlackWebhook

Next simply use the SlackClient class to send a message:

await new SlackClient(webhookUrl).SendAsync(b => b
    .WithUsername("Slack Bot Name")
    .WithIcon(IconType.Url, "")
    .WithText("Something very interesting just happened")

How to obtain Incoming Webhook URL

In the above example i used the webhookUrl which you obtain by adding the Incoming WebHooks app configuration to the channel you want to send messages to (each url is tied to a specific channel, so if you want to sent to different channels, just add multiple configurations).

  1. Open
  2. Under Post to Channel select the channel you want to send to
  3. Press Add Incoming WebHooks integration
  4. Now copy the Webhook URL

What is supported?

Besides the message, the Slack hook also allows attachments which are pretty neat. In the above example I used a few attachments and fields to illustrate some of the uses. Especially the attachment fields are a good way to include extra detail in a table-like structure (by setting short flag on field, two fields will be shown in the attachment side-by-side for each row).

My example was generated by this code:

await new SlackClient(webhookUrl).SendAsync(b => b
    .WithText("Hello from *SlackWebhook*")
    .WithIcon(IconType.Url, "")
    .WithAttachment(a => a
        .WithTitle("How to install")
        .WithText("`PM> Install-Package SlackWebhook`")
    .WithAttachment(a => a
        .WithTitle("Find out more")
        .WithText("Find out more by taking a look at")
            "Use builder pattern",
            "```\n" +
            "await slackClient.SendASync(b => b\n" +
            "   .WithUsername(\"My Bot\")\n" +
            "   .WithText(\"Hello *World*\"));\n" +
            "Use object initializer",
            "```\n" +
            "await slackClient.SendAsync(new SlackMessage {\n" +
            "   Username = \"My Bot\",\n" +
            "   Text = \"Hello *World*\"\n" +
            "});\n" +


You can find the documentation in SlackWebhook, of particular interest are these:

  • ISlackClient: Interface of the SlackClient implementation used to send message
  • ISlackMessageBuilder: Inteface of the message builder used to configure your message
  • ISlackAttachmentBuilder: Interface of the attachment builder used to configure attachments added to your message
You can’t perform that action at this time.