Skip to content

BillJesser/Inbox-Companion

Repository files navigation

Inbox Companion

https://email-companion-frontend.vercel.app/

Overview

Inbox Companion helps you triage an Outlook inbox by walking a user through Microsoft's device-login flow, scanning a chosen date range of emails with Together AI, and sending a single HTML summary of actionable tasks back to the signed-in mailbox.

Architecture

  • Frontend: Vite + React single-page app (frontend/inbox-companion/src/App.jsx) deployed to Vercel. Handles the Microsoft sign-in UX, date selection, and polling.
  • Backend: Python AWS Lambda (lambda_function.py) exposed via a Lambda Function URL or API Gateway. Orchestrates device flow auth, pulls messages from Microsoft Graph, classifies them with Together AI, and sends summary email via SMTP.
  • Support tooling:
    • test.py drives the Lambda remotely (Function URL or direct invoke).
    • together.py is a quick smoke test against Together's REST API.
    • package/ contains the vendored build that matches the deployment ZIPs in this repo.

Key Features

  • Guided Microsoft device-code login that surfaces the verification URL and one-time code.
  • Date-range input to limit Microsoft Graph queries to a specific window.
  • Together AI classification that extracts actionable tasks from each email body.
  • HTML summary email (via SMTP) listing subjects, senders, and task summaries.
  • Deployed frontend: https://email-companion-frontend.vercel.app/

Prerequisites

  • Node.js 18+ and npm for the frontend.
  • Python 3.9+ (matches the Lambda runtime) for packaging/testing the backend.
  • AWS account with permissions to deploy and manage Lambda + Function URL or API Gateway.
  • Microsoft Entra app registration with delegated Mail.Read and User.Read scopes.
  • Together AI API key with access to your chosen model.
  • SMTP service (e.g., Gmail with App Password) to send the summary email.

Environment Variables

Backend (Lambda) Description
CLIENT_ID Azure app's client ID.
AUTHORITY Microsoft login authority, e.g. https://login.microsoftonline.com/common or your tenant.
SCOPES Comma-separated Microsoft Graph scopes (default Mail.Read,User.Read).
TOGETHER_API_KEY Together AI API key (never commit real keys).
TOGETHER_MODEL Optional Together model override (default openai/gpt-oss-20b).
TEMPERATURE Optional Together sampling temperature (default 0.0).
MAX_TOKENS Optional Together max completion tokens (default 128).
SMTP_HOST SMTP server host (e.g., smtp.gmail.com).
SMTP_PORT SMTP port (default 587).
SMTP_USER SMTP username/login.
SMTP_PASS SMTP password or app password.
FROM_EMAIL From address used when sending the summary.
SMTP_STARTTLS Set to false to skip STARTTLS (default true).
SEND_ONLY_IF_TASKS true to suppress summary email when no tasks found.
Frontend Description
VITE_FUNCTION_URL Base URL for the deployed Lambda (must include trailing slash or the app will add one).

Store backend secrets in Lambda environment configuration or a secure config service. For local scripts (together.py, test.py), you can use a .env file but avoid committing real credentials.

Local Development

Backend

  1. Create and activate a virtual environment.
  2. Install dependencies: pip install -r requirements.txt.
  3. Set the environment variables above (via shell, .env, or AWS credentials configuration).
  4. Exercise the Lambda remotely with python test.py (defaults to the Function URL in .env; override via env vars as needed).
  5. Optionally run python together.py to validate the Together API key before deploying.

For local emulation with AWS SAM, point template.yaml at your source, adjust environment variables, and run sam local start-api.

Frontend

  1. cd frontend/inbox-companion
  2. Install packages: npm install
  3. Create .env with VITE_FUNCTION_URL=<your lambda url>
  4. Start dev server: npm run dev
  5. Build for production: npm run build

Ensure CORS is enabled on the Lambda Function URL (or API Gateway) for the frontend origin.

Deployment Notes

  • Lambda: Package lambda_function.py with dependencies (see deployment-package.zip for reference) and deploy to AWS Lambda running Python 3.9+. Configure environment variables and enable a Function URL (or API Gateway) with CORS for your frontend domain.
  • Frontend: Deploy the Vite build output (frontend/inbox-companion/dist) to your hosting provider (Vercel in production). Set the VITE_FUNCTION_URL environment variable in the hosting platform.
  • Rotate any sample keys found in this repository; treat them as compromised.

Troubleshooting

  • Device flow stuck on "pending": verify the user completed the Microsoft login and that Mail.Read consent is granted.
  • 401 or expired errors: the device code expired before completion; restart step 1.
  • Empty task list: Together may have classified messages as non-actionable; inspect logs and adjust prompts/model if needed.
  • Email not delivered: confirm SMTP credentials and that less-secure app access or app password is allowed for the account.

Repository Layout

.
|-- lambda_function.py        # Primary Lambda handler (stdlib-only build)
|-- package/                  # Vendored Lambda build with requests + msal
|-- frontend/inbox-companion  # React/Vite frontend
|-- test.py                   # Remote driver for the Lambda workflow
|-- together.py               # Standalone Together API sanity check
|-- template.yaml             # SAM template with sample configuration
\-- requirements.txt          # Python dependencies for Lambda packaging

License

No license specified. Add one before distributing the project.

About

Application will read through thousands of emails and truncate them into actionable tasks, so that time does not have to be wasted digging through many emails.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors