7 min read

Building a YouTube Summary Bot with n8n + Telegram + Gemini

This guide will walk you through creating a YouTube summary bot using n8n, Telegram bot, and Gemini that works even without subtitles - completely free!
Building a YouTube Summary Bot with n8n + Telegram + Gemini

Directly Use Workflow

Prerequisites

Step 1: Integrating Telegram

Getting an API Token from Bot Father

BotFather
BotFather is the one bot to rule them all. Use it to create new bot accounts and manage your existing bots.

Click this link to use it directly on Telegram.

Getting an API Token requires 3 steps:

  1. Execute the /newbot command
  1. Enter a name : This is the display name in the chat room, don't worry about it being taken by others
name 的範例顯示方式
  1. Enter a username: This is the bot's unique ID. If it's already taken, you'll need to choose another name, and it must end with bot

The API Token format will be: 8888800000:ABCDE4lfG5i0NVaAxnozHeafaK2y-pNuHFA

BOT_ID:BOT_ALPHANUMERIC_PART

After obtaining the API Token, remember not to leak it to others or publish it on public networks.

In the next step, we'll add the Credential to the n8n Telegram node.

Adding n8n Telegram Credential

  1. In your n8n instance, select to add a Credential
  1. Find Telegram and click to add
  1. Fill in the Access Token field with the API Token you just obtained, and Save

Adding Telegram Node: Receiving Messages and Sending Stickers

Add Telegram Trigger Node

After adding the Telegram Trigger, we can try Pull Event, which means trying to send a message to the bot.

Here we can directly send a YouTube link to Telegram, which will be convenient for subsequent testing.

Example link to send: https://www.youtube.com/watch?v=CfM7JHJWe58

Click on the Execute Step on the left, and Telegram can start receiving messages.
After transmitting the message, corresponding data will appear on the right side, indicating that the receiving function is normal.

Next, we'll create a Telegram Send a Sticker node and drag the corresponding Chat ID to the designated field.

Copy your favorite sticker ID to the Sticker field:

CAACAgIAAxkBAAEPeuNo3MVT6jez0GGZsM406FsRRVo66QACKRUAAviLwEupQBIzh-Q46DYE

Example GIF used here
Execute Step,and see if the result popping out

If everything works correctly, we'll move to the next key node: Gemini Integration.

Step 2: Using Gemini

This step is the most crucial of all our nodes, but it all depends on you having registered an account at Google AI Studio and obtained an API Key.

Google AI Studio
The fastest path from prompt to production with Gemini

Don't worry, as long as you have a Google account, registration and obtaining an API Key can be completed in just a few steps.

Google AI Studio currently doesn't even charge additional fees, and provides very generous free quotas.
Besides Chat, these services are also worth exploring.

Getting a Google AI Studio API Key

This step is very simple:

  1. Log in to Google AI Studio with your Google account
  2. Click `Get API key` in the lower left corner
  3. You'll need to create a new project first
  4. The project here is to help you better manage your API keys and view usage for different projects
  5. Finally, create an API Key and prepare to fill it into n8n's Credential
Again, don't make your API Key public or provide it to others

Adding Credential

Add Google Gemini Credential in n8n

Fill in the API Key you just copied into the corresponding field.

After saving, if Connection tested successfully appears at the top, congratulations! You can now use Gemini's services in n8n!

Adding HTTP Node

Add HTTP Node in n8n

The following steps will be more complex. Since the official n8n Gemini node doesn't yet have the ability to directly retrieve YouTube transcripts, we'll interact with Gemini directly using API Requests.

Using Gemini API Video Understanding Feature

Video understanding | Gemini API | Google AI for Developers
Get started building with Gemini's multimodal capabilities in the Gemini API

Let's fill in the required content step by step into the HTTP Node:

  1. Select POST for Method
  2. Fill in the URL field:https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
  3. Select Predefined Credential Type for the Authentication field
    1. Select Google Gemini(PaLM) Api for Credential Type
    2. Select the Google AI Studio API Key you just created for Google Gemini(PaLM) Api
  4. Click Send Body
    1. Select JSON for Body Content Type
    2. Select Using JSON for Specify Body
    3. Paste the following content into the field
{
  "contents": [
    {
      "parts": [
        {
          "text": "Create a summary in zh-tw using its transcript. You will use the following template:\n\n\"\"\"\n\n## Summary\n\n{Multiple sentences summarising the YouTube video in zh-tw\n\n## Notes\n\n{Bullet points that summarize the key points or important moments from the video’s transcript with explanations in zh-tw}\n\n## Quotes\n\n{Extract 10 best sentences from the transcript in a list}\n\"\"\"\n\nTranscript: get from the video\n\nReturn Summary and Notes in zh-tw, but Quotes in original context"
        },
        {
          "file_data": {
            "file_uri": "{{ $('Telegram Trigger').item.json.message.text }}"
          }
        }
      ]
    }
  ]
}

Now we can execute Execute Step, and after waiting about a minute, results will be generated.

I specifically chose a video without subtitles as a reference, because the underlying logic is to have Gemini generate a YouTube video transcript, and then generate a summary based on that transcript.

At this point, we're basically done. Next, we just need to return the summary to Telegram to successfully complete this workflow.

Step 3: Returning Summary to Telegram

Formatting the Summary

Due to Telegram MarkdownV2 restrictions, summaries generated by AI are difficult to meet the requirements, making sending very prone to failure.
Therefore, I used telegramify-markdown + Cloudflare Workers & Pages to deploy a free service to solve this problem.

Markdown to Telegram MarkdownV2 Converter
Built using telegramify-markdown and Cloudflare Workers & Pages. Built by projectstain.dev

Add an HTTP node here and fill it in according to the steps below:

  1. Select POST for Method
  2. Fill in the URL field: `https://api.md2tg.projectstain.dev/`
  3. Click Send Body
    1. Select JSON for Body Content Type
    2. Select Using Fields Below for Specify Body
    3. Fill in markdown for Name
    4. Drag the text from the left side to the corresponding field for Value
  4. Click Execute Step and the output result will appear on the right side

Deleting Sticker and Returning Summary to Chat Room

The operation here is simple, just delete the previously sent sticker and finally return the summary.

After adding the "Delete Chat Message Node", drag chat_id and message_id to their corresponding fields.

Final steps:

  1. Add a Telegram Send a text message Node
  2. Drag the corresponding telegram_text and chat_id to the fields
  3. Select Parse Mode in Additional Fields
    1. 1. Select Markdown V2
  4. Results will appear after Execute Step

The Very Last Step: Activate Workflow

Click the top right to enable the workflow.

After activating the workflow, your YouTube summary bot is officially complete!


You can now drop any video you want to summarize into Telegram anytime, and it will work correctly on both mobile and desktop versions.