Search Results for

    Show / Hide Table of Contents

    WebHook

    Framework has WebHook support for receiving updates via TelegramModularFramework.WebHook package and ASP.Net.
    For WebHook example project see This Sample

    Minimal Project

    Program.cs

    var builder = WebApplication.CreateBuilder(args);
    
    builder.Host.ConfigureTelegramBotWebHookHost((context, c) =>
    {
        c.TelegramBotClientOptions = new TelegramBotClientOptions(context.Configuration["Telegram:Token"] ?? throw new InvalidOperationException("Token must be non null"));
        c.SecretToken = context.Configuration["Telegram:WebHook:SecretToken"] ?? throw new InvalidOperationException("Secret must be non null");
    }).AddTelegramModulesService();
    
    builder.Services.Configure<TelegramBotWebHookHostConfiguration>(builder.Configuration.GetSection("WebHookConfiguration"));
    
    builder.Services.AddHostedService<TelegramHandler>();
    
    var app = builder.Build();
    
    app.MapTelegramWebHook();
    
    app.Run();
    

    For TelegramHandler and Modules samples go to This Guide

    • Improve this Doc
    ☀
    ☾
    In This Article
    Back to top
    TelegramModularFramework (c) 2022-2022
    ☀
    ☾