Back to Omi

OmiSend

plugins/apps-js/README.md

3.0.0-Android-App7.5 KB
Original Source

OmiSend

A comprehensive Node.js server application for AI-powered email management and presentation generation with voice command integration.

šŸš€ Features

šŸ“§ Email Management

  • AI-powered email search and analysis with enhanced semantic search
  • Voice-controlled email composition and sending
  • Smart email fetching with context-aware filtering
  • Contact management with intelligent name resolution
  • OAuth integration with Google Gmail API
  • Email thread summarization and analysis

šŸ“Š Presentation Generation

  • Voice-triggered presentation creation with "Hey Omi" commands
  • AI-powered slide generation using SlidesGPT API
  • Real-time progress tracking with web viewer interface
  • Persistent presentation storage with Supabase database
  • Multiple output formats (embed links, PowerPoint downloads)

šŸŽÆ Voice Command Processing

  • Intent detection with natural language processing
  • Multi-language support for voice commands
  • Context-aware conversation flow management
  • Real-time webhook processing for voice segments

šŸ”§ Infrastructure

  • Redis caching for session state management
  • Supabase database for persistent data storage
  • Rate limiting and performance monitoring
  • Comprehensive error handling and logging
  • Security middleware with Helmet and CORS

šŸ“‹ Prerequisites

  • Node.js (v14 or higher)
  • Redis (for session management)
  • Supabase account (for database)
  • OpenAI API key (for AI features)
  • SlidesGPT API key (for presentation generation)
  • Google OAuth credentials (for email features)

šŸ› ļø Installation

  1. Clone the repository:
bash
git clone https://github.com/yourusername/omisend.git
cd omisend
  1. Install dependencies:
bash
npm install
  1. Create a .env file in the root directory:
env
# Server Configuration
PORT=3000
NODE_ENV=development

# Database
SUPABASE_URL=your_supabase_url_here
SUPABASE_KEY=your_supabase_anon_key_here

# Redis (Upstash)
UPSTASH_REDIS_HOST=your_redis_host
UPSTASH_REDIS_PASSWORD=your_redis_password
UPSTASH_REDIS_PORT=your_redis_port

# AI Services
OPENAI_API_KEY=your_openai_api_key_here
SLIDESGPT_API_KEY=your_slidesgpt_api_key_here

# Google OAuth (for email features)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REDIRECT_URI=your_redirect_uri

# Security
JWT_SECRET=your_jwt_secret_here
  1. Set up the database:
bash
npm run setup-supabase

šŸ“ Project Structure

src/
ā”œā”€ā”€ config/
│   └── constants.js          # Application configuration
ā”œā”€ā”€ controllers/
│   └── webhookController.js  # Webhook request handling
ā”œā”€ā”€ middleware/               # Custom middleware functions
ā”œā”€ā”€ models/
│   ā”œā”€ā”€ intentDetection.js    # Voice command pattern matching
│   ā”œā”€ā”€ aiEmailFetcher.js     # AI-powered email retrieval
│   ā”œā”€ā”€ aiEmailSender.js      # AI-powered email composition
│   ā”œā”€ā”€ enhancedEmailSearch.js # Advanced email search
│   ā”œā”€ā”€ Email.js              # Email data model
│   └── User.js               # User data model
ā”œā”€ā”€ routes/
│   ā”œā”€ā”€ auth.js               # Authentication endpoints
│   ā”œā”€ā”€ email.js              # Email management API
│   └── deck.js               # Presentation generation API
ā”œā”€ā”€ services/
│   └── authService.js        # Authentication services
└── utils/
    ā”œā”€ā”€ dbUtils.js            # Database utilities
    ā”œā”€ā”€ redisUtils.js         # Redis cache management
    ā”œā”€ā”€ emailUtils.js         # Email processing utilities
    ā”œā”€ā”€ deckUtils.js          # Presentation utilities
    ā”œā”€ā”€ googleAuth.js         # Google OAuth integration
    ā”œā”€ā”€ supabaseUtils.js      # Supabase database utilities
    ā”œā”€ā”€ contactUtils.js       # Contact management
    ā”œā”€ā”€ nameUtils.js          # Name resolution utilities
    ā”œā”€ā”€ omiUtils.js           # Core Omi utilities
    ā”œā”€ā”€ mailUtils.js          # Mail processing
    └── errorHandler.js       # Error handling utilities

public/
ā”œā”€ā”€ index.html                # Main web interface
ā”œā”€ā”€ deck.html                 # Presentation interface
ā”œā”€ā”€ success.html              # Success page
└── style.css                 # Styling

tests/                        # Test suites
server.js                     # Main application entry point

šŸ”Œ API Endpoints

Authentication

  • GET /api/auth/oauth/callback - Google OAuth callback
  • POST /api/auth/login - User authentication
  • GET /api/auth/profile - Get user profile

Email Management

  • POST /api/email/send - Send email via voice command
  • GET /api/email/search - Search emails with AI
  • GET /api/email/fetch - Fetch emails with context
  • GET /api/email/contacts - Get contact list
  • GET /api/email/summary/:threadId - Get email thread summary

Presentation Generation

  • POST /api/deck/webhook - Process voice commands for presentations
  • GET /api/deck/status/:presentation_id - Check generation status
  • GET /api/deck/viewer/:presentation_id - View presentation progress
  • GET /api/deck/history/:session_id - Get presentation history

System

  • POST /webhook - Main webhook endpoint for voice processing
  • GET /health - Health check endpoint

šŸŽ® Usage

Starting the Server

Development mode:

bash
npm run dev

Production mode:

bash
npm start

Voice Commands

Email Commands:

  • "Hey Omi, send an email to [contact] about [subject]"
  • "Find emails from [sender] about [topic]"
  • "Show me recent emails"

Presentation Commands:

  • "Hey Omi, create a presentation about [topic]"
  • "Make slides on [subject]"

Web Interface

  1. Main Interface: Visit http://localhost:3000
  2. Presentation Viewer: Visit http://localhost:3000/deck
  3. Real-time Tracking: Each presentation gets a unique viewer URL

šŸ”§ Development

Running Tests

bash
npm test

Database Setup

bash
# Initialize Supabase tables
npm run setup-supabase

# Test database connection
node tests/test_database.js

Performance Monitoring

The application includes built-in performance monitoring that logs:

  • Request count and error rates
  • Average and maximum response times
  • Webhook processing statistics
  • Email sending metrics

šŸ›”ļø Security Features

  • Helmet.js for security headers
  • CORS configuration for cross-origin requests
  • Rate limiting (200 requests per minute per IP)
  • Input validation with express-validator
  • JWT authentication for secure sessions
  • Environment variable validation on startup

šŸ“Š Database Schema

Presentations Table

  • Stores presentation generation data
  • Tracks status, content, and SlidesGPT responses
  • Maintains persistent URLs for embed and download

Users Table

  • User authentication and profile data
  • OAuth integration details

Emails Table

  • Email metadata and processing history
  • Search indexing and caching

šŸ¤ Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

šŸ“„ License

This project is licensed under the ISC License - see the LICENSE file for details.

šŸ†˜ Support

For detailed setup instructions for the presentation system, see PRESENTATION_SETUP.md.

For issues and questions, please open an issue on GitHub.