Skip to main content
Telegrator is a modern reactive framework for building Telegram bots in C# with aspect-oriented design and mediator-based dispatching. This guide will help you get started with installation and setup.

Prerequisites

Before installing Telegrator, ensure you have:

.NET SDK

  • .NET Standard 2.0+ for core package
  • .NET 8.0+ for hosting packages

Bot Token

Get your bot token from @BotFather on Telegram

Package Overview

Telegrator consists of three main NuGet packages:

Telegrator

Core FrameworkThe main package with handlers, filters, and reactive capabilities

Telegrator.Hosting

.NET Generic HostIntegration with Microsoft.Extensions.Hosting for background services

Telegrator.Hosting.Web

ASP.NET CoreWebhook support and ASP.NET Core integration

Installation

Option 1: Core Package Only

Install the core Telegrator package for basic bot functionality:
dotnet add package Telegrator
The core package targets .NET Standard 2.0, making it compatible with .NET Framework 4.6.1+, .NET Core 2.0+, and .NET 5.0+.

Option 2: With Generic Host Support

For production-ready applications with dependency injection, configuration, and logging:
dotnet add package Telegrator.Hosting
Telegrator.Hosting requires .NET 8.0 or later and automatically includes the core Telegrator package.

Option 3: With ASP.NET Core & Webhooks

For web applications that use webhooks instead of long polling:
dotnet add package Telegrator.Hosting.Web
Telegrator.Hosting.Web requires .NET 8.0 or later and includes both Telegrator and Telegrator.Hosting packages.

Dependencies

Each package has the following key dependencies:

Telegrator (Core)

  • Telegram.Bot (v22.6.2) - Official Telegram Bot API client
  • Includes Roslyn-based code generators and analyzers

Telegrator.Hosting

  • Microsoft.Extensions.Hosting (v9.0.5) - Generic host implementation
  • Microsoft.Extensions.Http (v9.0.5) - HTTP client factory
  • Requires all core Telegrator dependencies

Telegrator.Hosting.Web

  • Telegram.Bot.AspNetCore (v22.5.0) - ASP.NET Core integration
  • Microsoft.AspNetCore.App (framework reference)
  • Requires all Telegrator.Hosting dependencies

Verify Installation

After installation, verify that the packages are correctly installed:
1

Check project file

Open your .csproj file and confirm the PackageReference entries are present:
<ItemGroup>
  <PackageReference Include="Telegrator" Version="1.15.8" />
  <!-- Or Telegrator.Hosting or Telegrator.Hosting.Web -->
</ItemGroup>
2

Restore packages

Restore NuGet packages to download dependencies:
dotnet restore
3

Build the project

Build your project to ensure everything compiles:
dotnet build

Next Steps

Now that you have Telegrator installed, you can:

Quick Start

Create your first bot in minutes

Core Concepts

Learn about handlers, filters, and the mediator pattern

API Reference

Explore the complete API documentation

Examples

View example projects on GitHub

Troubleshooting

If you encounter version conflicts with Telegram.Bot or Microsoft.Extensions packages, try:
dotnet list package --include-transitive
This shows all package versions including transitive dependencies. Update conflicting packages manually in your .csproj file.
Ensure your project targets the correct framework:
  • Core package: .NET Standard 2.0+
  • Hosting packages: .NET 8.0+
Check your TargetFramework in the .csproj file:
<TargetFramework>net8.0</TargetFramework>
Telegrator includes Roslyn analyzers that may show warnings. These help ensure correct usage patterns. To disable specific warnings:
<PropertyGroup>
  <NoWarn>$(NoWarn);TELEGRATOR001</NoWarn>
</PropertyGroup>
Having trouble? Check the GitHub issues or ask questions in the repository discussions.

Build docs developers (and LLMs) love