This is a submission for the Postmark Challenge: Inbox Innovators.
What I Built
EPB (Email PR Bot) is an AI-powered code generation service that lets developers create code through email. Simply send an email with your code requirements, and within seconds, you'll receive a pull request with working code generated by Mistral AI, optimized for your specific repository.
The application:
- Receives emails through Postmark's inbound email parsing
- Extracts the instruction from the email body
- Identifies the target GitHub repository (via email content or user defaults)
- Analyzes the repository to understand existing code patterns and structure
- Generates contextually-aware code using Mistral AI's codestral model
- Creates a GitHub pull request with the generated files
- Responds to the sender with a link to view the PR
This workflow creates a seamless experience where developers can quickly implement new features or fix bugs without needing to switch contexts or open their code editor.
Demo
How to Test EPB:
-
Send an email to:
[email protected]
- Include a code request in the email body (see example below)
-
Specify a repository make pr in the test repo
bO-05/mailforge-test-target
as current functionality and github repo/ token is only for this repo. - Wait for the response with your PR link (usually within <1 minute)
Test Credentials:
- You can use the default repository
bO-05/mailforge-test-target
for testing - No authentication is needed to test the service
- The system's GitHub token is configured to only have access to this test repository
Real-World Example Requests:
I've tested the system with progressive enhancement requests to demonstrate its ability to understand context and build on existing code. Here are the actual email requests sent to the system:
Email #1: Basic Implementation
Subject: Python Script to Convert DOCX to Markdown
Body:
Could you please implement a simple Python script that converts a .docx file to Markdown format (.md)? The goal is to extract the text (including basic formatting like headings, bold, italics, and bullet points) and output a clean Markdown version of the document.
Result: Successfully created docx_to_markdown.py with basic formatting conversion
Email #2: Feature Enhancement
Subject: Enhancement Request: Additional Features for DOCX to Markdown Conversion of repo: "bO-05/mailforge-test-target"
Body:
I'd like to request a set of enhancements to a Python-based .docx to Markdown conversion tool — possibly building on a previous task you may have worked on involving basic text formatting extraction from Word documents.
This time, I'm looking to expand the feature set with the following:
Table conversion: Convert Word tables to Markdown tables (GitHub-compatible).
Image handling: Save embedded images to a local folder and insert Markdown image syntax in the output (e.g., ).
Hyperlink preservation: Convert Word hyperlinks to Markdown format [text](url).
Code block detection: For monospaced or code-style text (e.g., Courier New or "Code" paragraph styles), wrap the content in triple backticks (```
).
Result: Enhanced the existing script with the requested features, building on the previous implementation
Email #3: Frontend Addition
Subject: Enhancement Request: simpe frontend for DOCX to Markdown Conversion of repo: "bO-05/mailforge-test-target"
Body:
make simple frontend and edit readme to reflect our app
Result: PR created with index.html and app.py files (pending merge)
Screenshots:
Request from email
GitHub PR Created by EPB
Response Email with PR Link
Vercel logs
Code Repository
GitHub Repository: EPB (Email PR Bot)
How I Built It
Tech Stack:
- Backend: Python serverless function on Vercel
- Email Processing: Postmark inbound email webhook
- AI Code Generation: Mistral AI (codestral-latest model)
- Repository Integration: GitHub API
- Email Response: Postmark outbound emails
Implementation Process:
-
Setting up Postmark Inbound Processing:
- Created a Postmark server with inbound webhook processing
- Configured the webhook endpoint to point to the Vercel-hosted API
- Set up email validation and parsing to extract instructions
-
Repository Context Analysis:
- Implemented a system to fetch and analyze existing repository structure
- Created an algorithm to identify relevant files based on request context
- Built a context-aware prompt system for the AI model
-
AI Code Generation:
- Integrated with Mistral AI's codestral model
- Developed a custom prompt format that includes repository context
- Implemented parsing logic to extract multiple files from AI responses
-
GitHub Integration:
- Created a workflow to create branches, commit files, and open PRs
- Added support for handling existing files (update vs. create)
- Implemented error handling for repository access issues
-
Response System:
- Designed HTML email templates for success and error scenarios
- Implemented email response logic through Postmark's outbound API
- Added tracking and detailed information in response emails
Challenges and Solutions:
-
Repository Context:
- Challenge: Getting the AI to understand existing code patterns
- Solution: Implemented targeted repository scanning to provide relevant code context
-
Email Format Parsing:
- Challenge: Reliably extracting target repositories and instructions
- Solution: Created multiple regex patterns and fallback detection mechanisms
-
Code Generation Quality:
- Challenge: Ensuring generated code integrates with existing repositories
- Solution: Enhanced system prompts with detailed integration guidelines
-
Error Handling:
- Challenge: Providing useful feedback when errors occur
- Solution: Implemented detailed error emails with troubleshooting suggestions
Experience with Postmark:
Postmark's inbound email parsing capabilities were central to this project's success. The reliable webhook system, clean email parsing, and structured JSON payload made it straightforward to extract and process email content.
Key Postmark features used:
- Inbound webhook processing for email reception
- Email body and subject extraction
- Reply handling with StrippedTextReply
- Outbound email API for response delivery
- HTML email formatting for rich responses
The clean API and reliable delivery of Postmark made it the perfect foundation for this email-driven workflow. The ability to receive and process emails programmatically opened up an entirely new interface for code generation that doesn't require specialized tools or interfaces.
Team
This project was developed by async_dime.
Top comments (0)