# PPTX Text Extraction

> Extracts text from Microsoft PowerPoint (.pptx) presentations by traversing the Office Open XML Presentation structure with python-pptx.

Source: https://docs.sommatic.ai/en/nodes/ai.pptx.extract.text/

- Slug: `ai.pptx.extract.text`
- Family: AI
- Version: 1.0.0
- Status: Available
- Execution: async

Extracts text from Microsoft PowerPoint (.pptx) presentations by traversing the Office Open XML Presentation structure with python-pptx.

Emits slide-by-slide content preserving deck order and separating visible slide text from presenter notes.

**Features:**
- **Slide order preservation:** Every slide produces a section marker with its slide number, title placeholder, and body placeholders concatenated in reading order.
- **Presenter notes:** Speaker notes are extracted per slide and emitted as a separate block so they can be used or filtered independently.
- **Tables within slides:** In-slide tables are rendered as markdown tables.
- **Shape traversal:** Text from grouped shapes, text frames, and SmartArt is flattened deterministically so the same deck always yields the same output.
- **Hidden slides:** Slides flagged as hidden are reported in metadata but excluded from the main text stream by default.

## Configuration

This node has no configuration fields.

Its configuration shows the shared execution settings, but this node does not apply retries (`retryOnFail`, `maxTries`) yet. `continueOnFail` is not applied by any node.

## Output ports

- `extracted` (default): Extracted
- `empty`: Empty
- `error`: Error

## Input contract

- `content_base64` (string, optional)
- `file_path` (string, optional)

## Output contract

- `text` (string, optional)
- `chars` (number, optional)
- `empty` (boolean, optional)
- `method` (string, optional)
- `metadata` (object, optional)

## In expressions

What a later node can read from this node's output with `$("PPTX Text Extraction").item.json.<path>` (write your node's label instead of `PPTX Text Extraction`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `extracted`, from the output shown in Ports.

- `$("PPTX Text Extraction").item.json.text` (string) = `"## Slide 1\n\nQuarterly review\n\nRevenue gr…"`
- `$("PPTX Text Extraction").item.json.chars` (number) = `106`
- `$("PPTX Text Extraction").item.json.empty` (boolean) = `false`
- `$("PPTX Text Extraction").item.json.method` (string) = `"python-pptx"`
- `$("PPTX Text Extraction").item.json.metadata` (object) = `{…}`
- `$("PPTX Text Extraction").item.json.metadata.slides_total` (number) = `3` (Not suggested by the editor)
- `$("PPTX Text Extraction").item.json.metadata.slides_with_content` (number) = `2` (Not suggested by the editor)


## How it works

Extracts the text of a .pptx presentation with python-pptx: one `## Slide n` block per slide with the text of its text boxes and placeholders, followed by the speaker notes.

1. Resolves the node config: expressions in config keys are evaluated against the run; the incoming item is used as-is.
2. Reads `content_base64` or `file_path` from the config first, then from the incoming item. If neither is present it returns `error`.
3. Opens the presentation and walks the slides in deck order. For each slide it keeps the text of every top-level shape that has a text frame, one paragraph per line.
4. Appends the speaker notes as `**Notes:** …` inside the slide block. Slides with no text and no notes are left out.
5. If the script fails it returns `error` with the Python message and stderr. Otherwise `empty: true` goes out through `empty` and any other result through `extracted`.

## In a workflow

### Node

```json
{
  "node_id": "node-pptx-text",
  "label": "Read deck text",
  "operator_slug": "ai.pptx.extract.text",
  "operator_version": "1.0.0",
  "config": {
    "execution": {
      "timeout_ms": 120000
    }
  }
}
```

### Envelope

```json
{
  "ok": true,
  "port": "extracted",
  "data": {
    "text": "## Slide 1\n\nQuarterly review\n\nRevenue grew 12%\n\n**Notes:** Mention the new region.\n\n## Slide 2\n\nNext steps",
    "chars": 106,
    "empty": false,
    "method": "python-pptx",
    "metadata": {
      "slides_total": 3,
      "slides_with_content": 2
    }
  }
}
```

## Output ports (behaviour in the code)

### `extracted`

At least one slide has text or notes.

```json
{
  "text": "## Slide 1\n\nQuarterly review\n\nRevenue grew 12%\n\n**Notes:** Mention the new region.\n\n## Slide 2\n\nNext steps",
  "chars": 106,
  "empty": false,
  "method": "python-pptx",
  "metadata": {
    "slides_total": 3,
    "slides_with_content": 2
  }
}
```

### `empty`

No slide has readable text or notes. Same shape with `text: ""` and `empty: true`.

```json
{
  "text": "",
  "chars": 0,
  "empty": true,
  "method": "python-pptx",
  "metadata": {
    "slides_total": 4,
    "slides_with_content": 0
  }
}
```

### `error`

The input is missing or the script fails. `data` is `{ error }` or `{ error, stderr }`.

```json
{
  "error": "File is not a zip file",
  "stderr": ""
}
```

