{
  "name": "SlideAI \u2014 07 Output Pipeline",
  "active": false,
  "nodes": [
    {
      "id": "ewt-o",
      "name": "When Called by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "get-proj-o",
      "name": "Get Project for Output",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        280,
        0
      ],
      "parameters": {
        "url": "=https://yqpvjtwldnkoersgqoti.supabase.co/rest/v1/projects?id=eq.{{ $json.project_id }}&select=*",
        "method": "GET",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Prefer",
              "value": "return=representation"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "export-agent",
      "name": "Export Agent \u2014 FastAPI (PPTX/PDF/HTML)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        560,
        0
      ],
      "parameters": {
        "url": "http://fastapi:8000/export",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={\"project_id\":\"{{ $json.project_id }}\"}",
        "options": {}
      }
    },
    {
      "id": "walkthrough-agent",
      "name": "Walk Through Agent \u2014 Groq",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        840,
        0
      ],
      "parameters": {
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "method": "POST",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "groqApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ JSON.stringify({ model: 'llama-3.3-70b-versatile', temperature: 0.7, max_tokens: 4096, messages: [{ role: 'system', content: \"You are a presentation coach. Generate a timed speaker script. Return JSON only: {\\\"total_minutes\\\":0,\\\"sections\\\":[{\\\"slide_order\\\":1,\\\"duration_seconds\\\":60,\\\"script\\\":\\\"...\\\"}]}\" }, { role: 'user', content: `Generate a timed ${$('Get Project for Output').first().json.duration_mins}-minute walkthrough script for: ${$('Get Project for Output').first().json.topic}` }] }) }}",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "qa-agent",
      "name": "Q&A Generation Agent \u2014 Groq",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1120,
        0
      ],
      "parameters": {
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "method": "POST",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "groqApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ JSON.stringify({ model: 'llama-3.3-70b-versatile', temperature: 0.7, max_tokens: 4096, messages: [{ role: 'system', content: \"You are a Q&A preparation expert. Return JSON only: {\\\"technical\\\":[{\\\"q\\\":\\\"\\\",\\\"a\\\":\\\"\\\"}],\\\"non_technical\\\":[{\\\"q\\\":\\\"\\\",\\\"a\\\":\\\"\\\"\"}]}\" }, { role: 'user', content: `Generate 10 Q&A pairs for: ${$('Get Project for Output').first().json.topic}. Audience: ${$('Get Project for Output').first().json.audience}` }] }) }}",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "save-walkthrough",
      "name": "Save Walkthrough Script",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1400,
        0
      ],
      "parameters": {
        "url": "https://yqpvjtwldnkoersgqoti.supabase.co/rest/v1/walkthrough_scripts",
        "method": "POST",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Prefer",
              "value": "return=representation"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ JSON.stringify({project_id:$('When Called by Another Workflow').first().json.project_id, script_data:$('Walk Through Agent \u2014 Groq').first().json.choices[0].message.content, total_minutes:$('Get Project for Output').first().json.duration_mins}) }}",
        "options": {}
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "package-agent",
      "name": "Package Agent \u2014 FastAPI (ZIP)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1680,
        0
      ],
      "parameters": {
        "url": "http://fastapi:8000/package",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={\"project_id\":\"{{ $('When Called by Another Workflow').first().json.project_id }}\"}",
        "options": {}
      }
    },
    {
      "id": "upd-done",
      "name": "Set Status \u2192 done",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1960,
        0
      ],
      "parameters": {
        "url": "=https://yqpvjtwldnkoersgqoti.supabase.co/rest/v1/projects?id=eq.{{ $('When Called by Another Workflow').first().json.project_id }}",
        "method": "PATCH",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Prefer",
              "value": "return=representation"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={\"status\":\"done\"}",
        "options": {}
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "log-agents",
      "name": "Log Agent Runs",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        2240,
        0
      ],
      "parameters": {
        "url": "https://yqpvjtwldnkoersgqoti.supabase.co/rest/v1/agent_runs",
        "method": "POST",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Prefer",
              "value": "return=representation"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ JSON.stringify([\n  {project_id:$('When Called by Another Workflow').first().json.project_id,agent_name:'Export Agent',status:'done',completed_at:new Date().toISOString()},\n  {project_id:$('When Called by Another Workflow').first().json.project_id,agent_name:'Walk Through Agent',status:'done',completed_at:new Date().toISOString()},\n  {project_id:$('When Called by Another Workflow').first().json.project_id,agent_name:'Q&A Generation Agent',status:'done',completed_at:new Date().toISOString()},\n  {project_id:$('When Called by Another Workflow').first().json.project_id,agent_name:'Package Agent',status:'done',completed_at:new Date().toISOString()}\n]) }}",
        "options": {}
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Called by Another Workflow": {
      "main": [
        [
          {
            "node": "Get Project for Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Project for Output": {
      "main": [
        [
          {
            "node": "Export Agent \u2014 FastAPI (PPTX/PDF/HTML)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export Agent \u2014 FastAPI (PPTX/PDF/HTML)": {
      "main": [
        [
          {
            "node": "Walk Through Agent \u2014 Groq",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Walk Through Agent \u2014 Groq": {
      "main": [
        [
          {
            "node": "Q&A Generation Agent \u2014 Groq",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Q&A Generation Agent \u2014 Groq": {
      "main": [
        [
          {
            "node": "Save Walkthrough Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Walkthrough Script": {
      "main": [
        [
          {
            "node": "Package Agent \u2014 FastAPI (ZIP)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Package Agent \u2014 FastAPI (ZIP)": {
      "main": [
        [
          {
            "node": "Set Status \u2192 done",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Status \u2192 done": {
      "main": [
        [
          {
            "node": "Log Agent Runs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}