Public
Like
1
Enrich-New-User
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.
Viewing readonly version of main branch: v35View latest version
This implementation sends an initial Discord notification immediately, then updates it with enriched data when Clay completes processing.
- User signs up → Clerk webhook triggers
- Val sends basic info to Discord immediately (with "enriching..." message)
- Val sends data to Clay for enrichment
- Clay processes enrichment (takes 10-60 seconds)
- Clay calls back to your Val with enriched data
- Val sends a follow-up Discord message with full enrichment
- Add "HTTP API" as first column
- Set as webhook receiver
- Copy the generated webhook URL
- This receives data from your Val
Map these fields from the webhook data:
emailprofile_image_urlsignup_timestampcallback_url(important!)
- Find Person from Email: Maps email → person data
- Enrich Company: Uses company from person data
- Any other enrichments you want
Add "HTTP API" column at the end:
- Method: POST
- URL: Use the
{{callback_url}}field - Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer YOUR_SECRET_KEY" }
- Body: Map all enriched fields:
{ "email": "{{email}}", "full_name": "{{person_full_name}}", "company": "{{company_name}}", "title": "{{person_title}}", "linkedin": "{{person_linkedin_url}}", "location": "{{person_location}}", "industry": "{{company_industry}}", "company_size": "{{company_size}}", "company_website": "{{company_website}}" }
- Configure the table to run automatically when new rows are added
- Or set it to run when webhook is received
Add these to your Val:
CLAY_WEBHOOK_URL: The inbound webhook URL from ClayCLAY_WEBHOOK_SECRET: A secret key for authenticating Clay callbacksVAL_TOWN_URL: Your Val's base URL (e.g.,https://yourval.val.run)DISCORD_WEBHOOK: Your Discord webhook URLCLERK_SECRET_KEY: Your Clerk authentication secret
Your Val now has two endpoints:
/newUserWelcomeEmail- Receives Clerk webhooks/clayCallback- Receives Clay enrichment callbacks
- Trigger a test signup or manually call the Clerk webhook
- Check Discord for initial message with "Enriching data with Clay..."
- Wait 10-60 seconds for Clay to process
- Check Discord for second message with enriched data
- Discord Limitation: Discord webhooks can't edit messages, so we send a second message
- Storage: Current implementation uses in-memory storage (resets on Val restart)
- Cleanup: Old pending enrichments are automatically cleaned up after 1 hour
- Fallback: If Clay fails or is not configured, users still get the basic notification
- Use Val.town Blob Storage: Store pending enrichments persistently
- Discord Bot: Use a bot token instead of webhook to edit messages
- Retry Logic: Re-send to Clay if enrichment fails
- Batching: Collect multiple signups and enrich in batches