{
  "name": "Meeting Recording to Summary",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "YOUR_MEETING_RECORDINGS_FOLDER_ID",
          "mode": "id"
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "drive-trigger",
      "name": "Watch Recordings Folder",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        220,
        300
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "YOUR_GOOGLE_DRIVE_CREDENTIAL_ID",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "audio-check",
              "leftValue": "={{ $json.mimeType }}",
              "rightValue": "audio/",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "video-check",
              "leftValue": "={{ $json.mimeType }}",
              "rightValue": "video/",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "filter-media",
      "name": "Filter Media Files",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "file_id",
              "name": "file_id",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "file_name",
              "name": "file_name",
              "value": "={{ $json.name }}",
              "type": "string"
            },
            {
              "id": "mime_type",
              "name": "mime_type",
              "value": "={{ $json.mimeType }}",
              "type": "string"
            },
            {
              "id": "created_time",
              "name": "created_time",
              "value": "={{ $json.createdTime }}",
              "type": "string"
            },
            {
              "id": "web_link",
              "name": "web_link",
              "value": "={{ $json.webViewLink }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "set-file-data",
      "name": "Extract File Info",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        660,
        280
      ]
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.file_id }}",
          "mode": "id"
        },
        "options": {}
      },
      "id": "download-file",
      "name": "Download Recording",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        880,
        280
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "YOUR_GOOGLE_DRIVE_CREDENTIAL_ID",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "data",
        "options": {
          "language": "en",
          "responseFormat": "text",
          "temperature": 0
        }
      },
      "id": "whisper-transcribe",
      "name": "Transcribe with Whisper",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1100,
        280
      ],
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL_ID",
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "transcript",
              "name": "transcript",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "file_name",
              "name": "file_name",
              "value": "={{ $('Extract File Info').first().json.file_name }}",
              "type": "string"
            },
            {
              "id": "file_id",
              "name": "file_id",
              "value": "={{ $('Extract File Info').first().json.file_id }}",
              "type": "string"
            },
            {
              "id": "web_link",
              "name": "web_link",
              "value": "={{ $('Extract File Info').first().json.web_link }}",
              "type": "string"
            },
            {
              "id": "created_time",
              "name": "created_time",
              "value": "={{ $('Extract File Info').first().json.created_time }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "set-transcript",
      "name": "Store Transcript",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1320,
        280
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "content": "You are a meeting summarizer. Analyze this meeting transcript and create a structured summary.\n\nReturn ONLY valid JSON with these fields:\n\n1. title: A descriptive title for the meeting (infer from content if not stated)\n\n2. duration_estimate: Rough estimate of meeting length based on transcript length\n\n3. attendees: Array of names mentioned as participants (if detectable)\n\n4. summary: 2-3 paragraph executive summary of the meeting\n\n5. key_points: Array of 3-7 main discussion points (strings)\n\n6. decisions: Array of decisions made during the meeting (strings). If none clear, use []\n\n7. action_items: Array of objects with:\n   - task: What needs to be done\n   - owner: Who's responsible (if mentioned, else \"Unassigned\")\n   - deadline: When it's due (if mentioned, else \"TBD\")\n\n8. follow_up: Any mentioned follow-up meetings or next steps\n\n9. sentiment: Overall meeting tone - \"productive\", \"challenging\", \"routine\", or \"urgent\"\n\nExample output:\n{\n  \"title\": \"Q1 Marketing Strategy Review\",\n  \"duration_estimate\": \"45-60 minutes\",\n  \"attendees\": [\"Sarah\", \"Mike\", \"Jennifer\"],\n  \"summary\": \"The team reviewed Q1 marketing performance...\",\n  \"key_points\": [\"Social media engagement up 23%\", \"Email campaigns underperforming\"],\n  \"decisions\": [\"Increase Instagram ad budget by $500/month\"],\n  \"action_items\": [{\"task\": \"Draft new email templates\", \"owner\": \"Sarah\", \"deadline\": \"Friday\"}],\n  \"follow_up\": \"Weekly sync next Monday at 2pm\",\n  \"sentiment\": \"productive\"\n}",
              "role": "system"
            },
            {
              "content": "Meeting Recording: {{ $json.file_name }}\nDate: {{ $json.created_time }}\n\nTranscript:\n{{ $json.transcript }}",
              "role": "user"
            }
          ]
        },
        "options": {
          "temperature": 0.3,
          "maxTokens": 2000
        }
      },
      "id": "summarize-meeting",
      "name": "Generate Summary",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1540,
        280
      ],
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL_ID",
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Parse the OpenAI response to get clean JSON\nconst response = $input.first().json.message.content;\nconst fileData = $('Store Transcript').first().json;\n\ntry {\n  let summaryData;\n  \n  // Try to parse JSON directly\n  try {\n    summaryData = JSON.parse(response);\n  } catch (e) {\n    // Try to extract JSON from markdown code blocks\n    const jsonMatch = response.match(/```json?\\n?([\\s\\S]*?)\\n?```/);\n    if (jsonMatch) {\n      summaryData = JSON.parse(jsonMatch[1]);\n    } else {\n      throw new Error('Could not find valid JSON in response');\n    }\n  }\n  \n  // Add file metadata\n  summaryData.file_name = fileData.file_name;\n  summaryData.file_id = fileData.file_id;\n  summaryData.web_link = fileData.web_link;\n  summaryData.transcript = fileData.transcript;\n  summaryData.processed_at = new Date().toISOString();\n  \n  // Format action items for display\n  summaryData.action_items_formatted = (summaryData.action_items || [])\n    .map((item, i) => `${i+1}. ${item.task} (${item.owner}) - ${item.deadline}`)\n    .join('\\n');\n  \n  // Format key points for display\n  summaryData.key_points_formatted = (summaryData.key_points || [])\n    .map((point, i) => `• ${point}`)\n    .join('\\n');\n  \n  return [{ json: summaryData }];\n} catch (e) {\n  // Return error for manual review\n  return [{ \n    json: {\n      title: fileData.file_name,\n      summary: 'AI could not generate summary - manual review needed',\n      key_points: [],\n      decisions: [],\n      action_items: [],\n      file_name: fileData.file_name,\n      file_id: fileData.file_id,\n      web_link: fileData.web_link,\n      transcript: fileData.transcript,\n      processed_at: new Date().toISOString(),\n      parse_error: e.message,\n      action_items_formatted: 'None extracted',\n      key_points_formatted: 'None extracted'\n    }\n  }];\n}"
      },
      "id": "parse-summary",
      "name": "Parse Summary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1760,
        280
      ]
    },
    {
      "parameters": {
        "channel": "#meeting-summaries",
        "text": "=:clipboard: *Meeting Summary: {{ $json.title }}*\n\n:calendar: *Date:* {{ $json.processed_at.split('T')[0] }}\n:stopwatch: *Duration:* {{ $json.duration_estimate }}\n:busts_in_silhouette: *Attendees:* {{ $json.attendees ? $json.attendees.join(', ') : 'Not detected' }}\n:signal_strength: *Vibe:* {{ $json.sentiment }}\n\n---\n\n:page_facing_up: *Summary*\n{{ $json.summary }}\n\n---\n\n:pushpin: *Key Points*\n{{ $json.key_points_formatted }}\n\n---\n\n:white_check_mark: *Decisions Made*\n{{ $json.decisions && $json.decisions.length > 0 ? $json.decisions.map(d => '• ' + d).join('\\n') : 'No major decisions recorded' }}\n\n---\n\n:dart: *Action Items*\n{{ $json.action_items_formatted || 'No action items identified' }}\n\n---\n\n:link: <{{ $json.web_link }}|View Original Recording>\n_Full transcript attached as thread reply_",
        "otherOptions": {}
      },
      "id": "slack-summary",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1980,
        180
      ],
      "credentials": {
        "slackApi": {
          "id": "YOUR_SLACK_CREDENTIAL_ID",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "channel": "#meeting-summaries",
        "text": "=:page_facing_up: *Full Transcript for: {{ $json.title }}*\n\n```\n{{ $json.transcript.substring(0, 3000) }}{{ $json.transcript.length > 3000 ? '\\n\\n[Transcript truncated - ' + ($json.transcript.length - 3000) + ' more characters in original]' : '' }}\n```",
        "messageTs": "={{ $('Post to Slack').first().json.ts }}",
        "otherOptions": {}
      },
      "id": "slack-transcript",
      "name": "Reply with Transcript",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        2200,
        180
      ],
      "credentials": {
        "slackApi": {
          "id": "YOUR_SLACK_CREDENTIAL_ID",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $json.email_recipients || 'team@yourdomain.com' }}",
        "subject": "=Meeting Summary: {{ $json.title }}",
        "message": "=<h2>Meeting Summary: {{ $json.title }}</h2>\n\n<p><strong>Date:</strong> {{ $json.processed_at.split('T')[0] }}<br>\n<strong>Duration:</strong> {{ $json.duration_estimate }}<br>\n<strong>Attendees:</strong> {{ $json.attendees ? $json.attendees.join(', ') : 'Not detected' }}</p>\n\n<hr>\n\n<h3>Executive Summary</h3>\n<p>{{ $json.summary }}</p>\n\n<hr>\n\n<h3>Key Points</h3>\n<ul>\n{{ $json.key_points ? $json.key_points.map(p => '<li>' + p + '</li>').join('') : '<li>No key points extracted</li>' }}\n</ul>\n\n<hr>\n\n<h3>Decisions Made</h3>\n<ul>\n{{ $json.decisions && $json.decisions.length > 0 ? $json.decisions.map(d => '<li>' + d + '</li>').join('') : '<li>No major decisions recorded</li>' }}\n</ul>\n\n<hr>\n\n<h3>Action Items</h3>\n<table border=\"1\" cellpadding=\"8\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n<tr><th>Task</th><th>Owner</th><th>Deadline</th></tr>\n{{ $json.action_items && $json.action_items.length > 0 ? $json.action_items.map(a => '<tr><td>' + a.task + '</td><td>' + a.owner + '</td><td>' + a.deadline + '</td></tr>').join('') : '<tr><td colspan=\"3\">No action items identified</td></tr>' }}\n</table>\n\n<hr>\n\n<p><a href=\"{{ $json.web_link }}\">View Original Recording</a></p>\n\n<p><em>This summary was automatically generated. Please review for accuracy.</em></p>",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "email-summary",
      "name": "Email Summary (Optional)",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1980,
        400
      ],
      "credentials": {
        "gmailOAuth2": {
          "id": "YOUR_GMAIL_CREDENTIAL_ID",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Meeting Log",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $json.processed_at }}",
            "Title": "={{ $json.title }}",
            "Duration": "={{ $json.duration_estimate }}",
            "Attendees": "={{ $json.attendees ? $json.attendees.join(', ') : '' }}",
            "Summary": "={{ $json.summary }}",
            "Key Points": "={{ $json.key_points_formatted }}",
            "Decisions": "={{ $json.decisions ? $json.decisions.join('; ') : '' }}",
            "Action Items": "={{ $json.action_items_formatted }}",
            "Sentiment": "={{ $json.sentiment }}",
            "Recording Link": "={{ $json.web_link }}"
          }
        },
        "options": {}
      },
      "id": "sheets-log",
      "name": "Log to Spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2200,
        400
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "connections": {
    "Watch Recordings Folder": {
      "main": [
        [
          {
            "node": "Filter Media Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Media Files": {
      "main": [
        [
          {
            "node": "Extract File Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract File Info": {
      "main": [
        [
          {
            "node": "Download Recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Recording": {
      "main": [
        [
          {
            "node": "Transcribe with Whisper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe with Whisper": {
      "main": [
        [
          {
            "node": "Store Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Transcript": {
      "main": [
        [
          {
            "node": "Generate Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Summary": {
      "main": [
        [
          {
            "node": "Parse Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Summary": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email Summary (Optional)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Slack": {
      "main": [
        [
          {
            "node": "Reply with Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Summary (Optional)": {
      "main": [
        [
          {
            "node": "Log to Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "uzunu-automation-templates"
  },
  "pinData": {},
  "versionId": "1",
  "triggerCount": 1,
  "tags": [
    {
      "name": "notifications",
      "id": "notifications"
    },
    {
      "name": "reporting",
      "id": "reporting"
    },
    {
      "name": "meetings",
      "id": "meetings"
    }
  ]
}
