Skip to content

Client used to build and send Slack messages to a channel, using a slack incoming webhook which can easily configured


Notifications You must be signed in to change notification settings


Repository files navigation


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


Client used to build and send Slack messages to a channel, using a slack incoming webhook which can easily configured