Slackbot.Net.Endpoints 6.0.6

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.6                
NuGet\Install-Package Slackbot.Net.Endpoints -Version 6.0.6                
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.6" />                
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.6                
#r "nuget: Slackbot.Net.Endpoints, 6.0.6"                
#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.
// Install Slackbot.Net.Endpoints as a Cake Addin
#addin nuget:?package=Slackbot.Net.Endpoints&version=6.0.6

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

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. 
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
7.0.2-feature0002-58bd1f7 165 12/6/2023
7.0.1 3,414 12/1/2023
7.0.1-bug0001-b9e7b58 112 12/1/2023
7.0.0 150 11/15/2023
7.0.0-feature0022-dc8652f 117 11/15/2023
6.1.0-feature0021-ee28ead 129 7/10/2023
6.1.0-feature0021-43c2f96 113 7/10/2023
6.0.7 332 4/7/2023
6.0.6 210 4/4/2023
6.0.5 208 4/3/2023
6.0.4 270 3/27/2023
6.0.3 237 3/23/2023
6.0.2 254 3/19/2023
6.0.1 6,735 11/9/2021
5.0.0 400 9/13/2021
5.0.0-feature0016-b4a9409 261 9/13/2021
4.1.1 472 2/5/2021
4.1.1-ci0008-df3bf2d 248 2/5/2021
4.1.1-ci0007-2d11ecd 237 2/5/2021
4.1.0 441 11/16/2020
4.1.0-pre001 299 11/16/2020
4.0.0 434 10/26/2020
4.0.0-preview002 605 10/23/2020
4.0.0-preview001 299 10/23/2020
3.0.0-preview125 378 10/2/2020
3.0.0-preview124 308 10/2/2020
3.0.0-preview123 329 9/30/2020
3.0.0-preview122 333 9/30/2020
3.0.0-preview121 353 9/17/2020
3.0.0-preview120 312 9/17/2020
3.0.0-preview111 317 9/9/2020
3.0.0-preview110 306 9/9/2020
3.0.0-preview104 399 9/8/2020
3.0.0-preview103 332 9/8/2020
3.0.0-preview102 326 9/8/2020
3.0.0-preview101 336 9/8/2020
3.0.0-preview100 348 9/8/2020
3.0.0-preview091 388 7/11/2020
3.0.0-preview090 552 7/10/2020
3.0.0-preview080 384 7/6/2020
3.0.0-preview071 340 6/30/2020
3.0.0-preview070 543 6/30/2020
3.0.0-preview061 497 6/23/2020
3.0.0-preview060 354 6/23/2020
3.0.0-preview052 391 6/22/2020
3.0.0-preview051 358 6/22/2020
3.0.0-preview050 392 6/22/2020
3.0.0-preview041 393 6/18/2020
3.0.0-preview040 358 6/18/2020
3.0.0-preview033 356 6/17/2020
3.0.0-preview032 386 6/15/2020
3.0.0-preview031 357 6/15/2020
3.0.0-preview030 379 6/12/2020
3.0.0-preview025 403 3/8/2020
3.0.0-preview024 365 3/6/2020
3.0.0-preview023 364 3/6/2020
3.0.0-preview022 346 3/6/2020
3.0.0-preview021 394 3/5/2020
3.0.0-preview020 423 3/5/2020
3.0.0-preview019 406 3/5/2020
3.0.0-preview018 411 3/4/2020
3.0.0-preview017 410 2/26/2020
3.0.0-preview016 484 2/23/2020
3.0.0-preview015 366 2/21/2020
3.0.0-preview014 375 2/21/2020
3.0.0-preview013 397 2/20/2020
3.0.0-preview011 407 2/19/2020
3.0.0-preview010 399 2/19/2020
3.0.0-preview008 392 2/19/2020
3.0.0-preview007 485 2/8/2020
3.0.0-preview006 467 2/8/2020
3.0.0-preview005 387 2/7/2020
3.0.0-preview004 394 1/28/2020
3.0.0-preview003 405 1/28/2020
3.0.0-preview002 396 1/28/2020
3.0.0-preview001 369 1/22/2020
2.0.1 538 1/17/2020
2.0.0 517 1/17/2020
1.0.8 584 1/10/2020
1.0.7 538 1/10/2020
1.0.6 522 1/10/2020
1.0.5 557 1/10/2020
1.0.4 538 1/10/2020
1.0.3 543 1/10/2020
1.0.2 540 1/9/2020
1.0.1 568 1/7/2020
1.0.1-beta015 398 1/3/2020
1.0.1-beta014 425 1/3/2020
1.0.1-beta013 446 1/3/2020
1.0.1-beta012 429 1/2/2020
1.0.1-beta011 406 1/2/2020
1.0.1-beta010 464 1/2/2020