Send Lead Gen Email

A Hono-based web application for previewing and sending personalized welcome emails with Discord notifications.

Overview

This Val provides a user-friendly interface to preview and send customized welcome emails to new users. It's designed to integrate with automation workflows (like Discord bots or webhooks) where you can generate quick links for team members to review and approve emails before sending.

Features

  • šŸ“§ Email Preview - Visual preview of the email before sending
  • āœļø Inline Editing - Quick edit capability for subject and content
  • šŸŽØ Personalization - Dynamic email content based on user data
  • šŸ”” Discord Notifications - Automatic Discord webhook on successful send
  • šŸ”— Edit Val Button - Quick access to edit the Val code
  • šŸ“± Responsive Design - Works on desktop and mobile

Usage

URL Parameters

Generate a URL with the following query parameters:

https://send-lead-gen-email.val.run?name=John+Doe&email=john@example.com&title=Software+Engineer&org=Acme+Corp

Required Parameters

  • name: Full name of the recipient (e.g., "John Doe")
  • email: Email address of the recipient

Optional Parameters

  • title: Job title (e.g., "Software Engineer")
  • org: Organization/company name (e.g., "Acme Corp")

Email Personalization

The role description in the email is automatically built from the title and org parameters:

  • Both provided: "your role as Software Engineer at Acme Corp"
  • Only title: "your role as Software Engineer"
  • Only org: "your work at Acme Corp"
  • Neither: "your background"

Environment Variables

Set these in your Val Town environment:

Required

  • GMAIL_USER - Gmail address for sending emails
  • GMAIL_PASS - Gmail app password (not your regular password)

Optional

  • DISCORD_WEBHOOK - Discord webhook URL for notifications

Email Templates

Edit the email content by modifying these files:

  • email.html - HTML version of the email
  • email.txt - Plain text version of the email

Use these template variables:

  • {{firstName}} - First name extracted from full name
  • {{roleDescription}} - Auto-generated role description
  • {{subject}} - Email subject line

Project Structure

.
ā”œā”€ā”€ main.ts              # Hono server and routes
ā”œā”€ā”€ email-template.ts    # Email generation logic
ā”œā”€ā”€ pages.ts             # HTML page templates
ā”œā”€ā”€ discord.ts           # Discord webhook notifications
ā”œā”€ā”€ email.html           # Email HTML template
ā”œā”€ā”€ email.txt            # Email text template
└── README.md            # This file

Discord Notifications

When an email is successfully sent, a Discord notification is posted with:

  • āœ… Success message with recipient details
  • šŸ“§ Email preview embed (subject + body)
  • āœļø Edit Val button to modify the code

Development

Key Functions

  • generateEmailPreview() - Generates email content from templates
  • buildRoleDescription() - Creates personalized role descriptions
  • sendDiscordNotification() - Sends Discord webhook on email send
  • generatePreviewPage() - Renders the preview UI