Slackbot.Net.Endpoints 6.0.1

.NET 6.0
NuGet\Install-Package Slackbot.Net.Endpoints -Version 6.0.1
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.
dotnet add package Slackbot.Net.Endpoints --version 6.0.1
<PackageReference Include="Slackbot.Net.Endpoints" Version="6.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Slackbot.Net.Endpoints --version 6.0.1
#r "nuget: Slackbot.Net.Endpoints, 6.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Slackbot.Net.Endpoints as a Cake Addin
#addin nuget:?package=Slackbot.Net.Endpoints&version=6.0.1

// Install Slackbot.Net.Endpoints as a Cake Tool
#tool nuget:?package=Slackbot.Net.Endpoints&version=6.0.1

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 Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
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
6.0.1 2,085 11/9/2021
5.0.0 197 9/13/2021
5.0.0-feature0016-b4a9409 138 9/13/2021
4.1.1 268 2/5/2021
4.1.1-ci0008-df3bf2d 138 2/5/2021
4.1.1-ci0007-2d11ecd 143 2/5/2021
4.1.0 252 11/16/2020
4.1.0-pre001 191 11/16/2020
4.0.0 248 10/26/2020
4.0.0-preview002 483 10/23/2020
4.0.0-preview001 183 10/23/2020
3.0.0-preview125 264 10/2/2020
3.0.0-preview124 192 10/2/2020
3.0.0-preview123 218 9/30/2020
3.0.0-preview122 209 9/30/2020
3.0.0-preview121 224 9/17/2020
3.0.0-preview120 206 9/17/2020
3.0.0-preview111 199 9/9/2020
3.0.0-preview110 198 9/9/2020
3.0.0-preview104 280 9/8/2020
3.0.0-preview103 218 9/8/2020
3.0.0-preview102 207 9/8/2020
3.0.0-preview101 218 9/8/2020
3.0.0-preview100 231 9/8/2020
3.0.0-preview091 276 7/11/2020
3.0.0-preview090 418 7/10/2020
3.0.0-preview080 257 7/6/2020
3.0.0-preview071 232 6/30/2020
3.0.0-preview070 435 6/30/2020
3.0.0-preview061 369 6/23/2020
3.0.0-preview060 243 6/23/2020
3.0.0-preview052 273 6/22/2020
3.0.0-preview051 253 6/22/2020
3.0.0-preview050 275 6/22/2020
3.0.0-preview041 280 6/18/2020
3.0.0-preview040 243 6/18/2020
3.0.0-preview033 236 6/17/2020
3.0.0-preview032 258 6/15/2020
3.0.0-preview031 247 6/15/2020
3.0.0-preview030 246 6/12/2020
3.0.0-preview025 285 3/8/2020
3.0.0-preview024 244 3/6/2020
3.0.0-preview023 254 3/6/2020
3.0.0-preview022 239 3/6/2020
3.0.0-preview021 282 3/5/2020
3.0.0-preview020 312 3/5/2020
3.0.0-preview019 294 3/5/2020
3.0.0-preview018 299 3/4/2020
3.0.0-preview017 281 2/26/2020
3.0.0-preview016 345 2/23/2020
3.0.0-preview015 258 2/21/2020
3.0.0-preview014 261 2/21/2020
3.0.0-preview013 274 2/20/2020
3.0.0-preview011 292 2/19/2020
3.0.0-preview010 283 2/19/2020
3.0.0-preview008 276 2/19/2020
3.0.0-preview007 380 2/8/2020
3.0.0-preview006 350 2/8/2020
3.0.0-preview005 267 2/7/2020
3.0.0-preview004 285 1/28/2020
3.0.0-preview003 291 1/28/2020
3.0.0-preview002 280 1/28/2020
3.0.0-preview001 243 1/22/2020
2.0.1 322 1/17/2020
2.0.0 315 1/17/2020
1.0.8 374 1/10/2020
1.0.7 341 1/10/2020
1.0.6 338 1/10/2020
1.0.5 359 1/10/2020
1.0.4 350 1/10/2020
1.0.3 359 1/10/2020
1.0.2 333 1/9/2020
1.0.1 357 1/7/2020
1.0.1-beta015 289 1/3/2020
1.0.1-beta014 309 1/3/2020
1.0.1-beta013 339 1/3/2020
1.0.1-beta012 330 1/2/2020
1.0.1-beta011 295 1/2/2020
1.0.1-beta010 339 1/2/2020