Marketing generates leads, but they often lack critical information (Company Size, Industry, Location). Sales reps waste time researching this data manually. High-value leads might sit in a queue for too long.
A real-time workflow that triggers on form submission, enriches the data, and instantly routes it to the right person.
import { salesforce } from '@dataflows/salesforce'
import { clearbit } from '@dataflows/clearbit'
import { slack } from '@dataflows/slack'
export async function leadEnrichment(event: WebhookEvent) {
'use workflow'
const { email, name } = event.body
// 1. Enrich with Clearbit
const enrichment = await enrichLead(email)
const companySize = enrichment.company?.metrics?.employees || 0
const isEnterprise = companySize > 1000
// 2. Create Lead in Salesforce
const leadId = await createSalesforceLead(name, email, enrichment, companySize, isEnterprise)
// 3. Notify Sales Team
await notifySales(isEnterprise, email, companySize, leadId)
}
async function enrichLead(email: string) {
'use step'
return clearbit.enrich({ email })
}
async function createSalesforceLead(name: string, email: string, enrichment: any, companySize: number, isEnterprise: boolean) {
'use step'
return salesforce.create('Lead', {
FirstName: name.split(' ')[0],
LastName: name.split(' ')[1] || '',
Email: email,
Company: enrichment.company?.name || 'Unknown',
NumberOfEmployees: companySize,
Rating: isEnterprise ? 'Hot' : 'Warm'
})
}
async function notifySales(isEnterprise: boolean, email: string, companySize: number, leadId: string) {
'use step'
const channel = isEnterprise ? '#sales-enterprise' : '#sales-inbound'
const text = isEnterprise
? `🚨 New Enterprise Lead: ${email} (${companySize} employees).`
: `New Lead: ${email}.`
await slack.postMessage({
channel,
text: `${text} <https://salesforce.com/${leadId}|View in Salesforce>`
})
}
Automatically fetches company data based on email domain.
Routes leads to different sales teams based on company size.