- π€ Modern Discord Bot with slash commands
- π CSV Transaction Processing from bank exports
- π· Interactive Categorization with Discord UI
- πΎ Session Management for resuming interrupted processes
- β° Daily Reminders for transaction processing
- π― Auto-categorization with customizable rules
/upload- Upload a CSV file to start processing transactions/resume- Resume a previously paused session/status- Check your current processing progress/cancel- Cancel and clear your current session/cached- View and process cached transactions
- Python 3.8+
- Discord Bot Token
- Virtual environment (recommended)
-
Clone the repository
git clone <your-repo-url> cd FinanceAutomation
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure the bot
# Copy configuration template cp src/config_settings.example.py src/config_settings.py # Edit config_settings.py with your values nano src/config_settings.py
-
Set up Discord Bot
- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" section
- Copy the token to your
src/config_settings.pyfile - Enable required intents: Message Content, Server Members
-
Set up Google Sheets (Optional)
If you want to export transactions to Google Sheets:
a. Go to Google Cloud Console b. Create a new project or select an existing one c. Enable the Google Sheets API and Google Drive API d. Go to "Credentials" β "Create Credentials" β "Service Account" e. Download the JSON key file f. Save it as
src/config/google_service_account.jsong. Share your Google Sheet with the service account email h. Update yoursrc/config_settings.pyfile with Google Sheets configuration -
Run the bot
cd src python bot.py
Edit src/config_settings.py to configure the bot:
# Discord Bot Token (required)
DISCORD_TOKEN = "your_discord_bot_token_here"
# Daily Reminder Configuration
DAILY_REMINDER_TIME = "09:00" # 24-hour format
REMINDER_CHANNEL_ID = 1234567890123456789 # Channel ID for reminders
MENTION_USER_IDS = [
123456789012345678, # Your Discord user ID
987654321098765432, # Other user IDs
]
# CSV Download Link (optional)
CSV_DOWNLOAD_LINK = "" # URL where users can download CSV files
# Google Sheets Configuration (optional)
GOOGLE_SHEETS_ENABLED = True
GSHEET_NAME = "Your Sheet Name"
GSHEET_TAB = "Your Tab Name"Add Discord user IDs to the MENTION_USER_IDS list in config_settings.py for daily reminder mentions.
The bot expects CSV files with the following columns (ASN Bank format):
- Date
- Account IBAN
- Counterparty IBAN
- Counterparty Name
- Transaction Amount
- Currency
- Transaction Code
- Remittance Information
Edit src/constants.py to customize income and expense categories:
class ExpenseCategory(str, Enum):
FOOD = ("Food", r"food|restaurant|grocery")
TRANSPORT = ("Transport", r"transport|uber|taxi")
# Add your categories...Add regex patterns in src/constants.py:
CATEGORIZATION_RULES_EXPENSE = {
r"JUMBO|PICNIC|LIDL": ("Groceries", ExpenseCategory.FOOD),
r"Shell|BP|Texaco": ("Fuel", ExpenseCategory.TRANSPORT),
# Add your rules...
}- Never commit your Discord bot token or API keys
- Keep your
config_settings.pyfile secure - Add
src/config_settings.pyto.gitignoreif it contains sensitive data - Regularly rotate your bot token if compromised
If you encounter issues:
- Check the bot logs for error messages
- Verify your Discord bot permissions
- Ensure your CSV format matches the expected structure
- Check that all required configuration is set in
src/config_settings.py
See CHANGES.md for detailed change history.
cd src
python bot.py/upload- Upload a CSV file to start processing transactions/status- Check your current processing session status/resume- Resume a previously paused session/cancel- Cancel and clear your current session/cached- View and process cached transactions
The bot will send daily reminders at 09:00 (configurable) to upload CSV files for processing.
src/
βββ bot.py # Main bot file
βββ bot_commands.py # Slash command definitions
βββ config_settings.py # Configuration settings
βββ constants.py # Category enums and rules
βββ asnexport.py # Legacy CSV processing (deprecated)
βββ config/
β βββ google_service_account.json # Google Sheets credentials
β βββ spaarpot_uuid_map.py # Savings account mapping
βββ finance_core/
βββ csv_helper.py # CSV loading and normalization
βββ export.py # Main processing logic
βββ google_sheets.py # Google Sheets integration
βββ session_management.py # Session persistence
βββ ui/
βββ transaction_prompt.py # Interactive UI components
data/ # Runtime data directory
βββ sessions/ # User session persistence
βββ uploads/ # Uploaded CSV files- Daily reminder time: Edit
DAILY_REMINDER_TIMEinconfig_settings.py - Upload directory: Edit
UPLOAD_DIRinconfig_settings.py(default:data/uploads) - Session directory: Edit
SESSION_DIRinconfig_settings.py(default:data/sessions) - Transaction categories: Edit
ExpenseCategoryandIncomeCategoryinconstants.py - Auto-categorization rules: Edit
CATEGORIZATION_RULES_*inconstants.py
The bot uses a dedicated data/ directory for runtime files:
data/sessions/- User session files for resuming interrupted processingdata/uploads/- Uploaded CSV files from Discord
These directories are automatically created when the bot starts. This structure keeps source code separate from runtime data.
Make sure you're running the bot from the src/ directory:
cd src
python bot.pyInstall missing packages:
pip install discord.py- Check that the bot token is correct in
src/config_settings.py - Ensure the bot has proper permissions in your Discord server
- Check the console for error messages