---
title: "Summarise Google Docs with LangGraph | EnConvert"
description: "Google Docs summarisation in LangGraph: EnConvert Distill returns schema-defined fields from up to 50 shared URLs in one synchronous call, no Drive API setup"
canonical: "https://www.enconvert.com/solutions/summarise-google-docs-with-langgraph-enconvert"
locale: "en"
---

# How to Summarise Google Docs with LangGraph

A developer building a LangGraph agent that reads shared Google Docs needs clean document content before reasoning or summarising. Google Docs shared via “anyone with the link” serve a full Drive UI with comment sidebars, suggestion overlays, and navigation chrome that obscures the document body, and the Drive API requires OAuth and project setup before a single document can be read. EnConvert Distill accepts the shared Google Doc URL, applies a schema the agent defines, and returns structured fields in one synchronous call. The agent gets structured document content ready for downstream reasoning with no Drive API credentials.

## Example

```python
import os
import requests
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode, tools_condition

# ChatOpenAI reads OPENAI_API_KEY from the environment
GOOGLE_DOC_URL = os.environ["GOOGLE_DOC_URL"]  # a Google Doc shared as "Anyone with the link can view"

BASE_URL = "https://api.enconvert.com/v2"
headers = {
    "X-API-Key": os.environ["ENCONVERT_API_KEY"],
    "Content-Type": "application/json",
}

# The fields the agent receives. The response keys match these names exactly.
DOC_SCHEMA = {
    "title": "The document title",
    "summary": "A three sentence summary of what the document covers",
    "key_points": "The main points or decisions in the document, as a list",
    "author": "The document owner or author, if the page shows one",
    "last_edited": "The date the document was last edited, if the page shows one",
}

@tool
def summarise_google_docs(urls: list[str]) -> str:
    """Reads shared Google Docs and returns structured fields for each document:
    title, summary, key points, author, and last edited date."""
    if len(urls) > 50:
        return "Too many URLs. Distill accepts at most 50 per call."

    # One synchronous call: no job_id, no polling, no download step
    response = requests.post(
        f"{BASE_URL}/distill",
        headers=headers,
        json={"urls": urls, "schema": DOC_SCHEMA},
        timeout=300,
    )

    # Distill runs on paid plans only, and the free tier returns 402
    if response.status_code == 402:
        return "Distill requires a paid plan."
    response.raise_for_status()

    documents = []
    for result in response.json()["results"]:
        # Failed pages come back as rows with a failed status, not as errors
        if result["status"] != "completed":
            documents.append(f"Source: {result['url']}\nCould not be read ({result['status']}).")
            continue

        # A render_quality below 0.5 may mean a login wall or challenge page
        render_quality = result.get("render_quality", 1.0)
        if render_quality < 0.5:
            documents.append(
                f"Source: {result['url']}\nLow render quality ({render_quality}), skipped."
            )
            continue

        data = result["data"]  # keys match DOC_SCHEMA exactly
        points = data["key_points"]
        documents.append(
            f"Source: {result['url']}\n"
            f"Title: {data['title']}\n"
            f"Author: {data['author']}\n"
            f"Last edited: {data['last_edited']}\n"
            f"Key points: {'; '.join(points) if isinstance(points, list) else points}\n"
            f"Summary: {data['summary']}"
        )
    return "\n\n---\n\n".join(documents)

tools = [summarise_google_docs]
llm = ChatOpenAI(model="gpt-4.1").bind_tools(tools)

def agent_node(state: MessagesState):
    return {"messages": [llm.invoke(state["messages"])]}

# The graph: the agent calls the tool when it needs a document, then answers
builder = StateGraph(MessagesState)
builder.add_node("agent", agent_node)
builder.add_node("tools", ToolNode(tools))
builder.add_edge(START, "agent")
builder.add_conditional_edges("agent", tools_condition)  # routes to "tools" or ends
builder.add_edge("tools", "agent")
graph = builder.compile()

result = graph.invoke(
    {
        "messages": [
            (
                "system",
                "You summarise shared Google Docs. Use summarise_google_docs to read the "
                "documents you need, answer only from what it returns, and cite the document "
                "URL for every statement.",
            ),
            (
                "user",
                f"Read {GOOGLE_DOC_URL} "
                "and summarise it, listing its key points.",
            ),
        ]
    }
)
print(result["messages"][-1].content)
```

## Output

Distill returns the schema-defined fields inline as structured JSON in the data object, with no polling, no job_id, and no signed URL to fetch. The render_quality score lets the agent detect a login wall or challenge page before reasoning over incomplete content. The Google Drive API requires OAuth 2.0 credentials, a GCP project, and a separate export call to retrieve document content, while Distill requires only the shared link and an API key.

## Get started

[Get free API key — 500 ops per month, no card required. Note: Distill runs on paid plans. Free tier returns 402.](https://www.enconvert.com/auth?mode=signup)

## Related solutions

- [How to Summarise GitHub with Pydantic AI](https://www.enconvert.com/solutions/summarise-github-with-pydantic-ai-enconvert.md)
- [How to Summarise GitHub with LlamaIndex](https://www.enconvert.com/solutions/summarise-github-with-llamaindex-enconvert.md)
- [How to Summarise Google Docs with Pydantic AI](https://www.enconvert.com/solutions/summarise-google-docs-with-pydantic-ai-enconvert.md)
- [How to Summarise YouTube Transcripts with LlamaIndex](https://www.enconvert.com/solutions/summarise-youtube-transcripts-with-llamaindex-enconvert.md)
- [How to Summarise GitHub Issues with CrewAI](https://www.enconvert.com/solutions/summarise-github-issues-with-crewai-enconvert.md)
- [How to Summarise GitHub Issues with LlamaIndex](https://www.enconvert.com/solutions/summarise-github-issues-with-llamaindex-enconvert.md)