## Behaviour in the code

- `execution.timeout_ms`: Timeout of the Python subprocess. When unset the code uses 120000 ms (the schema shows 300000 as the default).
- `content_base64 / file_path`: Not declared in the config schema, but read from the config before the incoming item. Use them to point at a file with an expression, e.g. `{{ $json.attachment.content_base64 }}`.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `Either content_base64 or file_path is required.` | `error` | Neither the config nor the incoming item has `content_base64` or `file_path`. Map the file from the previous node. |
| `Either content_base64 or file_path is required` | `error` | Raised by the Python script when `file_path` does not exist on the orchestrator host. Data also carries `stderr`. |
| `<exception message from the Python library>` | `error` | The file could not be read as a .pptx presentation (corrupt, encrypted or another format). `data.stderr` has the details. |
| `Python timed out after <timeout_ms>ms` | `error` | The script exceeded `execution.timeout_ms`. Raise it or process fewer pages. |
| `Python runtime not available (ENOENT)` | `error` | No Python interpreter is available on the orchestrator host. |

## Notes and limits

- Only top-level shapes with a text frame are read. Tables, grouped shapes, charts and SmartArt are skipped, although the description says otherwise.
- Hidden slides are not detected: they are extracted like any other slide. Notes are inline in each slide block, not a separate field.
- Only the Open XML format (.pptx) is supported; legacy .ppt files fail.
- `file_path` is a path on the orchestrator host. `content_base64` wins when both are present.
- The extraction runs in a Python subprocess. On first use the orchestrator creates a virtual environment and installs the pinned requirements, which can take minutes; later runs reuse it.
- The Python result is limited to 50 MB of output; above it the node leaves through `error`.
- The engine does not apply `execution.retryOnFail`, `maxTries`, `waitBetweenTries` or `continueOnFail` to this node. Handle failures by wiring the `error` port.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "ai.pptx.extract.text",
  "name": "PPTX Text Extraction",
  "category": "ai",
  "version": "1.0.0",
  "description": "Extracts text from Microsoft PowerPoint (.pptx) presentations by traversing the Office Open XML Presentation structure with python-pptx.\n\n  Emits slide-by-slide content preserving deck order and separating visible slide text from presenter notes.\n\n  **Features:**\n  - **Slide order preservation:** Every slide produces a section marker with its slide number, title placeholder, and body placeholders concatenated in reading order.\n  - **Presenter notes:** Speaker notes are extracted per slide and emitted as a separate block so they can be used or filtered independently.\n  - **Tables within slides:** In-slide tables are rendered as markdown tables.\n  - **Shape traversal:** Text from grouped shapes, text frames, and SmartArt is flattened deterministically so the same deck always yields the same output.\n  - **Hidden slides:** Slides flagged as hidden are reported in metadata but excluded from the main text stream by default.",
  "capabilities": [
    "pptx",
    "office",
    "powerpoint",
    "presentation",
    "text-extraction"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "content_base64": {
        "type": "string"
      },
      "file_path": {
        "type": "string"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string"
      },
      "chars": {
        "type": "number"
      },
      "empty": {
        "type": "boolean"
      },
      "method": {
        "type": "string"
      },
      "metadata": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "extracted",
      "label": "Extracted",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "empty",
      "label": "Empty",
      "is_default": false,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "tags": [
    "ai",
    "pptx",
    "office",
    "powerpoint",
    "presentation",
    "text"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "execution": {
      "type": "object",
      "title": "Execution Settings",
      "properties": {
        "alwaysOutputData": {
          "type": "boolean",
          "title": "Always Output Data",
          "description": "Always output data, even on error (if configured).",
          "default": false
        },
        "retryOnFail": {
          "type": "boolean",
          "title": "Retry On Fail",
          "description": "Retry the execution if it fails.",
          "default": false
        },
        "maxTries": {
          "type": "integer",
          "title": "Max Retries",
          "description": "Number of retries.",
          "default": 3,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "waitBetweenTries": {
          "type": "integer",
          "title": "Wait Between Retries (ms)",
          "default": 1000,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "continueOnFail": {
          "type": "boolean",
          "title": "Continue On Fail",
          "description": "Do not crash workflow on error.",
          "default": false
        },
        "timeout_ms": {
          "type": "integer",
          "title": "Timeout (ms)",
          "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
          "default": 300000
        }
      }
    }
  }
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "content_base64": {
      "type": "string"
    },
    "file_path": {
      "type": "string"
    }
  }
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "text": {
      "type": "string"
    },
    "chars": {
      "type": "number"
    },
    "empty": {
      "type": "boolean"
    },
    "method": {
      "type": "string"
    },
    "metadata": {
      "type": "object"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "extracted",
    "label": "Extracted",
    "is_default": true,
    "supports_condition": true
  },
  {
    "port_id": "empty",
    "label": "Empty",
    "is_default": false,
    "supports_condition": true
  },
  {
    "port_id": "error",
    "label": "Error",
    "is_default": false,
    "supports_condition": false
  }
]
```
