TelegramNotifier 1.0.0

Additional Details

Version 1.0.0 has dependency resolution issues. Please upgrade to version 1.0.1 for better compatibility with .NET 6+ projects.

There is a newer version of this package available.
See the version list below for details.
dotnet add package TelegramNotifier --version 1.0.0
                    
NuGet\Install-Package TelegramNotifier -Version 1.0.0
                    
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="TelegramNotifier" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TelegramNotifier" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TelegramNotifier" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TelegramNotifier --version 1.0.0
                    
#r "nuget: TelegramNotifier, 1.0.0"
                    
#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.
#:package TelegramNotifier@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TelegramNotifier&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TelegramNotifier&version=1.0.0
                    
Install as a Cake Tool

TelegramNotifier

A lightweight .NET library for sending logs and exceptions to Telegram with support for queuing and background processing.


Key Features

  • Sending messages to Telegram
  • Automatic exception reporting (Exception)
  • Sending long logs as .txt files
  • Support for Telegram forum topics (message_thread_id)
  • Asynchronous processing via queue (Channel + BackgroundWorker)
  • Formatting logs into a readable view (code blocks)

Supported Platforms

  • .NET 6
  • .NET 7
  • .NET 8
  • .NET 9

Installation

dotnet add package TelegramNotifier

Configuration

Add settings to appsettings.json:

{
  "TelegramNotifier": {
    "Enabled": true,
    "BotToken": "YOUR_BOT_TOKEN",
    "ChatId": "-100XXXXXXXXXX"
  }
}

Explanations

Parameter Description
Enabled Enables or disables sending to Telegram
BotToken Your Telegram bot token
ChatId ID of the chat or group where messages will be sent
MessageThreadId (optional) ID of the group topic, if using forum chats

๐Ÿง  Important

  • MessageThreadId is only needed if you have a group with topics
  • If it is a regular chat โ€” you can leave it blank
  • Nothing will be sent without Enabled = true

Registration

builder.Services.AddTelegramNotifier(builder.Configuration);

Usage

Automatic Error Reporting

If you plug in the middleware, all unhandled errors will be automatically sent to Telegram:

app.UseTelegramNotifier();

Sending a Regular Message Manually

If you need to send a message yourself:

public class TestController : ControllerBase
{
    private readonly ITelegramNotifier _notifier;

    public TestController(ITelegramNotifier notifier)
    {
        _notifier = notifier;
    }

    [HttpGet("send")]
    public async Task<IActionResult> Send()
    {
        await _notifier.SendMessageAsync("Test message");
        return Ok();
    }
}

Sending an Exception Manually

If you want to send an exception manually:

try
{
    throw new Exception("Test exception");
}
catch (Exception ex)
{
    await _notifier.SendExceptionAsync(ex);
}

Security

  • Do not store BotToken in open source code
  • Use appsettings or environment secrets

๐Ÿ“ How to get ChatId

To send messages to Telegram, you need to find out the ChatId.


๐Ÿค– 1. For a private chat with the bot

  1. Send any message to your bot (e.g., hi)
  2. Open in your browser:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  1. Find the field:
"chat": {
  "id": 123456789
}

๐Ÿ‘‰ this is your ChatId


๐Ÿ‘ฅ 2. For a group

  1. Add the bot to the group
  2. Send any message to the group
  3. Open:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  1. Find:
"chat": {
  "id": -1001234567890
}

๐Ÿ‘‰ this is the group's ChatId


๐Ÿงต 3. For forum groups (Topics)

If you have a group with topics:

  • ChatId โ€” is the ID of the entire group
  • MessageThreadId โ€” is the ID of the specific topic

Example:

"message_thread_id": 6

โš ๏ธ Important

  • Without a message in the chat, getUpdates may show nothing
  • If you are using a webhook โ€” disable it first:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/deleteWebhook

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 is compatible.  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 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.  net9.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
2.0.0 122 6/4/2026
1.0.1 165 4/16/2026
1.0.0 126 4/16/2026 1.0.0 is deprecated because it has critical bugs.