Slackbot.Net.Endpoints
6.0.4
There is a newer version of this package available.
See the version list below for details.
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.
paket add Slackbot.Net.Endpoints --version 6.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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.
// Install Slackbot.Net.Endpoints as a Cake Addin #addin nuget:?package=Slackbot.Net.Endpoints&version=6.0.4 // Install Slackbot.Net.Endpoints as a Cake Tool #tool nuget:?package=Slackbot.Net.Endpoints&version=6.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Slackbot.NET
What?
An opinionated ASP.NET Core middleware to create simple Slackbots using the Slack event API.
Install
$ 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 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. |
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 | 162 | 12/6/2023 |
7.0.1 | 3,225 | 12/1/2023 |
7.0.1-bug0001-b9e7b58 | 109 | 12/1/2023 |
7.0.0 | 146 | 11/15/2023 |
7.0.0-feature0022-dc8652f | 113 | 11/15/2023 |
6.1.0-feature0021-ee28ead | 125 | 7/10/2023 |
6.1.0-feature0021-43c2f96 | 109 | 7/10/2023 |
6.0.7 | 328 | 4/7/2023 |
6.0.6 | 206 | 4/4/2023 |
6.0.5 | 204 | 4/3/2023 |
6.0.4 | 265 | 3/27/2023 |
6.0.3 | 232 | 3/23/2023 |
6.0.2 | 251 | 3/19/2023 |
6.0.1 | 6,731 | 11/9/2021 |
5.0.0 | 396 | 9/13/2021 |
5.0.0-feature0016-b4a9409 | 257 | 9/13/2021 |
4.1.1 | 468 | 2/5/2021 |
4.1.1-ci0008-df3bf2d | 244 | 2/5/2021 |
4.1.1-ci0007-2d11ecd | 233 | 2/5/2021 |
4.1.0 | 437 | 11/16/2020 |
4.1.0-pre001 | 295 | 11/16/2020 |
4.0.0 | 430 | 10/26/2020 |
4.0.0-preview002 | 600 | 10/23/2020 |
4.0.0-preview001 | 294 | 10/23/2020 |
3.0.0-preview125 | 374 | 10/2/2020 |
3.0.0-preview124 | 304 | 10/2/2020 |
3.0.0-preview123 | 325 | 9/30/2020 |
3.0.0-preview122 | 329 | 9/30/2020 |
3.0.0-preview121 | 349 | 9/17/2020 |
3.0.0-preview120 | 308 | 9/17/2020 |
3.0.0-preview111 | 313 | 9/9/2020 |
3.0.0-preview110 | 302 | 9/9/2020 |
3.0.0-preview104 | 395 | 9/8/2020 |
3.0.0-preview103 | 327 | 9/8/2020 |
3.0.0-preview102 | 320 | 9/8/2020 |
3.0.0-preview101 | 330 | 9/8/2020 |
3.0.0-preview100 | 344 | 9/8/2020 |
3.0.0-preview091 | 384 | 7/11/2020 |
3.0.0-preview090 | 546 | 7/10/2020 |
3.0.0-preview080 | 378 | 7/6/2020 |
3.0.0-preview071 | 336 | 6/30/2020 |
3.0.0-preview070 | 538 | 6/30/2020 |
3.0.0-preview061 | 493 | 6/23/2020 |
3.0.0-preview060 | 350 | 6/23/2020 |
3.0.0-preview052 | 387 | 6/22/2020 |
3.0.0-preview051 | 354 | 6/22/2020 |
3.0.0-preview050 | 388 | 6/22/2020 |
3.0.0-preview041 | 389 | 6/18/2020 |
3.0.0-preview040 | 354 | 6/18/2020 |
3.0.0-preview033 | 352 | 6/17/2020 |
3.0.0-preview032 | 382 | 6/15/2020 |
3.0.0-preview031 | 353 | 6/15/2020 |
3.0.0-preview030 | 375 | 6/12/2020 |
3.0.0-preview025 | 399 | 3/8/2020 |
3.0.0-preview024 | 361 | 3/6/2020 |
3.0.0-preview023 | 360 | 3/6/2020 |
3.0.0-preview022 | 342 | 3/6/2020 |
3.0.0-preview021 | 390 | 3/5/2020 |
3.0.0-preview020 | 419 | 3/5/2020 |
3.0.0-preview019 | 402 | 3/5/2020 |
3.0.0-preview018 | 407 | 3/4/2020 |
3.0.0-preview017 | 406 | 2/26/2020 |
3.0.0-preview016 | 480 | 2/23/2020 |
3.0.0-preview015 | 362 | 2/21/2020 |
3.0.0-preview014 | 371 | 2/21/2020 |
3.0.0-preview013 | 393 | 2/20/2020 |
3.0.0-preview011 | 403 | 2/19/2020 |
3.0.0-preview010 | 395 | 2/19/2020 |
3.0.0-preview008 | 388 | 2/19/2020 |
3.0.0-preview007 | 481 | 2/8/2020 |
3.0.0-preview006 | 463 | 2/8/2020 |
3.0.0-preview005 | 383 | 2/7/2020 |
3.0.0-preview004 | 389 | 1/28/2020 |
3.0.0-preview003 | 401 | 1/28/2020 |
3.0.0-preview002 | 392 | 1/28/2020 |
3.0.0-preview001 | 364 | 1/22/2020 |
2.0.1 | 533 | 1/17/2020 |
2.0.0 | 512 | 1/17/2020 |
1.0.8 | 579 | 1/10/2020 |
1.0.7 | 534 | 1/10/2020 |
1.0.6 | 518 | 1/10/2020 |
1.0.5 | 553 | 1/10/2020 |
1.0.4 | 534 | 1/10/2020 |
1.0.3 | 539 | 1/10/2020 |
1.0.2 | 536 | 1/9/2020 |
1.0.1 | 564 | 1/7/2020 |
1.0.1-beta015 | 393 | 1/3/2020 |
1.0.1-beta014 | 420 | 1/3/2020 |
1.0.1-beta013 | 442 | 1/3/2020 |
1.0.1-beta012 | 424 | 1/2/2020 |
1.0.1-beta011 | 401 | 1/2/2020 |
1.0.1-beta010 | 459 | 1/2/2020 |