This project is an example ai agent for property managers. The app:
- Connects to an email client
- Triages unread messages
- Generates draft replies using an LLM (OpenAI GPT-4.1)
- Triggers relevant workflows (such as creating action items)
- Connects to a Gmail inbox using IMAP (via
imaplib) - Fetches unread or recent messages
- Loads relevant tenant information (mocked for demo purposes)
- Generates draft replies using OpenAI's GPT-4.1 LLM
- Extracts and processes action items (e.g., maintenance requests) as JSON
- Sends email replies to tenants
- Clone the repository
- Install dependencies:
pip install openai python-dotenv backoff
- Set up your
.envfile with the following variables:EMAIL_ADDRESS=[email protected] EMAIL_PASSWORD=your_gmail_password_or_app_password IMAP_SERVER=imap.gmail.com OPENAI_API_KEY=your_openai_api_key
Note: For Gmail, you may need to use an App Password if 2FA is enabled.
- Run the app:
python main.py
main.py— Entry point, runs the end-to-end cycleemail_client.py— Handles IMAP connection, email fetching, and sendingemail_handling.py— Loads tenant info, generates LLM replies, processes workflowspost_processing.py— Extracts draft replies and action items from LLM output
- Use actual objects to represent tenants, actions, etc.
- Add persistence
- The classics: add error handling, logging, etc.
- Support HTML email parsing and attachments
- Integrate with a workflow system to create action items
- All relevant tenant data is available or can be mocked
- The LLM can generate useful replies and action items from the email content
- The app is run with access to the relevant inbox
- LLM Used: OpenAI GPT-4.1 via the
openaiPython SDK - Prompting: The LLM is prompted to extract intent, generate a draft reply, and suggest an action item in JSON
- Post-processing: Regex is used to extract the draft reply and action item from the LLM output
- Development: I used cusor.
