bot_warehouse — Telegram bot for transferring Excel reports to Google Sheets
A Telegram bot built with Python that receives Excel files from a work chat and transfers their contents to the specified sheet of a Google spreadsheet.

Slide 1 of 2
DESCRIPTION
The bot automates the upload of warehouse reports: employees send .xlsx files to a group chat, and the bot transfers the data to a Google Sheet. It is implemented using pure requests with a custom long polling getUpdates loop. Only messages from a specified group chat are processed (filtered by chat_id); files are recognized by their extension and MIME type.
File reading and Sheets writing
The file is downloaded via Telegram getFile, read by openpyxl in read-only mode (data_only) into a temporary file. Data is written to Google Sheets using gspread: a service account (api_gg.json) is authorized in scopes spreadsheets/drive, and the content of the target sheet is completely replaced (worksheet.clear + update with value_input_option='USER_ENTERED').
Routing reports to sheets
The non-trivial part is routing the report to the correct sheet. The file name is matched with a mapping table
TOOLS USED
- Python
- Telegram Bot API
- requests
- Google Sheets API
- gspread
- google-auth
- openpyxl
- regular expressions
- Git
RESULT
- Implemented reception of Excel files from a specified group chat with filtering by chat_id and recognition by extension/MIME.
- Implemented file downloading via getFile and reading with openpyxl in read-only mode through a temporary file.
- Implemented data writing to the correct Google Sheets sheet via gspread with complete replacement of the sheet's content.
- Implemented routing of the report to the sheet by file name with Unicode normalization and removal of numerical/date suffixes using regular expressions.
AI-ASSISTANT
Ask a question about this project