Skip to content

API Reference parrot.integrations.telegram.crew.payload

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.telegram.crew.payload

View source

DataPayload — file exchange between agents via Telegram documents.

Handles downloading documents from Telegram messages, uploading files to the group, MIME type validation, CSV convenience methods, and temp file management.

Class DataPayload

Manages file exchange between agents in a Telegram crew.

Parameter Type Default Description
temp_dir str '/tmp/parrot_crew' Directory for temporary file storage.
max_file_size_mb int 50 Maximum allowed file size in megabytes.
allowed_mime_types Optional[List[str]] None List of allowed MIME types for document exchange.

Method DataPayload.validate_mime

Check if a MIME type is in the allowed list.

validate_mime(mime_type: str) -> bool

Parameter Type Default Description
mime_type str The MIME type to validate.

Returns: bool — True if allowed, False otherwise.

Method DataPayload.download_document

Download a document from a Telegram message to the temp directory.

download_document(bot: Bot, message: Message) -> Optional[str]

Parameter Type Default Description
bot Bot The aiogram Bot instance.
message Message The Telegram message containing the document.

Returns: Optional[str] — Path to the downloaded file, or None if validation fails.

Method DataPayload.send_document

Upload a file to the Telegram group as a document.

If the caption exceeds 1024 characters, it is sent as a separate message after the document.

send_document(bot: Bot, chat_id: int, file_path: str, caption: str = '', reply_to_message_id: Optional[int] = None) -> None

Parameter Type Default Description
bot Bot The aiogram Bot instance.
chat_id int Target chat ID.
file_path str Path to the file to upload.
caption str '' Optional caption for the document.
reply_to_message_id Optional[int] None Optional message ID to reply to.

Method DataPayload.send_csv

Serialize a pandas DataFrame to CSV and send as a document.

send_csv(bot: Bot, chat_id: int, dataframe, filename: str = 'data.csv', caption: str = '', reply_to_message_id: Optional[int] = None) -> None

Parameter Type Default Description
bot Bot The aiogram Bot instance.
chat_id int Target chat ID.
dataframe A pandas DataFrame to serialize.
filename str 'data.csv' Output filename for the CSV.
caption str '' Optional caption for the document.
reply_to_message_id Optional[int] None Optional message ID to reply to.

Method DataPayload.cleanup_file

Remove a temporary file if it exists.

cleanup_file(file_path: str) -> None

Parameter Type Default Description
file_path str Path to the file to remove.

Method DataPayload.cleanup_all

Remove all files in the temp directory.

cleanup_all() -> None

Attribute TELEGRAM_CAPTION_LIMIT

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally