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

valdottown

Enrich-New-User

Get enriched new user data notifications
Public
Like
1
Enrich-New-User
Home
Code
8
utils
1
.vtignore
README.md
enrichedUserWebhook.ts
H
main.tsx
newUserWebhook.ts
test-signup.ts
types.ts
Branches
1
Pull requests
Remixes
1
History
Environment variables
2
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
/
/
x
/
valdottown
/
Enrich-New-User
/
branch
/
main
/
version
/
187
/
code
/
README.md
/
README.md
Code
/
/
x
/
valdottown
/
Enrich-New-User
/
branch
/
main
/
version
/
187
/
code
/
README.md
/
README.md
Search
10/14/2025
Viewing readonly version of main branch: v187
View latest version
README.md

Clay API for New User Enrichment

Clay doesn't offer an API, but you can simulate an API via Val Town by listening to webhooks, enriching data in Clay, and having Clay send an HTTP request back when enrichment is complete.

This demo uses Clay like an API to automatically enrich new user signups and send notifications to Discord.

Here's an example: Screenshot 2025-07-11 at 2.56.21 PM.png

Here's the underlying Clay Table (feel free to zoom in to see the exact setup for debugging): CleanShot 2025-07-23 at 10.50.53@2x.png

Project Structure

This project uses the Hono framework with a clean, flat architecture:

├── enrichedUserWebhook.ts    # Receives enriched data from Clay
├── newUserWebhook.ts         # Receives new signups from Clerk/Stripe
├── discordNotifications.ts   # Discord message formatting and buttons
├── types.ts                  # TypeScript interfaces
├── test-signup.ts            # Test utility
├── main.tsx                  # Hono app entry point with routing
├── deno.json                 # Deno configuration
└── README.md                 # This file

1. Set up your Clay table and webhook

  1. Create a new Clay workbook called "New User Enrichment"

  2. Click Add → Pull in data from source at the bottom

  3. Select Pull in data from a Webhook Table

  4. Click Edit source on the Webhook column to copy the webhook URL Screenshot 2025-07-11 at 3.24.16 PM.png

  5. Add the webhook URL to your environment variables:

    • Go to your val's Environment Variables
    • Add environment variable: CLAY_WEBHOOK_URL
    • Set value to: https://api.clay.com/v3/sources/webhook/pull-in-data-from-a-webhook-YOUR_ID

Note: Setting up the webhook like this lets you transform / filter the data before sending it over to Clay. It also helps with error handling and give you logs in Val Town for observability. Otherwise, you could set up the webhook directly from the source ie. Clerk, Stripe etc.

2. Add enrichment columns to Clay

Add whichever enrichment columns you want. This example uses:

  • Enrich Person → Name, Title, Org
  • LinkedIn Profile → LinkedIn URL

3. Make HTTP request from Clay

  1. Click Add Column → Add Enrichment → search for HTTP API
  2. Add HTTP API column to your Clay table
  3. Click Edit Column and fill in the following:
  • Set endpoint to your HTTP URL: https://your-val-url.com/enrichedUserWebhook (Note: you need the /enrichedUserWebhook!)
  • Set method: POST
  • Configure request body:
{ "email": "{{email}}", "profile_image_url": "{{profile_image_url}}", "Name": "{{name}}", "Title": "{{title}}", "Org": "{{org}}", "LinkedIn": "{{LinkedIn Profile}}" }
  • Enable Remove empty values
  • Here's what my final column looked like:
  • Screenshot 2025-07-11 at 2.44.27 PM.png

4. Add environment variables in Val Town

  1. Click Environment Variables in your val's sidebar
  2. Add the following environment variables:

Required:

  • CLAY_WEBHOOK_URL - Your Clay webhook URL from step 1
  • DISCORD_WEBHOOK - Your Discord webhook URL for notifications

Optional (for executive email feature):

  • GMAIL_USER - Gmail address to send emails from
  • GMAIL_PASS - Gmail app password (not your regular password!)
    • How to create a Gmail app password

Note: If you don't set up Gmail credentials, the system will still work but won't send welcome emails to executives.

5. Executive Welcome Email (Optional)

This project automatically detects executive signups and sends them a personalized welcome email with a $50 credit offer.

What qualifies as an executive?

The system checks job titles for keywords like:

  • C-Suite: CEO, CTO, CFO, CMO, etc.
  • Leadership: VP, Director, Head of, etc.
  • Founders: Founder, Co-founder, Owner

See the full list in send-email.ts.

Customizing the email templates

Email templates are stored as editable text files in the templates/ directory:

  • templates/executive-welcome.txt - Plain text version
  • templates/executive-welcome.html - HTML version

Available variables:

  • {{firstName}} - Recipient's first name
  • {{roleDescription}} - Generated from title/org
  • {{teamQuestion}} - Customized based on whether they have an org
  • {{subject}} - Email subject line

Simply edit these files to change the email copy - no code changes needed!

Testing

To test the email feature, send a webhook with a title like "CEO" or "Founder" and the system will automatically send an email.

6. Configure your source webhook

This is what triggers a new row in the Clay table, hook up your source system (Clerk, Stripe, etc.) to send webhooks to your val's HTTP URL: https://your-val-url.com/newUserSignup (Note: you need the /newUserSignup!)

For Clerk, you can find it here: image.png

Output

Discord Notifications

Enriched profiles (with ⭐):

⭐ New user! John Doe • Software Engineer @ Tech Corp • john@example.com • https://linkedin.com/in/johndoe

Basic signups:

New user! user@example.org

Executive signups (with email sent):

⭐ New user! Jane Smith • CEO @ Startup Inc • jane@startup.com • https://linkedin.com/in/janesmith • ✅ Executive welcome email sent

Email Notifications

Executives automatically receive a welcome email with:

  • Personalized greeting using their first name
  • $50 credit offer for Val Town's Townie AI
  • Customized message based on their role and company

How It Works

Flow Diagram

User Signs Up (Clerk/Stripe)
    ↓
    → Val Town receives webhook at /newUserSignup
    ↓
    → Forwards to Clay for enrichment
    ↓
Clay enriches data (name, title, company, LinkedIn)
    ↓
    → Clay sends HTTP request to /enrichedUserWebhook
    ↓
Val Town processes enriched data:
    ├─→ Builds Discord notification message
    ├─→ Checks if executive title
    │    └─→ If yes: Send welcome email
    └─→ Sends Discord notification

Key Features

  1. Automatic Enrichment: Uses Clay to enrich user emails with LinkedIn data
  2. Smart Detection: Identifies executives by job title keywords
  3. Personalized Emails: Sends customized welcome emails to executives
  4. Template-Based: Email copy stored in editable template files
  5. Discord Integration: Real-time notifications with user details
  6. Modular Architecture: Clean Hono-based structure for easy maintenance

Error Handling

  • If email sending fails, Discord notification shows ❌ with error message
  • All errors are logged to Val Town console for debugging
  • Clay enrichment failures are handled gracefully (shows partial data)
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
© 2025 Val Town, Inc.