Generate leads from a website with therapists
Overview
This recipe demonstrates how to use Airtop to automate the generation of leads for reaching out to therapists of any kind. The recipe compiles a list of therapists from a provided URL, extracts their information and generates personalized outreach messages for each one. It’s a great example of how to combine Airtop with Agentic Frameworks like LangChain to create multi-step intelligent workflows.
The instructions below will walk you through the application and how it leverages Airtop and LangGraph capabilities to create the list of leads.
Demo
A live demo of this recipe is available here. You can sign up to create an API key for free and try it out yourself! You will also need an OpenAI API key to run the recipe, which you can get for free here.
Prerequisites
To get started, ensure you have:
- Node.js installed on your system.
- PNPM package manager installed. See here for installation steps.
- A Node Version Manager (NVM preferably)
- An Airtop API key. You can get one for free.
- An OpenAI API key. You can get one for free here.
Getting Started
-
Clone the repository
Start by cloning the source code from GitHub:
-
Install dependencies
Run the following command to install the necessary dependencies, including the Airtop SDK:
Running the Script
To run the script, go to the examples/lead-generation directory and run the following command in your terminal:
Script walkthrough
The script executes the following tasks in order:
- Accepts the API Keys and the URLs to run the recipe
The script starts by requesting the URLs containing the list of therapists, followed by accepting the Airtop and OpenAI API keys.
- Define the graph flow
Using LangChain’s LangGraph flow, we define the flow of the script as follows:
- Step 1: Validate the URLs to determine if they contain a list of therapists
- Step 2: Compile the list of therapists from the URLs, or go to an error handling step if no valid URLs are provided
- Step 3: Enrich the information of each therapists by generating a summary of their profile
- Step 4: Generate a personalized outreach message for each therapist
- Step 5: Generate a CSV file with the compiled information
- Enter the graph
We run the graph by passing instances of the Airtop and LangChain’s ChatOpenAI to the graph.
- URL Validation Node
Using Airtop’s pageQuery
API in conjunction with the batchOperate
functionality, we analyze each URL in parallel to verify if they contain a list of therapists. We then filter out the URLs that do not satisfy this criteria, and continue with the graph flow using LangGraph’s Command API.
- Fetch Therapists Node
Using Airtop’s pageQuery
API in conjunction with the batchOperate
functionality, we compile the list of therapists from the URLs, extracting their name, phone number, personal website and email address (if available in the URL).
- Enrich Therapist Node
In this node, we run a similiar process as the node above (to pick up any extra information from the therapist’s personal webiste that might have not been extracted in the previous step), but we generate a summary of their profile as well. This summary is going to be used to generate the personalized outreach message later in the app.
- Outreach Message Node
LangChain’s LLM tools make it super easy to use the OpenAI API. We use the ChatOpenAI
tool to generate a personalized message for each therapist. We pair it with the withStructuredOutput
tool to ensure the output is in the correct format.
- CSV Generator Node
In this node, we generate the content of the CSV file with the compiled information of all therapists. In the Live Demo, we provide both the CSV file and a preview of the content.
Summary
This recipe demonstrates how to use Airtop to automate the generation of leads for approaching therapists of any kind. It leverages several Airtop’s and LangChain’s APIs to scrape different pages, collects and enriches information, and provides it in a structured friendly format for its consumers.