Skip to main content
This task example shows how to build an Upsonic LLM agent that:
  • Reuses the find_company_website agent to find and validate the official website of a company (via Serper API)
  • Chains the result into the extract_categories tool to scrape ecommerce sales categories from that website

Overview

The Find Sales Categories example demonstrates how to build composite agents that combine multiple tools and agents to perform complex tasks. It showcases:
  1. Agent Composition: Combining website discovery with content extraction
  2. Tool Integration: Using custom tools alongside Upsonic agents
  3. E-commerce Analysis: Extracting business intelligence from company websites
  4. Structured Output: Returning organized category information

Key Features

  • Agent Orchestration: Combines multiple agents and tools in a single workflow
  • E-commerce Intelligence: Extracts sales categories from company websites
  • Smart Filtering: Filters out non-sales related navigation items
  • Flexible Extraction: Works with various website structures and designs
  • Reusable Components: Modular design for easy extension

Code Structure

Category Extractor Tool

Main Agent

Complete Implementation

category_extractor.py

find_sales_categories.py

How It Works

The flow is split into two reusable components:

1. Website Finder

  • Uses Serper to search for the company
  • Validates candidate websites
  • Returns the best match as a structured WebsiteResponse

2. Category Extractor

  • Fetches the website HTML
  • Looks for navigation and menu elements
  • Extracts category names, filtering out non-sales links

3. Sales Categories Agent

  • Orchestrates the two steps above
  • Input: Company name
  • Output: JSON containing website, validation info, and extracted categories

Usage

Setup

  1. Install dependencies:
  1. Copy the example environment file and add your Serper API key:
  1. Edit .env and replace the placeholder with your key:
You can get a free API key from Serper.dev.

Run the Agent

Run the sales categories agent with any company name:
Example output:
You can replace “Nike” with any other company, e.g.:

Advanced Usage

Custom Category Filtering

Batch Company Analysis

Enhanced Category Analysis

Use Cases

  • Competitive Analysis: Understand competitor product categories and structure
  • Market Research: Analyze how companies organize their product offerings
  • E-commerce Intelligence: Gather insights about business models and focus areas
  • Category Mapping: Map product categories across different companies
  • Business Development: Identify potential partnership opportunities
  • Content Strategy: Understand how companies structure their navigation

File Structure

Notes

  • This agent depends on the find_company_website example. Make sure you have its code and .env setup in place
  • Modular Design: Components can be reused independently
  • Smart Filtering: Automatically excludes non-sales navigation items
  • Flexible Extraction: Works with various website structures
  • Error Handling: Graceful handling of failed requests and invalid websites

Dependencies

This example requires:
  • Serper API: For website discovery
  • Find Company Website: For website validation
  • BeautifulSoup: For HTML parsing
  • Upsonic Framework: For agent orchestration

Repository

View the complete example: Find Sales Categories Example