Table of Contents

Class TelegramChannel

Namespace
JD.AI.Channels.Telegram
Assembly
JD.AI.Channels.Telegram.dll

Telegram channel adapter using Telegram.Bot SDK. Supports private chats, groups, and inline commands.

public sealed class TelegramChannel : IChannel, IAsyncDisposable
Inheritance
TelegramChannel
Implements
Inherited Members

Constructors

TelegramChannel(string)

public TelegramChannel(string botToken)

Parameters

botToken string

Properties

ChannelType

Unique channel type identifier (e.g., "discord", "signal", "web").

public string ChannelType { get; }

Property Value

string

DisplayName

Display name for this channel instance.

public string DisplayName { get; }

Property Value

string

IsConnected

Whether the channel is currently connected and healthy.

public bool IsConnected { get; }

Property Value

bool

Methods

ConnectAsync(CancellationToken)

Connects to the messaging platform.

public Task ConnectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

DisconnectAsync(CancellationToken)

Gracefully disconnects.

public Task DisconnectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

SendMessageAsync(string, string, CancellationToken)

Sends a message to the specified conversation/thread.

public Task SendMessageAsync(string conversationId, string content, CancellationToken ct = default)

Parameters

conversationId string
content string
ct CancellationToken

Returns

Task

Events

MessageReceived

Raised when a new inbound message arrives.

public event Func<ChannelMessage, Task>? MessageReceived

Event Type

Func<ChannelMessage, Task>

Remarks

Uses Func<ChannelMessage, Task> instead of EventHandler to support async handlers.