TelegramElement
The TelegramElement
enables real-time chat interactions between a Telegram bot and users using Telethon. It handles authentication, incoming messages based on configurable criteria, and outgoing message sending.
Instantiation
Arguments:
app_id: str
Telegram application ID. If not provided, loads from TELEGRAM_APP_ID
env var.
api_hash: str
Telegram API hash. If not provided, loads from TELEGRAM_API_HASH
env var.
bot_token: str
Telegram bot token for authentication. If not provided, loads from TELEGRAM_BOT_TOKEN
env var.
start_message_with: Union[int, str], optional
Chat ID or username to message upon startup.
on_message_criteria: callable, optional
Function to filter incoming messages (default: only private chats). Receives a Telethon Message
.
Input Ports
Port Name | Payload Type | Behavior |
---|---|---|
assistant_message_emit_input |
MessagePayload | Sends assistant-originated MessagePayload s to Telegram users via DM. |
Output Ports
Port Name | Payload Type | Behavior |
---|---|---|
user_message_output |
MessagePayload | Emits messages received from Telegram users. |
assistant_message_output |
MessagePayload | Emits messages sent by the assistant. |