LangChain Code Execution for YouTube Video Summarization - n8n Workflow

Use this powerful n8n workflow template to integrate LangChain code directly into your automation. Summarize YouTube transcripts using OpenAI and the specialized n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation engineers looking to leverage advanced Python/JS libraries like LangChain within n8n.
Content marketers needing automated summarization of long-form video content.
Developers seeking robust examples of the custom LangChain Code n8n node.
Users searching for high-level, sophisticated n8n templates involving AI and data extraction.

Overview

This sophisticated automation demonstrates the true power of the n8n platform by integrating the flexibility of the LangChain framework directly into a custom n8n node. The core problem it solves is the automated processing and summarization of massive text inputs, such as long YouTube video transcripts, which standard LLM calls often struggle with due to token limits. This n8n workflow uses the LangChain library to handle the data loading (SearchApiLoader for transcripts), document splitting (TokenTextSplitter), and advanced chain execution (Refine Summarization Chain).

By deploying this n8n template, users gain a reliable method for extracting insights from video content, generating concise summaries, and preparing the content for potential RAG (Retrieval Augmented Generation) applications by pre-generating specific Q&A examples. This approach ensures maximum accuracy and efficiency when dealing with large documents within the context of an n8n automation.

How it Works

The execution of this n8n workflow is straightforward, yet the underlying logic is complex and powerful.


  1. Trigger and Setup: The process begins with the 'When clicking "Execute Workflow"' manual n8n trigger. Following this, the 'Set YouTube video ID' n8n node defines the specific YouTube video ID to be processed.

  2. AI Configuration: The 'OpenAI Chat Model' n8n node (a LangChain LM node) configures the necessary language model (using gpt-4o-mini) and connects its capability to the subsequent LangChain Code n8n node.

  3. LangChain Execution: The 'LangChain Code' n8n node forms the core of the automation. It uses a required SearchAPI key to load the video transcript using the SearchApiLoader.

  4. Data Processing: The JavaScript code within the n8n node utilizes TokenTextSplitter to break the potentially large transcript into manageable chunks. It then defines specialized prompts for the 'Refine' summarization strategy.

  5. Summarization Chain: The code initializes a loadSummarizationChain which uses the provided LLM (OpenAI) and the defined Refine prompts. This chain iteratively processes the chunks, building and refining the summary until the entire transcript is covered.

  6. Output: The final output of the n8n workflow is a comprehensive object containing the generated video summary and the accompanying example Q&A pairs.

Installation Guide

To use this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' option. This creates the full n8n workflow.

  2. OpenAI Credentials: You must provide credentials for the 'OpenAI Chat Model' n8n node. Click on the node and connect your existing OpenAI account credentials or create new ones.

  3. SearchAPI Key: A crucial step detailed in the sticky note is configuring the SearchAPI key. In the 'LangChain Code' n8n node, locate the line const searchApiKey = "" and replace with a valid API key from searchapi.io. This is necessary for fetching YouTube transcripts.

  4. Customization: Modify the 'Set YouTube video ID' n8n node if you wish to process a different video.

  5. Execution: Once configured, execute the n8n workflow by clicking 'Execute Workflow' to see the LangChain logic in action.

Node Details

This n8n template utilizes specialized and core n8n nodes:

When clicking "Execute Workflow" (Manual n8n Trigger):
Function: Starts the n8n workflow execution upon manual user command.
Key Configuration: Standard manual n8n trigger settings.

Set YouTube video ID (Set n8n node):
Function: Initializes the input data by setting a static videoId parameter for the LangChain code.
Key Configuration: Sets the value videoId to OsMVtuuwOXc.

OpenAI Chat Model (LangChain LM Chat OpenAI n8n node):
Function: Configures the large language model that the LangChain summarization chain will use.
Key Configuration: Uses the highly capable gpt-4o-mini model. Requires valid OpenAI credentials.

LangChain Code (LangChain Code n8n node):
Function: Executes custom JavaScript code leveraging the LangChain library for data extraction, document splitting, prompt engineering, and complex summarization chain execution. This n8n node is the heart of the automation.
Key Configuration: Contains logic to import SearchApiLoader, TokenTextSplitter, define Refine prompts, and execute loadSummarizationChain with the LLM input, requiring an external searchapi.io API key to function correctly.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
David Roberts
David Roberts

Featured*