All Projects → Expecho → Self-Hosted-Asp.Net-WebHooks

Expecho / Self-Hosted-Asp.Net-WebHooks

Licence: MIT license
Self hosted custom webhook receiver and sender

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Self-Hosted-Asp.Net-WebHooks

discord-twitter-webhooks
🤖 Stream tweets to Discord
Stars: ✭ 47 (-6%)
Mutual labels:  webhooks, webhook
tcWebHooks
WebHooks plugin for Teamcity. Supports many build states and payload formats.
Stars: ✭ 128 (+156%)
Mutual labels:  webhooks, webhook
elmah.io
ELMAH error logger for sending errors to elmah.io.
Stars: ✭ 31 (-38%)
Mutual labels:  asp-net, asp-net-web-api-2
Postmark webhooks
Lightweight quickstart app for receiving and processing webhooks from Postmark
Stars: ✭ 14 (-72%)
Mutual labels:  webhooks, webhook
sre.surmon.me
💻 SRE service for Surmon.me blog.
Stars: ✭ 34 (-32%)
Mutual labels:  webhooks, webhook
iris
Watch on Kubernetes events, filter and send them as standard wehbook to any system
Stars: ✭ 57 (+14%)
Mutual labels:  webhooks, webhook
github-release-notifier
Automatize tasks when a specific package got a new release - Github Release Notifier
Stars: ✭ 21 (-58%)
Mutual labels:  webhooks, webhook
Taviloglu.Wrike.ApiClient
.NET Client for Wrike API
Stars: ✭ 24 (-52%)
Mutual labels:  webhooks, webhook
Webhook
webhook is a lightweight incoming webhook server to run shell commands
Stars: ✭ 7,201 (+14302%)
Mutual labels:  webhooks, webhook
Achievibit
Github Gamification - Achievements system as a GitHub WebHook.
Stars: ✭ 93 (+86%)
Mutual labels:  webhooks, webhook
fregata
A self hosted REST API for message delivery
Stars: ✭ 19 (-62%)
Mutual labels:  self-hosted
subplayer
A music player frontend compatible with Subsonic backends
Stars: ✭ 66 (+32%)
Mutual labels:  self-hosted
ServiceStack.Webhooks
Add Webhooks to your ServiceStack services
Stars: ✭ 26 (-48%)
Mutual labels:  webhook
.oh-my-comma
The idea of a 'workbench for developers' - Shell utilities, tooling, and dotfiles for comma.ai's open-source self-driving car technology stack
Stars: ✭ 110 (+120%)
Mutual labels:  self-hosted
Home
Home for Blazor Extensions
Stars: ✭ 51 (+2%)
Mutual labels:  asp-net
webhook-relay
A simple Node.js server for queueing and relaying webhook requests
Stars: ✭ 30 (-40%)
Mutual labels:  webhooks
neko-rooms
Selfhosted collaborative browser - room management for n.eko
Stars: ✭ 262 (+424%)
Mutual labels:  self-hosted
signalilo
Forward alerts from Prometheus Alertmanager to Icinga2 via Webhooks
Stars: ✭ 57 (+14%)
Mutual labels:  webhook
frequency
Frequency Analytics - Open source private web analytics server
Stars: ✭ 67 (+34%)
Mutual labels:  self-hosted
self-hosted
Deploy Revolt using Docker.
Stars: ✭ 490 (+880%)
Mutual labels:  self-hosted

Asp.Net WebHooks

Self hosted custom webhook receiver and sender. More about webhooks: https://docs.asp.net/projects/webhooks/en/latest/. The product repo can be found here.

The solution contains 2 projects:

Receiver

This console application sends a registration for a Webhook and receives message of the Webhook. It also calls the api that triggers the Webhook to send a notification.

There are two ways to receive custom webhooks. One is using the build in mechanism that works by implementing your own WebHookHandler:

    public class CustomWebHookHandler : WebHookHandler
    {
        public override Task ExecuteAsync(string generator, WebHookHandlerContext context)
        {
            var notifications = context.GetDataOrDefault<CustomNotifications>();
            
            Console.WriteLine($"Received notification with payload:");
            foreach (var notification in notifications.Notifications)
            {
                Console.WriteLine(string.Join(", ", notification.Values));
            }

            return Task.FromResult(true);
        }
    }

(Source)

For this to work the next line is added to the web api configuration section

config.InitializeReceiveCustomWebHooks();

The other one is by creating your own web api controller that accepts a POST method like outlined here

The registrations of the webhook takes place in Program.cs

Web Api Host

This console application hosts the Webhook registration endpoints and hosts a web api controller that triggers the Webhook.

Most of the configuration to support custom webhook registrations is done here:

    var config = new HttpConfiguration();

    config.MapHttpAttributeRoutes();

    config.Routes.MapHttpRoute(
                    "DefaultApi",
                    "api/{controller}/{id}",
                    new { id = RouteParameter.Optional }
                );

    config.InitializeCustomWebHooks();
    config.InitializeCustomWebHooksApis(); 

    HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
    listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;

Usage

Set the startup projects of the solution to both projects and run the solution. Wait until both projects are fully loaded and then start interacting according to the instructions given.

Points of interest

There are some not so very well documented features you should know of before throwing the towel in the ring.

Endpoint verification

If you create your own controller with a POST method to facilitate incoming webhooks you have to have a GET method also that accepts an Echo parameter and returns the exact content of that parameter in plain text. Failure to do so will result in the following error when you register your webhook:

WebHook verification failed. Please ensure that the WebHook URI is valid and that the endpoint is accessible.

To disable this verification you can include the NoEcho parameter upon registration like this:

    // Create a webhook registration to our custom controller
    var registration = new Registration
    {
        WebHookUri = $"{webhookReceiverBaseAddress}/api/webhook?NoEcho=1",
        Description = "A message is posted.",
        Secret = "12345678901234567890123456789012",

        // Remove the line below to receive all events, including the MessageRemovedEvent event.
         Filters = new List<string> { "MessagePostedEvent" } 
     };

(See the registration and the GET method)

Persisted registrations

This example, as most examples found regarding this topic, uses an in-memory store to store registrations. To persist registration you can use an out-of-the box solution or write your own.

Secrets

When using a custom webhook handler it is important to have matching secrets using the MS_WebHookReceiverSecret_Custom application setting.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].