Slackbot.Net.Endpoints 6.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Slackbot.Net.Endpoints --version 6.0.4
                    
NuGet\Install-Package Slackbot.Net.Endpoints -Version 6.0.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="Slackbot.Net.Endpoints" Version="6.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Slackbot.Net.Endpoints" Version="6.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Slackbot.Net.Endpoints" />
                    
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 Slackbot.Net.Endpoints --version 6.0.4
                    
#r "nuget: Slackbot.Net.Endpoints, 6.0.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.
#addin nuget:?package=Slackbot.Net.Endpoints&version=6.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Slackbot.Net.Endpoints&version=6.0.4
                    
Install as a Cake Tool

Slackbot.NET

Build

What?

An opinionated ASP.NET Core middleware to create simple Slackbots using the Slack event API.

Install

Download it from NuGet:NuGet

$ dotnet add package slackbot.net.endpoints

Supported events

  • challenge
  • app_mention
  • view_submission
  • member_joined_channel

Configuration

A slack app can be distributed either as a single-workspace application (1 single Slack token), or as a distributed Slack application where other workspaces can install it them self either via a web page, or via the Slack App Store.

Single workspace Slack app

var builder = WebApplication.CreateBuilder(args);

// Needed to verify that incoming event payloads are from Slack
builder.Services.AddAuthentication()
                .AddSlackbotEvents(c =>
                    c.SigningSecret = Environment.GetEnvironmentVariable("SIGNING_SECRET")
                );

// Setup event handlers
builder.Services.AddSlackBotEvents()
                .AddAppMentionHandler<DoStuff>()


var app = builder.Build();
app.UseSlackbot(); // event endpoint
app.Run();

class DoStuff : IHandleAppMentions
{
    public bool ShouldHandle(AppMentionEvent slackEvent) => slackEvent.Text.Contains("hi");

    public Task<EventHandledResponse> Handle(EventMetaData meta, AppMentionEvent @evt)
    {
        Console.WriteLine("Doing stuff!");
        return Task.FromResult(new EventHandledResponse("yolo"));
    }
}

Advanced: Distributed Slack app

Implement the ITokenStore to store/remote on install/uninstall flows.

var builder = WebApplication.CreateBuilder(args);

// Needed to verify that incoming event payloads are from Slack
builder.Services.AddAuthentication()
               .AddSlackbotEvents(c => c.
                   SigningSecret = Environment.GetEnvironmentVariable("SIGNING_SECRET")
               );

builder.Services.AddSlackbotDistribution(c => {
   c.CLIENT_ID = Environment.GetEnvironmentVariable("CLIENT_ID");
   c.CLIENT_SECRET = Environment.GetEnvironmentVariable("CLIENT_SECRET");
});

// Setup event handlers
builder.Services.AddSlackBotEvents<MyTokenStore>()
               .AddAppMentionHandler<DoStuff>()


var app = builder.Build();
app.Map("/authorize", a => a.UseSlackbotDistribution()); // OAuth callback endpoint
app.Map("/events", a => a.UseSlackbot()); // event endpoint
app.Run();


/// Bring-your-own-token-store:
class MyTokenStore : ITokenStore
{
   // _db is some persistance technology you choose (sql, mongo, whatever)
   public Task<Workspace Delete(string teamId) => _db.DeleteByTeamId(teamId);
   public Task Insert(Workspace slackTeam) => _db.Insert(slackTeam);
}

Samples

Check the samples.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

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
8.0.2 147 6/5/2025
8.0.1 139 6/4/2025
7.0.1 8,351 12/1/2023
7.0.0 159 11/15/2023
6.0.7 365 4/7/2023
6.0.6 243 4/4/2023
6.0.5 236 4/3/2023
6.0.4 298 3/27/2023
6.0.3 273 3/23/2023
6.0.2 287 3/19/2023
6.0.1 6,840 11/9/2021
5.0.0 454 9/13/2021
4.1.1 533 2/5/2021
4.1.0 498 11/16/2020
4.0.0 494 10/26/2020
2.0.1 607 1/17/2020
2.0.0 582 1/17/2020
1.0.8 653 1/10/2020
1.0.7 604 1/10/2020
1.0.6 589 1/10/2020
1.0.5 621 1/10/2020
1.0.4 612 1/10/2020
1.0.3 611 1/10/2020
1.0.2 613 1/9/2020
1.0.1 634 1/7/2020