AI Sales Agent

This example shows a complete autonomous sales agent that researches leads using search_humans, discovers their interests with search_interests, finds meeting opportunities, locates sales reps nearby, and orchestrates real-world meetings using the full tool suite.

Architecture

┌──────────────┐ ┌─────────────────────┐ ┌────────────────┐
│ CRM / Lead │────>│ AI Sales Agent │────>│ HumanConnection│
│ Database │ │ │ │ Toolkit │
└──────────────┘ │ 1. Research lead │ └───────┬────────┘
│ 2. Discover interests│ │
│ 3. Find events │ ┌───────┴────────┐
│ 4. Find sales rep │ │ SearXNG + │
│ 5. Book event │ │ Crawl4AI │
│ 6. Send invite │ └───────┬────────┘
│ 7. Process report │ │
│ 8. Reward human │ ┌───────┴────────┐
│ 9. Update CRM │ │ Social Profiles│
└─────────────────────┘ │ Bio, Location │
│ Email, Interests│
└────────────────┘

Part 1: Lead Research and Interest Discovery

The core of the sales agent is lead research using search_humans and interest discovery using search_interests.

1import { search_humans, search_interests } from '@humanconnection/toolkit';
2
3interface Lead {
4 name: string;
5 company: string;
6 company_domain?: string;
7 title?: string;
8 city?: string;
9 objective: string;
10 talkingPoints: string[];
11}
12
13interface LeadDossier {
14 lead: Lead;
15 found: boolean;
16 bio?: string;
17 location?: string;
18 email?: string;
19 company_domain?: string;
20 linkedin?: string;
21 twitter?: string;
22 instagram?: string;
23 tiktok?: string;
24 confidence: number;
25 interests?: string[];
26}
27
28async function researchLead(lead: Lead): Promise<LeadDossier> {
29 const results = await search_humans({
30 name: lead.name,
31 company_name: lead.company,
32 company_domain: lead.company_domain,
33 location: lead.city,
34 provide_email: true,
35 });
36
37 if (results.length === 0 || results[0].confidence < 0.3) {
38 return { lead, found: false, confidence: 0 };
39 }
40
41 const human = results[0];
42
43 // Discover interests for meeting personalization
44 const interests = await search_interests({
45 name: lead.name,
46 linkedin_url: human.profiles.linkedin_profile_url,
47 x_url: human.profiles.x_profile_url,
48 instagram_url: human.profiles.instagram_profile_url,
49 });
50
51 return {
52 lead,
53 found: true,
54 bio: human.bio,
55 location: human.location,
56 email: human.email,
57 company_domain: human.company_domain,
58 linkedin: human.profiles.linkedin_profile_url,
59 twitter: human.profiles.x_profile_url,
60 instagram: human.profiles.instagram_profile_url,
61 tiktok: human.profiles.tiktok_profile_url,
62 confidence: human.confidence,
63 interests: interests.signals.map(s => s.signal),
64 };
65}
66
67// Process a batch of leads
68const leads: Lead[] = [
69 {
70 name: 'Sara Blakely',
71 company: 'Spanx',
72 company_domain: 'spanx.com',
73 city: 'Atlanta',
74 objective: 'Demo our retail analytics platform',
75 talkingPoints: [
76 'Spanx expanding direct-to-consumer',
77 'Our platform increases conversion by 35%',
78 'Free pilot for flagship stores',
79 ],
80 },
81 {
82 name: 'Brian Chesky',
83 company: 'Airbnb',
84 company_domain: 'airbnb.com',
85 city: 'San Francisco',
86 objective: 'Introduce our hospitality AI platform',
87 talkingPoints: [
88 'AI-powered guest experience optimization',
89 'Reduces host support tickets by 50%',
90 'Integration with Airbnb API',
91 ],
92 },
93];
94
95async function main() {
96 console.log('=== AI Sales Agent: Lead Research ===\n');
97
98 const dossiers: LeadDossier[] = [];
99
100 for (const lead of leads) {
101 console.log(`Researching ${lead.name} (${lead.title ?? ''} at ${lead.company})...`);
102 const dossier = await researchLead(lead);
103 dossiers.push(dossier);
104
105 if (dossier.found) {
106 console.log(` [FOUND] Confidence: ${dossier.confidence}`);
107 console.log(` Bio: ${dossier.bio}`);
108 console.log(` Location: ${dossier.location}`);
109 if (dossier.email) console.log(` Email: ${dossier.email}`);
110 if (dossier.linkedin) console.log(` LinkedIn: ${dossier.linkedin}`);
111 if (dossier.twitter) console.log(` X: ${dossier.twitter}`);
112 if (dossier.instagram) console.log(` Instagram: ${dossier.instagram}`);
113 if (dossier.interests?.length) console.log(` Interests: ${dossier.interests.join(', ')}`);
114 } else {
115 console.log(` [NOT FOUND]`);
116 }
117 console.log();
118 }
119
120 // Summary
121 const found = dossiers.filter(d => d.found);
122 console.log(`--- Summary ---`);
123 console.log(`Total leads: ${leads.length}`);
124 console.log(`Profiles found: ${found.length}`);
125 console.log(`Average confidence: ${(found.reduce((s, d) => s + d.confidence, 0) / found.length).toFixed(2)}`);
126}
127
128main();

