![]() |
VOOZH | about |
dotnet add package TwitchLib.EventSub.Webhooks --version 3.0.0
NuGet\Install-Package TwitchLib.EventSub.Webhooks -Version 3.0.0
<PackageReference Include="TwitchLib.EventSub.Webhooks" Version="3.0.0" />
<PackageVersion Include="TwitchLib.EventSub.Webhooks" Version="3.0.0" />Directory.Packages.props
<PackageReference Include="TwitchLib.EventSub.Webhooks" />Project file
paket add TwitchLib.EventSub.Webhooks --version 3.0.0
#r "nuget: TwitchLib.EventSub.Webhooks, 3.0.0"
#:package TwitchLib.EventSub.Webhooks@3.0.0
#addin nuget:?package=TwitchLib.EventSub.Webhooks&version=3.0.0Install as a Cake Addin
#tool nuget:?package=TwitchLib.EventSub.Webhooks&version=3.0.0Install as a Cake Tool
Provides an easy way to setup a Twitch EventSub Webhooks Server
Setting up a Twitch EventSub server can be daunting and has some moving parts that you could get wrong. TwitchLib.EventSub.Webhooks was build with that in mind and makes it as easy as it can get. You only need a few lines of code to add and configure it.
| NuGet | 👁 TwitchLib.EventSub.Webhooks |
|
|---|---|---|
| Package Manager | PM> |
Install-Package TwitchLib.EventSub.Webhooks -Version 3.0.0 |
| .NET CLI | > |
dotnet add package TwitchLib.EventSub.Webhooks --version 3.0.0 |
| PackageReference | <PackageReference Include="TwitchLib.EventSub.Webhooks" Version="3.0.0" /> |
|
| Paket CLI | > |
paket add TwitchLib.EventSub.Webhooks --version 3.0.0 |
void to Task)On prefix (OnChannelChatMessage ⇒ ChannelChatMessage)TwitchLib.EventSub.Core Nuget Package, for better management across future EventSub transport Client libraries.
That means their namespace changed from TwitchLib.EventSub.Webhooks.Core.EventArgs.* to TwitchLib.EventSub.Core.EventArgs.*.TwitchLib.EventSub.Core package, (namespace changed from TwitchLib.EventSub.Webhooks.Core.Models to TwitchLib.EventSub.Core.Models)
but to ensure that the models can be used across projects some changes had to be made:
Notification in TwitchLibEventSubEventArgs<T> were renamed to PayloadHeaders(Dictionary<string,string>) in TwitchLibEventSubEventArgs<T> were replaced with Metadata(EventSubMetadata) and before you can access the values you have to cast it to WebhookEventSubMetadataEventSubSubscriptionTransport was renamed to EventSubTransportVersion 2.0 contains some breaking changes.
TwitchLib.EventSub.Core for better management across future EventSub transport Client libraries
That means their namespace changed from TwitchLib.EventSub.Webhooks.Core.SubscriptionTypes / TwitchLib.EventSub.Webhooks.Core.Models to TwitchLib.EventSub.Core.SubscriptionTypes / TwitchLib.EventSub.Core.ModelsDateTime internally and in models was changed to use DateTimeOffset insteadITwitchEventSubWebhooks / TwitchEventSubWebhooks were renamed to IEventSubWebhooks/ EventSubWebhooksThe usual requirements that Twitch has for EventSub webhooks do still apply!
Step 1: Create a new ASP.NET Core project (.NET 8.0 and up)
Step 2: Install the TwitchLib.EventSub.Webhooks nuget package. (See above on how to do that)
Step 3: Add necessary services and config to the DI Container
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTwitchLibEventSubWebhooks(config =>
{
config.CallbackPath = "/eventsub/";
config.Secret = "supersecuresecret";
});
builder.Services.AddHostedService<EventSubHostedService>();
!!! If you follow these steps your callback url will https://{your_domain}/eventsub/ !!!
Step 4: Put the TwitchLib.EventSub.Webhooks middleware in the request pipeline
var app = builder.Build();
app.UseTwitchLibEventSubWebhooks();
app.Run();
Step 5: Create the HostedService and listen for events
using TwitchLib.EventSub.Core.EventArgs.Channel;
using TwitchLib.EventSub.Webhooks.Core;
using TwitchLib.EventSub.Webhooks.Core.EventArgs;
using TwitchLib.EventSub.Webhooks.Core.Models;
namespace TwitchLib.EventSub.Webhooks.Example
{
public class EventSubHostedService : IHostedService
{
private readonly ILogger<EventSubHostedService> _logger;
private readonly IEventSubWebhooks _eventSubWebhooks;
public EventSubHostedService(ILogger<EventSubHostedService> logger, IEventSubWebhooks eventSubWebhooks)
{
_logger = logger;
_eventSubWebhooks = eventSubWebhooks;
}
public Task StartAsync(CancellationToken cancellationToken)
{
_eventSubWebhooks.OnError += OnError;
_eventSubWebhooks.UnknownEventSubNotification += OnUnknownEventSubNotification;
_eventSubWebhooks.ChannelChatMessage += OnChannelChatMessage;
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
_eventSubWebhooks.OnError -= OnError;
_eventSubWebhooks.UnknownEventSubNotification -= OnUnknownEventSubNotification;
_eventSubWebhooks.ChannelChatMessage -= OnChannelChatMessage;
return Task.CompletedTask;
}
private async Task OnChannelChatMessage(object? sender, ChannelChatMessageArgs e)
{
_logger.LogInformation($"@{e.Payload.Event.ChatterUserName} #{e.Payload.Event.BroadcasterUserName}: {e.Payload.Event.Message.Text}");
}
private async Task OnError(object? sender, OnErrorArgs e)
{
_logger.LogError($"Reason: {e.Reason} - Message: {e.Message}");
}
// Handling notifications that are not (yet) implemented
private async Task OnUnknownEventSubNotification(object? sender, UnknownEventSubNotificationArgs e)
{
var metadata = (WebhookEventSubMetadata)e.Metadata;
_logger.LogInformation("Received event that has not yet been implemented: type:{type}, version:{version}", metadata.SubscriptionType, metadata.SubscriptionVersion);
switch ((metadata.SubscriptionType, metadata.SubscriptionVersion))
{
case ("channel.chat.message", "1"): /*code to handle the event*/ break;
default: break;
}
}
}
}
That is all that you need to do to setup a Twitch EventSub Webhook Server with TwitchLib.EventSub.Webhooks. Easy isn't it?
Alternatively you can also just clone the https://github.com/TwitchLib/TwitchLib.EventSub.Webhooks/tree/master/TwitchLib.EventSub.Webhooks.Example
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on TwitchLib.EventSub.Webhooks:
| Package | Downloads |
|---|---|
|
PolyhydraGames.Twitch
Twitch integration library used by ChannelCheevos and related services — wraps TwitchLib.Api, TwitchLib.Client, and TwitchLib.EventSub for internal Polyhydra services. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 3,048 | 11/22/2025 |
| 3.0.0-preview.6.fac6e74 | 267 | 11/13/2025 |
| 3.0.0-preview.4.4c8405b | 276 | 11/13/2025 |
| 3.0.0-preview.2.cbf482f | 216 | 10/23/2025 |
| 3.0.0-preview.1.2c180de | 227 | 8/31/2025 |
| 2.3.0 | 14,523 | 2/12/2023 |
| 2.2.0 | 2,061 | 11/21/2022 |
| 2.1.0 | 516 | 11/8/2022 |
| 2.0.0 | 628 | 10/19/2022 |
| 1.3.1 | 602 | 9/21/2022 |
| 1.3.0 | 563 | 8/28/2022 |
| 1.2.0 | 593 | 8/9/2022 |
| 1.1.1 | 1,295 | 11/22/2021 |
| 1.1.0 | 556 | 9/1/2021 |
| 1.0.0 | 554 | 8/25/2021 |
.NET 10 update
added EventSubDeduplicationService
Breaking Changes
Events are now asynchronous (return value changed from `void` to `Task`)
Events dropped the `On` prefix (`OnChannelChatMessage` => `ChannelChatMessage`)
All EventSub events were moved to `TwitchLib.EventSub.Core` Nuget Package, for better management across future EventSub transport Client libraries.
That means their namespace changed from `TwitchLib.EventSub.Webhooks.Core.EventArgs.*` to `TwitchLib.EventSub.Core.EventArgs.*`.
Like Events, all EventSub Models were moved to the `TwitchLib.EventSub.Core` package, (namespace changed from `TwitchLib.EventSub.Webhooks.Core.Models` to `TwitchLib.EventSub.Core.Models`) but to ensure that the models can be used across projects some changes had to be made:
- `Notification` in `TwitchLibEventSubEventArgs T` were renamed to `Payload`
- `Headers`(`Dictionary string,string`) in `TwitchLibEventSubEventArgs T ` were replaced with `Metadata`(`EventSubMetadata`) and before you can access the values you have to cast it to `WebhookEventSubMetadata`
- `EventSubSubscriptionTransport` was renamed to `EventSubTransport`