DEV Community

Anand Sukumaran
Anand Sukumaran

Posted on • Edited on

How to create a Youtube video summariser agent using EnvoyJS

In this tutorial, I will explain how you can build a Youtube video summariser AI agent using EnvoyJS, a minimal agentic framework in Javascript.

The idea

We will create a youtube video summariser agent and instruct them about their job. We will supply YoutubeTranscript tool to the agent so it can fetch the transcript of a given video.

We can either use the gpt-4o model, or deep-seek for this.

Install EnvoyJS library

npm i @envoyjs/core
Enter fullscreen mode Exit fullscreen mode

Import EnvoyJS library, and Youtube Transcript tool

import { Agent, youtubeTranscriptTool } from "@envoyjs/core";
Enter fullscreen mode Exit fullscreen mode

Create the agent

Let's create our agent using the Agent class.

const agent = new Agent({
    name: "Content Summariser Agent",
    bio: "You are an expert in reading YouTube video transcripts and summarizing what the video is about.",
    steps: [
        "Read the transcript",
        "Understand the entire context",
        "Find relevant portions",
        "Summarize as text",
        "Save it as a file"
    ],
    modelConfig: {
        provider: "OPEN_AI",
        apiKey: "", // Don't forget to add your OpenAI API key
        model: "gpt-4o"
    },
    tools: [youtubeTranscriptTool, fileWriterTool] // Add tools here
});
Enter fullscreen mode Exit fullscreen mode

In this class, we're giving instructions to the agent on how to do the task. We have given a bio, and then steps instructions on how to perform!

Running the agent!

Let's prompt the agent to do the work using the print_response() function.

agent.printResponse("Summarise this youtube video - https://www.youtube.com/watch?v=QtYEPYntfL4&t=27s");
Enter fullscreen mode Exit fullscreen mode

Now sitback and see how the agent analyses the task, take decisions to use the tool to fetch the transcript and summarise the video for you!

Top comments (0)