Skip to content

AI Trainer: Course Converter

This workflow transforms educational course documents (PDFs) into structured JSON format suitable for digital learning platforms. It uses AI to intelligently parse course content, extract learning objectives, identify different content types (text, audio, knowledge checks), and organize everything into a hierarchical course structure with units and blocks.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

This workflow serves educational content creators and digital learning platform administrators who need to convert traditional course documents into structured, machine-readable formats. It automates the tedious process of manually extracting and organizing course content, making it easier to deploy educational materials in digital learning systems.

How It Works

  1. Document Upload: A PDF course document is uploaded via webhook
  2. Text Extraction: The PDF content is extracted and converted to plain text
  3. Course Structure Parsing: The workflow identifies the course title, lesson information, and splits the document into EDU-coded sections
  4. Section Classification: Each section is analyzed to determine its type (text, audio, knowledge check, etc.) and metadata
  5. AI Content Extraction: OpenAI's GPT model processes each section to extract structured content according to predefined schemas
  6. Content Block Assembly: The extracted content is organized into properly formatted content blocks
  7. Final JSON Assembly: All blocks are grouped into units and assembled into a complete course JSON structure
  8. Response: The structured course data is returned via webhook response

Workflow Diagram

graph TD
    A[Webhook] --> B[Extract from File]
    B --> C[Set Course Text]
    C --> D[Parse Course Structure]
    D --> E[Split Sections]
    E --> F[Classify Sections]
    F --> G[Basic LLM Chain]
    G --> H[Code]
    H --> I[Aggregate]
    I --> J[Assemble Final JSON]
    J --> K[Format Output]
    K --> L[Respond to Webhook]

    M[OpenAI Chat Model] --> G
    N[Structured Output Parser] --> G

    O[Hardcoded payload] --> P[Respond to Webhook1]

Trigger

Webhook: POST request to /webhook/1a6c5fc2-2cac-410f-898b-289e638e25d9

The workflow is triggered by uploading a PDF document via HTTP POST request. The webhook expects multipart/form-data containing the course document.

Nodes Used

Node Type Purpose
Webhook Receives PDF upload requests and triggers the workflow
Extract from File Converts PDF documents to plain text
Set Stores extracted text and formats output data
Code Parses course structure, classifies sections, and assembles final JSON
Item Lists Splits course sections into individual items for processing
Basic LLM Chain Uses AI to extract structured content from course sections
Structured Output Parser Ensures AI responses match the required JSON schema
OpenAI Chat Model Provides the language model for content extraction
Aggregate Combines processed content blocks back together
Respond to Webhook Returns the structured course JSON to the client

External Services & Credentials Required

  • OpenAI API: Required for AI-powered content extraction
    • Credential: OpenAI Assistants API
    • Model: gpt-4.1-mini
    • Used for parsing and structuring course content

Environment Variables

No specific environment variables are configured in this workflow. All configuration is handled through node parameters and credentials.

Data Flow

Input: - PDF course document uploaded via multipart/form-data - Document should contain EDU-coded sections (e.g., EDU_6_1_1_TEXT) - Course content with learning objectives, text blocks, audio scripts, and knowledge checks

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
  "final_course_json": {
    "title": "Course Title",
    "description": "Course description",
    "course_code": "EDU",
    "units": [
      {
        "id": "EDU_X_X",
        "title": "Unit Title",
        "description": "Unit description",
        "order_index": 1,
        "learning_objectives": ["objective1", "objective2"],
        "blocks": [
          {
            "id": "EDU_X_X_X_TYPE",
            "type": "text|audio|knowledge_check|response",
            "order_index": 1,
            "content": {
              "text": "Content text",
              "audio_script": "Audio narration",
              "question": "Question text",
              "correct_responses": ["answer1", "answer2"],
              "feedback_correct": "Positive feedback",
              "feedback_incorrect": "Corrective feedback"
            },
            "metadata": {
              "response_type": "open_ended|specific_answer",
              "asset_references": ["ASSET_ID"]
            }
          }
        ]
      }
    ]
  },
  "parsing_statistics": {
    "total_units": 1,
    "total_blocks": 33,
    "block_types": ["text", "audio", "knowledge_check"],
    "unit_ids": ["EDU_1_1"],
    "items_processed": 1
  }
}

Error Handling

The workflow includes basic error handling:

  • JSON Parsing Fallback: If AI response is malformed JSON, the workflow falls back to using the raw response as text content
  • ID Parsing Validation: Invalid EDU ID formats are caught and logged with error messages
  • Content Extraction Fallback: If structured content extraction fails, the workflow uses default empty values to prevent workflow failure

Known Limitations

  • Currently processes documents with hardcoded test data (Hardcoded payload node is active)
  • Limited to PDF input format only
  • Requires specific EDU coding format in source documents
  • AI extraction quality depends on document structure and clarity
  • No validation of extracted content accuracy
  • Processing time scales with document size and complexity

No related workflows specified in the current context.

Setup Instructions

  1. Import Workflow: Import the workflow JSON into your n8n instance

  2. Configure Credentials:

    • Set up OpenAI API credentials with the name "OpenAI Assistants API"
    • Ensure the credential has access to GPT-4.1-mini model
  3. Webhook Configuration:

    • Note the webhook URL: https://your-n8n-instance.com/webhook/1a6c5fc2-2cac-410f-898b-289e638e25d9
    • Configure your client application to POST PDF files to this endpoint
  4. Disable Test Mode:

    • Disable the "Hardcoded payload" node
    • Enable the main processing path from "Webhook" → "Extract from File"
  5. Test the Workflow:

    • Upload a properly formatted EDU course PDF
    • Verify the JSON output structure matches your requirements
  6. Customize Content Schema:

    • Modify the "Structured Output Parser" schema if you need different content fields
    • Update the AI prompt in "Basic LLM Chain" to match your content extraction requirements
  7. Production Deployment:

    • Activate the workflow
    • Monitor execution logs for any processing errors
    • Set up appropriate error notifications if needed