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.
How to Summarise HubSpot with LangChain
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
Get API keyExample
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)
What you get back
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.