Skip to main content
A sales automation pipeline that qualifies leads with AI, creates contacts in HubSpot, and generates personalized outreach emails. This example shows how to combine workflows with agents and connectors for a fully automated sales process.

Project Structure

Step 1: Configuration

Define scoring thresholds and qualification criteria:
config/settings.ts

Step 2: Specialized Agents

Each agent handles one part of the pipeline.

Lead Qualifier

Uses a cheaper model — it just needs to score and classify:
agents/qualifier.ts

Sales Copywriter

Uses a better model for quality content:
agents/copywriter.ts

Step 3: Workflow Definition

The workflow orchestrates the full pipeline with conditional branching:
workflows/lead-to-deal.ts

Step 4: Main Entry Point

Wire the workflow into main.ts with identification and metrics:
main.ts

How It Works

Key Patterns

Cheap Model for Classification, Good Model for Content

Use gpt-4o-mini for tasks like scoring and classification — it’s faster and cheaper. Save gpt-4o for content generation where quality matters.

Structured JSON Responses

Tell agents to respond with valid JSON and parse it in the workflow conditions. This makes branching reliable:

Workflow vs Agent

This example uses a workflow because it’s a pipeline — data flows in, gets processed through steps, and comes out. There’s no conversation. Use workflows when the process is linear, not conversational.

Next Steps

Workflows

Learn more about workflows

Connectors

Integrate with HubSpot, Slack, etc.

Collections Agent

WhatsApp collections example

Best Practices

Tips for effective agents