Skip to content
A comprehensive Slack API client for .NET
C# PowerShell Shell
Branch: master
Clone or download
soxtoby Merge pull request #25 from mrmurb/verify-request-signature
Implementing request signature verification
Resolves #10, #22
Latest commit 139c7d0 Nov 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
SlackNet.AspNetCore revert changes to IsValidToken Nov 4, 2019
SlackNet.Bot Basic Blocks API Jun 24, 2019
SlackNet.Example Removing old token Jun 24, 2019
SlackNet.Tests Implements new Post in ISlackApiClient Aug 26, 2019
SlackNet expose PostEphemeral in IChatApi Aug 29, 2019
.gitattributes Add .gitignore and .gitattributes. Jul 1, 2017
.gitignore Adding Cake build script Dec 25, 2017
SlackNet.sln Adding bot example project May 26, 2019
SlackNet.sln.DotSettings Updating dictionary and fixing typo May 26, 2019
appveyor.yml Adding AppVeyor config Dec 25, 2017
build.cake Adding Cake build script Dec 25, 2017
build.ps1 Adding Cake build script Dec 25, 2017 Adding Cake build script Dec 25, 2017
cake.config Adding Cake build script Dec 25, 2017
license.txt Adding license Dec 25, 2017


An easy-to-use and flexible API for writing Slack bots in .NET, built on top of a comprehensive Slack API client.

Getting Started

There are three NuGet packages available to install, depending on your use case.


To use the Web API:

var api = new SlackApiClient("<your API token here>");

then start calling methods:

var channels = await api.Channels.List();

To use the RTM API:

var rtm = new SlackRtmClient("<your API token here>");
await rtm.Connect();
rtm.Events.Subscribe(/* handle every event */);
rtm.Messages.Subscribe(/* handle message events */);


var bot = new SlackBot("<your bot token here>");
await bot.Connect();

You can handle messages in a number of ways:

// .NET events
bot.OnMessage += (sender, message) => { /* handle message */ };

// Adding handlers
class MyMessageHandler: IMessageHandler { 
    public Task HandleMessage(IMessage message) {
        // handle message
bot.AddHandler(new MyMessageHandler());

// Subscribing to Rx stream
bot.Messages.Subscribe(/* handle message */);

The easiest way to reply to messages is by using their ReplyWith method. Replies will be sent to same channel and thread as the message being replied to.

message.ReplyWith("simple text message");
message.ReplyWith(new BotMessage {
    Text = "more complicated message",
    Attachments = { new Attachment { Title = "attachments!" } }
message.ReplyWith(async () => {
    // Show typing indication in Slack while message is build built
    var asyncInfo = await SomeAsyncMethod();
    return new BotMessage { Text = "async message: " + asyncInfo };

SlackNet.Bot includes a simplified API for getting common information from Slack:

var user = await bot.GetUserByName("someuser");
var channels = await bot.GetChannels();
// etc.

Everything is cached, so go nuts getting the information you need. You can clear the cache with bot.ClearCache().


In your Startup class:

public void ConfigureServices(IServiceCollection services)
    services.AddSlackNet(c => c.UseApiToken("<your API token here>"));

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    app.UseSlackNet(c => c.VerifyWith("<your verification token here>"));

See the SlackNet.EventsExample project for more detail.

You can’t perform that action at this time.