Automation that only runs in a straight line is easy to reason about but often too rigid. Real workflows branch (if contract then legal review, else fast-track), merge (combine calendar + tasks + document queue into one brief), and sometimes loop (retry until signed). Modeling these as automation graphs—directed graphs where nodes are steps and edges define what runs next—gives you flexibility without losing clarity. This guide covers how to build automation graphs with OpenClaw and related tools for US professionals, including where document and PDF handling fits as nodes in the graph.
Summary Treat workflows as directed graphs: nodes are skills or steps, edges define order and conditions. Use OpenClaw (or your orchestrator) to run the graph, handle branches with conditions, and merge with stable output keys. When the graph includes document steps (summarize PDF, check contract status), use a single document pipeline such as iReadPDF so every path gets consistent text and summaries.
What Are Automation Graphs
An automation graph is a directed graph used to represent a workflow:
- Nodes are steps: run a skill, call an API, check a condition, or wait for an event. Each node has a clear input and output (or reads/writes shared state).
- Edges define what runs next. An edge from node A to B means "after A, run B." Edges can be unconditional (always follow) or conditional (follow only if some condition holds).
- State (or context) flows through the graph. After each node runs, its output is available to downstream nodes. Branches can run in parallel; merge nodes combine their outputs before the next step.
Unlike a simple list of steps, a graph can express "run A, then either B or C depending on X, then merge and run D." That matches many real US business workflows: triage to route by type, different paths for contracts vs. reports, then merge into one digest or dashboard.
Why Use Graphs Instead of Linear Chains
Linear chains (step 1 to step 2 to step 3) work when the flow is always the same. Graphs are better when:
- You have branching logic. "If the email has a PDF attachment, summarize it; otherwise just log it." One node produces a result; the next edge decides which branch to take.
- You have parallel work. Fetch calendar, tasks, and document queue at the same time, then merge into a single brief. The graph has three branches that converge at a "compose brief" node.
- You have retries or loops. "Summarize PDF; if summary is empty, retry once." That is a small cycle in the graph (with a max-iteration guard).
- Different triggers lead to different entry points. A webhook might enter at "new contract," while a cron job enters at "daily digest." Same graph, different starting nodes.
For US professionals, automation graphs make it easier to add "if contract, then legal review" or "if document queue has items, include doc summaries" without building separate workflows for every case.
Core Concepts: Nodes, Edges, and State
- Node. A single unit of work: execute a skill, evaluate a condition, or merge state. Give each node a unique ID and define what it reads (from state) and writes (to state). Example: node summarize_pdf reads file_path, writes summary and key_points.
- Edge. A directed link from one node to another. Unconditional edge: after summarize_pdf, run send_notification. Conditional edge: after classify_doc, run legal_review only if type equals contract.
- State. A key-value structure (or context object) that accumulates as the graph runs. Each node reads what it needs and writes what it produces. Downstream nodes see the union of all previous outputs. Keep key names stable (e.g. doc_summaries, calendar_events) so branches and merges stay consistent.
When document handling is in the graph, one or more nodes might produce doc_summaries or doc_queue. Using a single pipeline (e.g. iReadPDF) for "extract and summarize PDF" keeps that node output format consistent no matter which path led to it.
Designing Your First Graph
Step 1: Write Down the Outcome
Define the goal: "When a new contract lands in the folder, classify it, summarize it, and either send to legal or auto-file based on type." That implies: ingest, classify, summarize, branch (legal vs. file), then send or file.
Step 2: List Nodes and Their Inputs and Outputs
| Node ID | Action | Inputs | Outputs | |---------|--------|--------|---------| | ingest | Get new file from folder | folder_path | file_path, filename | | classify | Classify document type | file_path | doc_type | | summarize | Summarize PDF | file_path | summary, key_points | | branch | Decide path | doc_type | edge to legal_review or auto_file | | legal_review | Notify legal, log | summary, filename | done | | auto_file | Move and log | file_path, summary | done |
The summarize node is where a consistent PDF pipeline matters: iReadPDF can provide OCR and summarization so summary and key_points are always in the same shape for the branch and downstream nodes.
Step 3: Draw Edges
- ingest to classify to summarize to branch
- branch to legal_review (if contract) or branch to auto_file (if report)
- legal_review and auto_file are terminal nodes (no outgoing edges), or they both point to a single log_complete node.
Step 4: Define State Shape
Agree on keys: file_path, filename, doc_type, summary, key_points. Every node that writes uses these keys; every node that reads declares what it needs. That way parallel or alternative paths still produce a consistent state for any merge.
Try the tool
Branches and Conditional Edges
Branches choose the next node based on state.
- Conditional edge. After classify, the edge to the next node is not fixed; it depends on doc_type. In code or config, you might have: from classify, if doc_type equals contract go to legal_review, else go to auto_file.
- Guardrails. Ensure every branch eventually reaches a terminal or merge. Avoid unreachable nodes and accidental infinite loops (e.g. cap retries on a summarize loop).
- Document branches. When the branch depends on document content (e.g. "if summary mentions NDA"), the summarize node must run first and write to state. A single summarization step like iReadPDF keeps that content reliable so branching logic works as intended.
Merges and Parallel Paths
When multiple paths must feed one node, you need a merge.
- Explicit merge node. A node that only runs when all required inputs are present. Example: compose_brief runs after get_calendar, get_tasks, and get_document_status have all finished. The orchestrator waits for the three parallel branches, then runs compose_brief with combined state.
- Stable keys. Each parallel branch writes to different keys (calendar_events, task_list, doc_queue). The merge node (or the next node) reads all of them. No overwriting: each branch gets its own key so merges are predictable.
- Document path. One branch might be get_document_status or get_document_summaries. That branch might call your doc pipeline or read from memory populated by iReadPDF. The merge does not care how doc_queue was produced, only that it is in the agreed shape.
Where Document and PDF Steps Fit
Document and PDF handling are nodes in the graph, not scattered logic.
- Single summarize node. One node summarize_pdf takes file_path (or doc_id), calls your PDF pipeline (e.g. iReadPDF), and writes summary and key_points to state. Every path that needs a summary goes through this node so format and behavior are consistent.
- Optional document branch. In a morning brief graph, one parallel branch is get_document_status. If it fails or returns empty, the merge still works (e.g. doc_queue empty). The compose_brief node handles "no docs" and still produces a valid brief.
- Pre-populated state. Sometimes the graph does not run PDF extraction itself; it reads from memory or a store that was updated when the user added the PDF (e.g. via iReadPDF). Then the graph has a get_document_summaries node that only reads; the document pipeline is outside the graph but feeds it.
Using one document pipeline for all PDF steps keeps the graph simple and ensures reports, contracts, and other PDFs are handled the same way everywhere.
Implementing with OpenClaw
OpenClaw and similar tools can run graph-based workflows.
- Define the graph. In config or code, list nodes (skills or steps) and edges. Support conditional edges (e.g. next node equals f(state)) and merge points (run this node when nodes A, B, C are done).
- Execute. Start from the entry node(s), run each node with the current state, update state with the node output, and follow the appropriate edge(s). For parallel branches, run nodes concurrently and wait at the merge.
- Document nodes. For summarize_pdf or get_document_summaries, invoke your existing pipeline (e.g. script that uses iReadPDF or reads from its output). OpenClaw does not need to know PDF details; only that the node returns the agreed keys.
As you add more workflows, reuse the same document nodes across graphs so automation stays consistent and maintainable.
Conclusion
Automation graphs model workflows as directed graphs: nodes are steps, edges define order and conditions, and state flows through. They support branches, parallel paths, and merges so you can represent real US business flows (triage, route by type, merge into a brief). When the graph includes document or PDF steps, use a single pipeline such as iReadPDF for extraction and summarization so every path gets reliable, consistent input. Build your first graph by listing the outcome, defining nodes and state shape, drawing edges (including conditionals), and implementing with OpenClaw or your orchestrator.
Ready to add document nodes to your automation graph? Use iReadPDF for OCR and summarization so every branch and merge runs on consistent PDF text and summaries.