AI Notes -Summarize YouTube videos
Nowadays, AI gives incredible possibilities that can level up every day's productivity. Due to my solopreneur journey and making 12 products in 12 months, I have started researching coding AI apps.
If you are a javascript developer and you tried chatGPT or even better, openAI API you can code amazing software using langchain framework.
Let's look at a piece of software that can load YouTube videos by URL, get a transcript, and summarize it.
How to code it?
Below I will present you the logic of the flow:

The logic of the code sets the system prompts to be a little universal and handle not only YouTube URLs but tweets, websites, posts, newsletters, etc.
Then after initializing the notion client, there is created a previewUrl object, which will just embed a youtube video or link inside a notion page.
If URL is from youtube, the loadAndSummarizeYoutubeVideo is run and it looks like the below:

The above piece of code uses YoutubeLoader from langchain loaders and loads the transcript of the video, which can be found in object key "pageContent".
In the meantime, gpt 3.5 turbo (default model) is summarizing the transcript to be shorter than 1000 characters (according to the passed system prompt). You can see the context set to indicate that the URL is extracted from youtube.
PageContent is transformed into notion blocks cause of a limitation for one paragraph, we have to divide it into chunks and then push to the new notion page.
I just set the max length 990, to have a little shorter blocks of text.

Such API service gives amazing flow. I have connected it with apple shortcuts and set it to run on double tap of the back of the phone.

As you can see, I push the URL from the clipboard to my API, using endpoint notes/url. This is where my service is located.
Then the code on the server is executed and I can check the results in Notes dashboard in Notion.

Every created new page from the youtube URL contains the embedded URL, summarized overview, and transcript.
If you are stuck with some part of code, do not hesitate to ask a question in a moderndev discord channel
1000 subs on YouTube 🚀
Last week the counter on my channel hit the 1000 subs. Thank you for watching the content I provide. Here you can watch my latest video: