A Discord bot that monitors an email inbox, uses AI to summarize email content, and sends notifications to a Discord channel.
- Email Monitoring: Automatically checks for new emails in a specified inbox
- AI-Powered Summaries: Uses OpenAI to generate concise summaries of email content
- Discord Notifications: Sends formatted notifications to a Discord channel
- Email Filtering: Option to whitelist specific email addresses
- Python 3.6+ (or Docker)
- Discord account and server with admin privileges
- Email account with IMAP access
- OpenAI API key
- Clone this repository:
git clone https://github.com/irregularchat/20250404-Irregular-Hack-discord_bot
cd 20250404-Irregular-Hack-discord_bot
- Install dependencies:
pip install -r requirements.txt
- Clone this repository:
git clone https://github.com/irregularchat/20250404-Irregular-Hack-discord_bot
cd 20250404-Irregular-Hack-discord_bot
- Make sure Docker and Docker Compose are installed on your system.
- Copy the example environment file to create your configuration:
cp .env.example .env
- Edit the
.env
file with your actual credentials:
imap_server=your_imap_server.com
imap_user=your_email@example.com
imap_password=your_email_password
imap_port=993
imap_ssl=true
openai_api_key=your_openai_api_key
discord_token=your_discord_bot_token
discord_channel_id=your_discord_channel_id
whitelisted_email_addresses=email1@example.com,email2@example.com
Important: Never commit your
.env
file with real credentials to version control. The.env
file is already added to.gitignore
to prevent accidental commits.
When running the container in Unraid:
- In the Unraid Docker UI, click "Add Container"
- Find the container image or provide the repository URL
- In the "Advanced View" section, add the following environment variables with your actual values:
Variable Name | Example Value | Description |
---|---|---|
imap_server | imap.example.com | Your IMAP server address |
imap_user | your-email@example.com | Your email username |
imap_password | your-password-here | Your email password |
imap_port | 993 | IMAP port (usually 993 for SSL) |
imap_ssl | true | Whether to use SSL (true/false) |
openai_api_key | your-openai-api-key | Your OpenAI API key |
discord_token | your-discord-bot-token | Your Discord bot token |
discord_channel_id | your-discord-channel-id | Your Discord channel ID |
whitelisted_email_addresses | email1@example.com,email2@example.com | Comma-separated list of email addresses to monitor |
log_level | INFO | Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
log_concise | true | Whether to use concise logging (true/false) |
log_to_file | false | Whether to log to file (true/false) |
log_dir | logs | Directory to store logs |
- Configure other container settings as needed (port mappings, volumes, etc.)
- Click "Apply" to create and start the container
- Go to the Discord Developer Portal
- Create a new application and configure a bot
- Enable necessary bot permissions (Send Messages, Read Message History)
- Generate and copy your bot token to the
.env
file - Invite the bot to your server using the OAuth2 URL generator
Run the bot with:
python bot.py
Start the bot using Docker Compose:
# Build and start in foreground (see logs in real-time)
docker-compose up
# Build and start in background (detached mode)
docker-compose up -d
To view logs when running in detached mode:
# View all logs
docker-compose logs -f
# View only the last 100 lines
docker-compose logs -f --tail=100
To stop the bot:
# If running in foreground, press Ctrl+C
# If running in background
docker-compose down
To rebuild the container after making changes:
docker-compose build
docker-compose up -d
- In the Unraid Docker tab, click "Add Container"
- Search for the container or provide the repository URL
- Configure the environment variables as described in the Configuration section
- Set up the appropriate paths for volumes
- Apply the settings to start the container
The bot uses a Docker volume to persist logs. You can access these logs at any time, even after restarting the container.
The bot will:
- Connect to your email server via IMAP
- Check for new emails at regular intervals
- Generate AI summaries for new email content
- Send formatted notifications to your Discord channel
You can modify the following aspects:
- Check frequency in the bot configuration
- Email filter criteria
- Discord message format
- AI prompt for email summarization
This project is licensed under the MIT License.