An AI agent that automatically processes "New Customer" emails and sends personalized follow-up emails to new ZeroDev customers.
- Parses "New Customer" email notifications
- Visits the customer's website to understand their project
- Analyzes company information to determine the company name and category
- Composes a personalized email based on the template
- Schedules the email to be sent at a random time (24-48 hours in the future)
- Bun (latest version)
- SendGrid API key (for sending emails)
- OpenAI API key (for content analysis)
-
Clone the repository:
git clone <repository-url> cd email-new-customers -
Install dependencies:
bun install -
Create a
.envfile based on the.env.examplefile:cp .env.example .env -
Fill in your API keys and email settings in the
.envfile
# Build the TypeScript
bun run build
# Process a new customer email
bun run dist/index.js "Customer email: customer@example.com
Customer description: John Doe"For development:
bun run src/index.ts "Customer email: customer@example.com
Customer description: John Doe"For convenient testing, you can use the included test script:
# Make the script executable if needed
chmod +x test.sh
# Run a test with a specific email and optional name
./test.sh customer@example.com "John Doe"To send test emails immediately instead of waiting 24-48 hours:
- Set
TEST_SEND_IMMEDIATELY=truein your.envfile - Run the test as normal
- Set it back to
falsefor production use
- The agent is triggered when it receives a "New Customer" email.
- It extracts the customer's email address and name from the notification.
- If the email is a generic email (like Gmail), it ignores the customer.
- Otherwise, it visits the website associated with the customer's email domain.
- It analyzes the website to determine the company name and category.
- It composes a personalized email based on the template.
- It schedules the email to be sent at a random time in the future (24-48 hours).
The project includes a webhook server that can receive notifications from Zapier:
# Run the webhook server
./server.shBy default, the server runs on port 3000. You can change this by setting the PORT environment variable.
- Create a new Zap in Zapier
- Set the trigger to "New Email" in your email app
- Filter emails with the subject "New Customer"
- Add a Webhook action step (POST)
- Point the webhook to your server URL (e.g.,
https://your-server.com:3000or use a service like ngrok for local testing) - Test the webhook to see the request format
- Once you've confirmed the format, update the webhook.ts file to process emails correctly
OPENAI_API_KEY: Your OpenAI API keySENDGRID_API_KEY: Your SendGrid API keyEMAIL_FROM: The email address to send from (format: "Derek email@example.com")FOUNDER_NAME: The founder's name (default: "Derek")PORT: The port for the webhook server (default: 3000)TEST_SEND_IMMEDIATELY: Set to "true" during testing to send emails immediatelyTEST_EMAIL_RECIPIENT: Your email for receiving test emails (overrides recipient during testing)AUDIT_EMAIL_RECIPIENT: Email address to receive audit notifications about all processed customers and errors