---
title: "Summarise HubSpot in LangChain Agents with EnConvert"
description: "How to summarise HubSpot content inside a LangChain agent with EnConvert Distill, returning a clean LLM-ready summary of any HubSpot page in a single call"
canonical: "https://www.enconvert.com/solutions/summarise-hubspot-in-langchain-agents-with-enconvert"
locale: "en"
---

# How to Summarise HubSpot with LangChain

A LangChain agent that reads HubSpot content needs a summary of the page, not the page template around it. HubSpot pages carry navigation headers, cookie banners, CTA modules, subscription forms, and sidebar widgets, and all of it lands in the output when you fetch a URL directly. The HubSpot CMS API avoids the markup but requires OAuth authentication and portal-level access that you often do not have, and what it returns is raw HTML or structured JSON that still needs a separate summarisation step. EnConvert’s Distill endpoint takes a HubSpot URL and returns a clean summary of the page content in one API call, ready to pass into a LangChain tool.

## Example

```python
import os

import requests
from langchain.agents import create_agent
from langchain.tools import tool
from langchain_openai import ChatOpenAI

ENCONVERT_API_KEY = os.environ["ENCONVERT_API_KEY"]
HUBSPOT_URL = os.environ["HUBSPOT_URL"]  # e.g. https://knowledge.hubspot.com/forms/create-forms


# Step 1: Wrap EnConvert Distill in a LangChain tool
@tool
def summarise_hubspot_page(url: str) -> str:
    """Take a HubSpot page URL (knowledge base article, blog post, landing page, or support doc) and return a clean summary of its content."""
    response = requests.post(
        "https://api.enconvert.com/v2/distill",
        headers={
            "X-API-Key": ENCONVERT_API_KEY,
            "Content-Type": "application/json",
        },
        json={
            "urls": [url],
            "schema": {
                "summary": (
                    "a thorough summary of the page, starting with its title "
                    "and including any step-by-step instructions it gives"
                ),
            },
        },
        timeout=60,
    )
    response.raise_for_status()

    item = response.json()["results"][0]
    summary = (item.get("data") or {}).get("summary")
    if item.get("error") or not summary:
        raise RuntimeError(f"Distill failed for {url}: {item.get('error')}")
    return summary


# Step 2: Build a tool-calling agent around the tool
agent = create_agent(
    model=ChatOpenAI(model="gpt-5.5", api_key=os.environ["OPENAI_API_KEY"]),
    tools=[summarise_hubspot_page],
    system_prompt="You are a support research assistant. Use the tool to read HubSpot pages before answering.",
)

# Step 3: Ask the agent about the page
result = agent.invoke(
    {
        "messages": [
            {
                "role": "user",
                "content": (
                    f"Summarise {HUBSPOT_URL} "
                    "and list the steps it describes."
                ),
            }
        ]
    }
)

print(result["messages"][-1].text)
```

## Output

Distill returns the HubSpot page title and body content summarised into clean prose, with navigation, CTA modules, subscription forms, and cookie banners stripped before the response comes back. Raw HTML scraping returns HubSpot’s full page template with CMS markup embedded in the text. The HubSpot CMS API requires portal authentication and returns content fields that still need summarisation before they are useful inside an agent.

## Get started

[Get free API key — 500 ops per month, no card required.](https://www.enconvert.com/auth?mode=signup)

## Related solutions

- [How to Ingest Markdown Files into LlamaIndex with EnConvert](https://www.enconvert.com/solutions/ingest-markdown-files-into-llamaindex-with-enconvert.md)
- [How to Ingest Web Pages into Vertex AI with EnConvert](https://www.enconvert.com/solutions/ingest-web-pages-into-vertex-ai-with-enconvert.md)
- [How to Ingest Markdown into OpenAI File Search with EnConvert](https://www.enconvert.com/solutions/ingest-markdown-into-openai-file-search-enconvert.md)
- [How to Ingest HTML Files into LlamaIndex with EnConvert](https://www.enconvert.com/solutions/ingest-html-files-into-llamaindex-with-enconvert.md)
- [Best Browserless Alternative for Document Parsing](https://www.enconvert.com/solutions/browserless-alternative-for-document-parsing-enconvert.md)
- [How to Ingest DOCX into CrewAI with EnConvert](https://www.enconvert.com/solutions/ingest-docx-into-crewai-with-enconvert.md)
