5MInnov.Tools.WebhookNotification.Domain 1.0.4

dotnet add package 5MInnov.Tools.WebhookNotification.Domain --version 1.0.4                
NuGet\Install-Package 5MInnov.Tools.WebhookNotification.Domain -Version 1.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="5MInnov.Tools.WebhookNotification.Domain" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add 5MInnov.Tools.WebhookNotification.Domain --version 1.0.4                
#r "nuget: 5MInnov.Tools.WebhookNotification.Domain, 1.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 5MInnov.Tools.WebhookNotification.Domain as a Cake Addin
#addin nuget:?package=5MInnov.Tools.WebhookNotification.Domain&version=1.0.4

// Install 5MInnov.Tools.WebhookNotification.Domain as a Cake Tool
#tool nuget:?package=5MInnov.Tools.WebhookNotification.Domain&version=1.0.4                

5M Innov Webhook Notification

Description

5M Innov Webhook Notification is a NuGet package that allows sending notifications to a webhook, such as Microsoft Teams, Slack, etc. This project is useful for monitoring applications and being notified in real-time of a critical issue.

Main Features

  • Sending notifications to a webhook.
  • Application monitoring.
  • Real-time warning of critical issues.

Prerequisites

  • .NET 8.0 or later

Installation

You can install this package via the NuGet Package Manager Console:

Install-Package 5MInnov.Tools.WebhookNotification.Domain

or via the .NET CLI:

dotnet add package 5MInnov.Tools.WebhookNotification.Domain

Example of Use

First, you need to identify the destination webhook. For example, for Microsoft Teams, you need to create a channel and add a "Webhook" type connector and copy the webhook URL. Finally, you need to install the nuget 5MInnov.Tools.WebhookNotification.MicrosoftTeams.Adapters which allows sending notifications to a Microsoft Teams channel. If you wish to implement your own adapter, you can use the nuget 5MInnov.Tools.WebhookNotification.Ports.

Here is a basic example to send a notification:

using _5MInnov.Tools.WebhookNotification.Domain;
using _5MInnov.Tools.WebhookNotification.Domain.Models;
using _5MInnov.Tools.WebhookNotification.Domain.Ports;
using _5MInnov.Tools.WebhookNotification.Enums;
using _5MInnov.Tools.WebhookNotification.MicrosoftTeams.Adapters;
using _5MInnov.Tools.WebhookNotification.Ports;
using _5MInnov.Tools.WebhookNotification.Ports.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

IConfiguration Configuration = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory())
                    .AddJsonFile("appsettings.json")
                    .Build();

WebhookNotificationSettings webhookNotificationSettings = new WebhookNotificationSettings();
Configuration.Bind("WebhookNotificationSettings", webhookNotificationSettings);


var serviceProvider = new ServiceCollection()
            .AddSingleton<IWebhookNotificationSettings, WebhookNotificationSettings>(f => webhookNotificationSettings)
            .AddSingleton<IWebhookNotification, MsTeamsWebhookNotification>()
            .AddLogging()
            .AddSingleton<IWebhookNotificationService, WebhookNotificationService>()            
            .BuildServiceProvider();

IWebhookNotificationService? webhookNotificationService = serviceProvider.GetService<IWebhookNotificationService>();
if (webhookNotificationService != null)
{
    bool result = await webhookNotificationService.PostNotificationAsync(NotificationType.Error, "Test error message", description: "Description détaillée de l'erreur");
}

Webhook Configuration Example

First, you need to configure the Webhook Setting part in an appsettings.json file:

{
    "WebhookNotificationSettings": {
        "WebhookUrl": "https://webhoook.url",
        "InformationLinkUrl": "https://google.com",
        "Title": "Test App Console",
        "RaiseError" : "false"
    }
}

Contributors

License

This project is licensed under 5M Innov.

Other Relevant Information

For any questions or suggestions, please contact mtrezieres@5minnov.fr.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.

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
1.0.4 132 6/18/2024
1.0.2 96 6/18/2024
1.0.1 105 6/18/2024
1.0.0 95 6/14/2024

Fix 5MInnov.Tools.WebhookNotification.Ports version