Part 2: Full End-to-End Workflow

The complete workflow: research the lead, discover interests, find events, find a sales rep, and book the meeting. Here’s what the pipeline produces across 5 real scenarios:

E2E results across 5 industries

1import {
2 search_humans,
3 search_interests,
4 search_events,
5 search_places,
6 book_ticket,
7 send_meeting_invite,
8 send_meeting_report,
9 send_meeting_payment,
10} from '@humanconnection/toolkit';
11
12async function processLead(lead: Lead) {
13 // Step 1: Research the lead
14 const dossier = await researchLead(lead);
15 if (!dossier.found) {
16 return { status: 'not_found', lead: lead.name };
17 }
18
19 // Step 2: Find events near the lead (interests already discovered in researchLead)
20 const events = await search_events({
21 location: { city: dossier.location ?? lead.city ?? 'San Francisco' },
22 radius_km: 50,
23 category: 'conference',
24 });
25
26 // Step 3: Find a sales rep near the lead
27 const reps = await search_humans({
28 location: dossier.location ?? lead.city ?? 'San Francisco',
29 title_filters: 'sales AND retail',
30 provide_email: true,
31 });
32
33 if (reps.length === 0 || !reps[0].email) {
34 return { status: 'no_rep_found', lead: lead.name };
35 }
36
37 const rep = reps[0];
38
39 // Step 4: Book the event ticket
40 if (events.data.length > 0) {
41 await book_ticket({
42 event_url: events.data[0].url,
43 email: rep.email,
44 name: rep.name,
45 });
46 }
47
48 // Step 5: Send calendar invite — the invite is the booking
49 await send_meeting_invite({
50 title: `Coffee with ${lead.name} at ${events.data[0]?.name ?? 'TBD'}`,
51 attendee_emails: [rep.email, dossier.email ?? lead.email],
52 scheduled_at: events.data[0]?.starts_at ?? new Date(Date.now() + 7 * 86400000).toISOString(),
53 duration_minutes: 30,
54 location: events.data[0]?.location?.name ?? dossier.location ?? lead.city,
55 description: `Meeting with ${lead.name} from ${lead.company}. Interests: ${dossier.interests?.join(', ')}. ${lead.objective}`,
56 });
57
58 return {
59 status: 'meeting_booked',
60 lead: lead.name,
61 rep: rep.name,
62 confidence: dossier.confidence,
63 };
64}
65
66async function processReport(meetingId: string) {
67 // After the meeting, submit the report
68 const report = await send_meeting_report({
69 meeting_id: meetingId,
70 summary: 'Productive conversation. Lead is evaluating solutions.',
71 outcome: 'follow_up_needed',
72 deal_value: { amount: 48000, currency: 'USD' },
73 next_steps: 'Schedule technical demo next week.',
74 });
75
76 // Reward based on outcome
77 const rewardType = report.outcome === 'deal_closed' ? 'commission' : 'flat_fee';
78 const rewardAmount = report.outcome === 'deal_closed' ? 2400 : 150;
79
80 await send_meeting_payment({
81 meeting_id: meetingId,
82 amount: rewardAmount,
83 currency: 'USD',
84 type: rewardType,
85 });
86}

What to do with search results

FieldWhat to do with it
bioUse to personalize your meeting objective and talking points
emailUse for meeting invites and calendar events
company_domainVerify the right person and use for CRM matching
locationSearch for events and places nearby. Find sales reps in the area
linkedin_profile_urlPass to search_interests for interest discovery
x_profile_urlPass to search_interests for interest discovery. Monitor for event attendance signals
instagram_profile_urlPass to search_interests for hobby and lifestyle signals
confidenceFilter out low-confidence results (below 0.4). Prioritize high-confidence leads

Next steps