agentconnect.agents.telegram.telegram_tools module¶
Telegram-specific tools for use with the AgentConnect framework.
This module defines tools that enable an AI agent to interact with Telegram, manage announcements, handle user groups, and send messages using advanced aiogram v3 capabilities.
- class SendMessageInput(**data)¶
Bases:
BaseModelInput schema for sending a message to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendMessageOutput(**data)¶
Bases:
BaseModelOutput schema for sending a message to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendPhotoInput(**data)¶
Bases:
BaseModelInput schema for sending a photo to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendPhotoOutput(**data)¶
Bases:
BaseModelOutput schema for sending a photo to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendDocumentInput(**data)¶
Bases:
BaseModelInput schema for sending a document to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendDocumentOutput(**data)¶
Bases:
BaseModelOutput schema for sending a document to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendLocationInput(**data)¶
Bases:
BaseModelInput schema for sending a location to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendLocationOutput(**data)¶
Bases:
BaseModelOutput schema for sending a location to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendVoiceInput(**data)¶
Bases:
BaseModelInput schema for sending a voice message to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class SendVoiceOutput(**data)¶
Bases:
BaseModelOutput schema for sending a voice message to Telegram.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class DownloadFileInput(**data)¶
Bases:
BaseModelInput schema for downloading a file from Telegram.
- Parameters:
file_id (str)
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class DownloadFileOutput(**data)¶
Bases:
BaseModelOutput schema for downloading a file from Telegram.
- Parameters:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class CreateAnnouncementInput(**data)¶
Bases:
BaseModelInput schema for creating an announcement.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class CreateAnnouncementOutput(**data)¶
Bases:
BaseModelOutput schema for creating an announcement.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class PublishAnnouncementInput(**data)¶
Bases:
BaseModelInput schema for publishing an announcement to groups.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class PublishAnnouncementOutput(**data)¶
Bases:
BaseModelOutput schema for publishing an announcement.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ListGroupsInput(**data)¶
Bases:
BaseModelInput schema for listing registered groups.
- Parameters:
limit (int)
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ListGroupsOutput(**data)¶
Bases:
BaseModelOutput schema for listing registered groups.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class DeleteAnnouncementInput(**data)¶
Bases:
BaseModelInput schema for deleting a draft announcement.
- Parameters:
announcement_id (str)
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class DeleteAnnouncementOutput(**data)¶
Bases:
BaseModelOutput schema for deleting an announcement.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class EditMessageInput(**data)¶
Bases:
BaseModelInput schema for editing a message.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class EditMessageOutput(**data)¶
Bases:
BaseModelOutput schema for editing a message.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class TelegramTools(bot, group_ids, groups_file)¶
Bases:
objectContains tools for interacting with Telegram through the AgentConnect framework.
This class provides tools for sending messages, managing announcements, and interacting with Telegram users and groups.
- async send_message(chat_id, text, reply_to_message_id=None, parse_mode=None)¶
Send a text message to a Telegram chat.
IMPORTANT: DO NOT USE THIS FOR RESPONDING TO THE USER WHO SENT THE CURRENT MESSAGE. This tool should ONLY be used when you need to send a message to a DIFFERENT chat/group than the one where the current conversation is happening.
For normal responses to the user, just return your response text directly in your reply.
- Parameters:
- Return type:
- Returns:
Dict with success status and message ID or error
- async send_photo(chat_id, photo_url, caption=None, reply_to_message_id=None)¶
Send a photo to a Telegram chat.
- Parameters:
- Return type:
- Returns:
Dict with success status and message ID or error
- async send_document(chat_id, document_url, caption=None, reply_to_message_id=None)¶
Send a document to a Telegram chat.
- Parameters:
- Return type:
- Returns:
Dict with success status and message ID or error
- async send_location(chat_id, latitude, longitude, reply_to_message_id=None)¶
Send a location to a Telegram chat.
- async send_voice(chat_id, voice_url, caption=None, reply_to_message_id=None)¶
Send a voice message to a Telegram chat.
- Parameters:
- Return type:
- Returns:
Dict with success status and message ID or error
- async download_file(file_id)¶
Download a file from Telegram.
- async edit_message(chat_id, message_id, text)¶
Edit an existing message.
- async create_announcement(text, photo_url='')¶
Create a new announcement.
- async publish_announcement(announcement_id, groups=None)¶
Publish an announcement to groups.
- async list_groups(limit=10)¶
List registered groups.
- async delete_announcement(announcement_id)¶
Delete a draft announcement.