• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
paulkinlan

paulkinlan

deep-research-email

Public
Like
deep-research-email
Home
Code
3
README.md
C
cron.ts
E
main.ts
Environment variables
1
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
12/27/2025
Viewing readonly version of main branch: v45
View latest version
README.md

Deep Research Email

An automated email-based research assistant powered by Google's Deep Research AI. Send an email with your research question, and receive a comprehensive research report back via email.

πŸš€ Features

  • Email-triggered research: Send a research query via email to initiate deep research
  • Asynchronous processing: Research runs in the background using Google's Deep Research Pro
  • Automated delivery: Completed research reports are automatically emailed back to you
  • Status tracking: Uses Val Town blob storage to track ongoing research tasks
  • Markdown formatting: Receive beautifully formatted research reports in HTML

πŸ“§ How to Use

  1. Send an email to: deep-research@valtown.email
  2. Subject: Your research topic (e.g., "Latest advances in quantum computing")
  3. Body: Detailed research question or context
  4. Wait: The system will process your request and send the research report back to your email

πŸ—οΈ Architecture

This val consists of two main components:

1. Email Handler (main.ts)

  • Type: Email Val
  • Trigger: Incoming email
  • Function:
    • Receives email and extracts the research question
    • Initiates a Deep Research task via Google GenAI API
    • Stores task metadata in blob storage for tracking
    • Returns immediately while research continues in background

2. Status Checker (cron.ts)

  • Type: Interval Val
  • Trigger: Scheduled (periodic check)
  • Function:
    • Polls blob storage for pending research tasks
    • Checks completion status with Google GenAI API
    • Sends email with research results when completed
    • Handles failed research attempts
    • Cleans up completed tasks from storage

πŸ› οΈ Technical Details

Dependencies

  • @google/genai - Google GenAI SDK for Deep Research
  • markdown-it - Markdown to HTML conversion
  • Val Town standard library (blob, email)

Data Flow

Email arrives β†’ Store task β†’ Background research
                    ↓
            Periodic status check
                    ↓
         Research complete? β†’ Email results

Storage Schema

Tasks are stored in blob storage as:

{ [interactionId]: { interaction: { id, status, ... }, e: { from, subject, text, ... } } }

⚠️ Known Issues

  • Race condition: Concurrent emails or simultaneous status checks may cause conflicts (noted in code comments)
  • Consider implementing proper locking mechanism for production use

πŸ”§ Configuration

Required Environment Variables

  • Google GenAI API credentials (configured through Val Town secrets)

Email Configuration

  • From address: paulkinlan.deep-research-email@valtown.email
  • Reply name: "Deep Research"

πŸ“ Example Usage

Email to send:

To: paulkinlan.deep-research-email@valtown.email
Subject: The impact of AI on software development
Body: I'm interested in understanding how AI tools like 
      GitHub Copilot and ChatGPT are changing the way 
      developers write code. Please research recent 
      trends and statistics.

Response you'll receive: A comprehensive email with:

  • Detailed research findings in HTML format
  • Multiple sources and citations
  • Well-formatted sections and bullet points
  • Original query context included

πŸš€ Deployment

This val is ready to use as-is. The components are:

  • Email endpoint: Automatically configured by Val Town
  • Cron job: Set to run at configured intervals
  • Blob storage: Managed by Val Town infrastructure

πŸ“„ License

This is a personal project hosted on Val Town.

πŸ‘€ Author

Paul Kinlan (@paulkinlan)


Built with Val Town 🏝️

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2026 Val Town, Inc.