Build an AI Research Agent in n8n

Build a governed AI agent with a Telegram approval gate in n8n.

Introduction

30 Second Summary

AI tools are powerful, but would you trust one to send emails or update spreadsheets on your behalf without checking its work first? In the real world, AI agents need guardrails.

In this project, you will build an AI Research Agent in n8n that researches topics on demand, sends results to your Telegram for approval, and only saves or emails the output after you explicitly say yes.

What You'll Build

A governed n8n workflow where an AI Agent researches topics using GPT-4.1 mini, pauses for your Telegram approval, then logs results to Google Sheets and sends you a Gmail notification.

By the end of this project, you'll have:

  • A working AI Research Agent in n8n that uses tool calling to find and summarize information on any topic you send it.
  • A Telegram approval gate that pauses the entire workflow until you explicitly approve or reject the agent's output.
  • Connected multi-channel outputs that log approved research to Google Sheets and deliver a formatted email report via Gmail.
  • Secret Mission: Add a second specialist tool and structured output parsing so the agent intelligently decides which tool to use based on your request.

Are there any prerequisites?

None. This guide walks you through setting up every tool from scratch, including n8n Cloud, OpenAI, Telegram, Google Sheets, and Gmail. You just need a Mac and a Google account.

Set Up Your Tools

Your AI Research Agent needs to connect to three external services: n8n for orchestration, OpenAI for intelligence, and Telegram for human approval.

In this step, you will create accounts for each service and securely store their credentials inside n8n so your workflow can authenticate with them automatically.

In this step, get ready to:
  • Create your n8n Cloud account and open the canvas editor.
  • Generate an OpenAI API key and save it as a credential in n8n.
  • Create a Telegram bot and retrieve your personal chat_id.
Create your n8n Cloud account

n8n Cloud hosts your automation workflows so you can build and run them without managing a server. The free trial gives you 14 days of Pro features with 1,000 executions and no credit card required.

  • Open https://n8n.io/pricing/ in your browser.
  • Click Start free trial under the Starter plan.
  • Complete the sign-up form with your email and a password.
  • Once inside, you will land on the n8n canvas editor. This is where you will build your entire workflow.

What is the n8n canvas editor?

The canvas is a visual workspace where you drag, connect, and configure nodes. Each node represents one step in your automation (a trigger, an AI call, a message send, etc.).

Not seeing the canvas?

If you land on a dashboard or overview page instead, click New Workflow in the upper-right corner to open a blank canvas.

help me get to the n8n canvas editor

Get your OpenAI API key

The AI Agent you are building uses OpenAI's GPT-4.1 mini model to generate research summaries. To give n8n permission to call this model, you need an API key from your OpenAI account.

  • Open https://platform.openai.com and create an account (or sign in if you already have one).
  • Click your profile icon in the top-right corner.
  • Select API Keys from the dropdown menu.
  • Click Create new secret key.
  • In the Name field, type n8n-agent.
  • Click Create secret key.
  • Copy the key immediately. You will not be able to see it again after closing this dialog.

Add credit to your OpenAI account

OpenAI charges per token used. Navigate to Settings then Billing and add $5 of credit. This is more than enough for weeks of learning with gpt-4.1-mini (input costs $0.40 per 1M tokens, output costs $1.60 per 1M tokens).

Now save this key as a credential in n8n so your workflow can use it.

  • Switch back to your n8n Cloud tab.
  • Click the Create button in the upper-left corner of the side menu.
  • Select Credential.
  • Search for OpenAI and select it.
  • Paste your copied API key into the API Key field.
  • Leave the Organization ID field blank (unless you belong to multiple OpenAI organizations).
  • Click Save. When you save, n8n automatically tests the credential to confirm it works.

What does the green checkmark mean?

After saving, n8n displays a green checkmark next to your credential name. This means n8n successfully authenticated with OpenAI using your key. If you see a red error instead, double-check that you copied the full key and that your account has credit.

Seeing a credential error?

Make sure your OpenAI account has credit added under Billing. A new account without credit will fail the connection test even with a valid key.

help me fix my OpenAI credential in n8n

Create your Telegram bot

Telegram is how your agent will ask you for approval before it acts. You will create a personal bot that sends you research summaries and waits for your go-ahead.

  • Open the Telegram app on your phone or desktop.
  • In the search bar, type @BotFather and open the conversation with the verified BotFather account.
  • Send the message /newbot.

What is BotFather?

BotFather is Telegram's official bot for creating and managing other bots. It walks you through naming your bot and gives you an authentication token at the end.

BotFather will ask you two questions in sequence:

  • When it asks for a name, type something descriptive like FASA Approval Bot.
  • When it asks for a username, type a unique username ending in bot (e.g. fasa_approval_bot). If the name is taken, try adding numbers.
  • BotFather replies with a message containing your bot token. Copy this token.

Now save the bot token in n8n as a Telegram credential.

  • Switch back to your n8n Cloud tab.
  • Click Create in the upper-left side menu, then select Credential.
  • Search for Telegram and select Telegram API.
  • Paste your bot token into the Access Token field.
  • Click Save. You should see a green checkmark confirming the connection.

Finally, activate the bot and retrieve your personal chat_id. The chat_id tells n8n exactly which Telegram conversation to send approval messages to.

  • In Telegram, search for your new bot by its username (e.g. @fasa_approval_bot) and open the conversation.
  • Send any message to the bot (e.g. hello). This activates the bot so it can receive and send messages.
  • Now search for @get_id_bot in Telegram and open a conversation with it.
  • Send it any message. It will reply with your personal chat ID (a numeric value like 123456789).
  • Save this number somewhere safe. You will use it in Step 3 when configuring the approval gate.

Why do I need my chat_id?

Telegram bots identify conversations by numeric chat IDs, not usernames. Your personal chat_id ensures approval messages land in your private conversation with the bot and nowhere else.

Bot not responding?

Make sure you opened a direct conversation with your bot (not BotFather). You must send it at least one message before n8n can interact with it.

help me get my Telegram bot working

All three services are connected and ready. Next up, you will build the AI Research Agent on the n8n canvas and watch it generate structured research summaries.

Build the AI Research Agent

Your tools are ready. You have n8n open, your OpenAI credentials saved, and your Telegram bot configured.

Now it is time to build the core of your workflow. You will create an AI Agent that takes a research topic, searches the web for information, and returns a structured summary. This is the foundation of every agentic workflow: a trigger, a reasoning engine, and a tool the agent can call.

In this step, get ready to:
  • Add a Chat Trigger and AI Agent node to your workflow.
  • Connect an OpenAI Chat Model and HTTP Request Tool to the agent.
  • Test the agent by sending a research topic and verifying the structured response.
Add a Chat Trigger and AI Agent node

Every n8n workflow starts with a trigger node that kicks things off. The Chat Trigger gives you a built-in chat interface inside n8n where you can type messages to your agent. No external frontend needed for testing.

  • In the n8n canvas, click Add first step (or press the + icon) to open the node menu.
  • Search for Chat Trigger and select it to add it to your canvas.
  • Close the node details by clicking Back to canvas.

Now you will add the AI Agent node. This is the reasoning engine that decides what to do with a user's message.

  • Click the Add node connector (the small circle on the right side of the Chat Trigger node).
  • Search for AI Agent and select it.
  • The AI Agent node opens with its settings panel visible. Leave the Prompt source as the default (Connected Chat Trigger Node). This passes whatever the user types directly to the agent.

Next, set the System Message. This tells the agent who it is and how to format its responses.

  • In the AI Agent settings panel, scroll down and click Add Option at the bottom.
  • Select System Message from the dropdown.
  • Paste the following into the System Message field:
You are a research assistant. When given a topic, use your available tools to find current information. Return a structured summary with: Topic, Key Findings (3-5 bullet points), Sources, and a Confidence Score (high/medium/low).

What does this System Message do?

The System Message acts as permanent instructions the agent follows for every interaction. It cannot be overridden by user messages.

By specifying a structured format (Topic, Key Findings, Sources, Confidence Score), you ensure the agent always returns consistent, readable results instead of freeform text.

  • Click Back to canvas to return to the workflow view.

You should see two nodes on your canvas: the Chat Trigger connected to the AI Agent with a line between them.

Don't see the AI Agent connected?

Make sure the line runs from the Chat Trigger's output (right side) to the AI Agent's input (left side). If they are not connected, drag from the Chat Trigger's connector to the AI Agent node.

help me connect my Chat Trigger to my AI Agent node in n8n

Connect the Chat Model and HTTP Request Tool

The AI Agent node has sub-node slots along its bottom edge for a Chat Model, Memory, and Tools. You will connect your OpenAI model as the brain and an HTTP Request Tool as the agent's way to search the web.

  • Click on the AI Agent node to open it.
  • Click the + button underneath the Chat Model connector (the first slot along the bottom of the node).
  • Search for OpenAI Chat Model and select it.
  • In the Credential dropdown, select your saved OpenAI API credential (the one showing a green checkmark from Step 1).
  • In the Model dropdown, select gpt-4.1-mini.

Why gpt-4.1-mini?

GPT-4.1 mini excels at instruction following and tool calling. It has a 1M token context window and low latency without a reasoning step. At $0.40 per 1M input tokens, it is cost-effective for agent workflows where the model needs to call tools reliably.

  • Click Back to canvas to return to the AI Agent node view.

Now add the HTTP Request Tool so your agent can search the web.

  • Click the + button underneath the Tool connector on the AI Agent node.
  • Search for HTTP Request and select HTTP Request Tool.
  • In the Method field, select GET.
  • In the URL field, type the word placeholder. This tells n8n that the agent will supply the actual URL at runtime.
  • In the Description field, enter:
Search the web for current information on a given topic

What does typing placeholder in the URL do?

When you type placeholder in the URL field, n8n marks it as a dynamic parameter. The AI Agent fills in the actual URL at runtime based on what it decides to search. This is how the agent controls its own tool usage.

The Description field is equally important. It tells the agent when and why to use this tool. A clear description produces more reliable tool calls.

  • Under Optimize Response, set Response Type to Text. This prevents the agent from receiving raw HTML that would overwhelm its context window.
  • Click Back to canvas.

Your canvas should now show the Chat Trigger connected to the AI Agent, with the OpenAI Chat Model and HTTP Request Tool attached as sub-nodes beneath the agent.

Don't see the sub-nodes beneath the AI Agent?

Sub-nodes appear as smaller nodes connected to the bottom of the AI Agent. If you do not see them, click on the AI Agent node to open it and verify the Chat Model and Tool slots both show connected nodes (not empty + buttons).

help me verify my AI Agent sub-nodes are connected correctly

Test the agent with a research topic

Your agent is wired up. Time to see it work. The Chat Trigger provides a built-in chat panel right inside n8n for testing.

  • Click the Chat button near the bottom of the canvas. A chat window opens on the left with agent logs on the right.
  • Type the following test message and press Enter:
latest trends in AI automation 2026
  • Watch the agent logs on the right side. You should see the agent reason about the request, call the HTTP Request Tool, and then return a structured response.

The response should include the sections you specified in the System Message: Topic, Key Findings (3-5 bullet points), Sources, and a Confidence Score.

What am I seeing in the logs?

The log panel shows the agent's reasoning loop step by step. It shows when the agent decides to use a tool, what URL it fetched, what data came back, and how it composed the final answer. This is called the ReAct pattern: Reason, Act, Observe, Repeat.

Agent not calling the HTTP tool?

Make sure the HTTP Request Tool's Description field is filled in. Without a description, the agent does not know when to use the tool.

Also verify that the URL field contains exactly the word placeholder (lowercase, no quotes). If the URL field is empty or has a different value, the agent cannot use the tool dynamically.

help me debug why my n8n AI Agent is not calling the HTTP Request Tool

Your AI Research Agent is alive. It can take any topic, search the web, and return a clean structured summary. Next up, you will add a Telegram approval gate so the agent cannot act on its research without your explicit sign-off.

Add the Telegram Approval Gate

Your AI Agent is researching topics and returning structured summaries. The next question is: how do you prevent it from acting on bad results without your say-so?

In this step, you will add a human-in-the-loop approval gate using Telegram. The workflow will pause after the agent produces a summary, send it to your phone for review, and only continue if you explicitly approve.

In this step, get ready to:
  • Send the agent's research output to your Telegram bot for review.
  • Pause the workflow until you reply with /approve or /reject.
  • Route the workflow based on your approval decision.
Send the research summary to Telegram

Right now the AI Agent's output flows straight through to whatever comes next. You need a checkpoint where you can read the summary before the workflow takes any further action.

  • On the n8n canvas, click the + button on the right side of the AI Agent node to add a new node after it.
  • Search for Telegram and select the Telegram node.
  • In the Credential to connect with dropdown, select the Telegram API credential you saved earlier.
  • Set Resource to Message.
  • Set Operation to Send Text Message.
  • In the Chat ID field, enter your personal chat_id (the one you retrieved in Step 1).
  • Click the Message field, then click the Expression tab (the orange toggle) to switch to expression mode.
  • Paste the following expression into the Message field:
APPROVAL REQUIRED:

{{ $json.output }}

Reply /approve to proceed or /reject to discard.

What does this expression do?

The {{ $json.output }} expression pulls the AI Agent's text response from the previous node's JSON output. n8n's $json shorthand accesses the current input item's data.

The surrounding text gives you clear instructions when the message arrives on your phone. You will see the full research summary sandwiched between the approval header and the reply instructions.

  • Close the Telegram node panel.
  • Verify on the canvas that the connection runs from AI Agent to the Telegram node.

Rename your nodes early

Double-click the Telegram node's title on the canvas and rename it to Send for Approval. Clear names make the workflow easier to debug as it grows.

Add the Wait node and approval logic

The workflow needs to pause after sending the Telegram message and wait for your reply. A Wait node configured to resume on a webhook call handles this perfectly.

  • Click the + button on the right side of the Telegram node to add a new node after it.
  • Search for Wait and select the Wait node.
  • Set Resume to On Webhook Call.
  • Leave the other defaults as-is. This tells n8n to pause the entire execution until the Wait node's unique webhook URL is called.

What is the Wait node doing here?

When this node executes, n8n offloads the workflow state to its database and generates a unique resume URL ($execution.resumeUrl). The workflow stays paused until that URL receives an HTTP call, which will happen when you reply in Telegram.

This is the core mechanism behind any human-in-the-loop approval gate. No code needed.

Next, you need an If node to check whether you approved or rejected the request.

  • Click the + button on the right side of the Wait node.
  • Search for If and select the If node.
  • In the If node, set the condition to check whether the incoming reply contains your approval command.
  • Set Value 1 (left side) to the expression {{ $json.body.message.text }}. This pulls the text of your Telegram reply from the webhook payload.
  • Set the Operation to Contains.
  • Set Value 2 (right side) to /approve.

What do the two branches do?

The If node creates two output branches. The True branch fires when your reply contains /approve. This is where you will connect Google Sheets and Gmail in the next step.

The False branch fires for anything else (including /reject). You will connect a response node here to log the rejection.

Now add a node to handle rejected requests.

  • Click the + button on the False output of the If node.
  • Search for Edit Fields (also called Set) and select it.
  • Add a field named status with the value Rejected.
  • Rename this node to Rejected by double-clicking its title on the canvas.

Why use an Edit Fields node for rejection?

This node creates a clean data record showing the request was rejected. In a production workflow, you could send this to a logging service or notify a team. For now, it marks the end of the False branch so nothing else executes on rejected requests.

Your canvas should now show the chain: AI Agent, Telegram send node, Wait, If, with the False branch going to the Rejected node. The True branch is left open for the next step.

Don't see the False branch?

The If node always shows two output connectors. The top one is True, the bottom one is False. If you accidentally connected to the wrong branch, drag the connection line to the correct output.

Help me fix my If node connections

Test the full approval flow

The approval gate is wired up. Time to confirm it actually pauses and resumes based on your Telegram reply.

  • Click Chat in the Chat Trigger node to open the built-in chat panel.
  • Type a research topic like latest trends in AI automation 2026 and press Enter.
  • Watch the workflow execute through the AI Agent and Telegram nodes. The execution indicator should pause at the Wait node.
  • Open Telegram on your phone. You should see a message from your bot starting with APPROVAL REQUIRED: followed by the research summary.
  • Reply to the bot message with /approve.
  • Return to the n8n canvas. The execution should resume past the Wait node and continue through the If node's True branch.

What should I see?

The execution view in n8n shows green checkmarks on each node that executed successfully. After you reply /approve in Telegram, the Wait node turns green and data flows into the If node. The True branch lights up because your reply contained /approve.

Now test the rejection path.

  • Click Chat again and send another research topic.
  • Wait for the Telegram message to arrive on your phone.
  • Reply with /reject.
  • Return to the n8n canvas. This time, the If node's False branch should light up and the Rejected node should execute.

Workflow not resuming after your Telegram reply?

Make sure you are replying directly to the bot in the same chat where the message arrived. A reply in a different chat or group will not trigger the Wait node's webhook.

Also confirm the workflow is still running (not timed out). Check the Executions tab in n8n to see if the execution is listed as waiting.

Help me debug why my workflow isn't resuming

Your agent now has a governance gate. No research summary can reach your output channels without your explicit approval. Next up, you will connect Google Sheets and Gmail so that approved research gets logged and emailed to you automatically.

Connect Output Channels

Your approval gate is working. The agent sends research to Telegram, waits for your reply, and routes accordingly.

Now you need somewhere for approved research to land. In this step, you will connect two output channels: Google Sheets to log every approved result, and Gmail to deliver a formatted report straight to your inbox.

In this step, get ready to:
  • Connect Google Sheets to your workflow and log approved research.
  • Add a Gmail node that emails you approved research summaries.
  • Run a full end-to-end test confirming both outputs work and rejections produce no output.
Add Google Sheets credentials and create your research log

Before the workflow can write data to a spreadsheet, n8n needs permission to access your Google account. Since you are on n8n Cloud, you can use Managed OAuth2, which handles the entire connection with a single sign-in.

  • In n8n, click your profile icon in the bottom-left corner, then click Credentials.
  • Click Add Credential.
  • Search for Google Sheets OAuth2 API and select it.
  • Click Sign in with Google.
  • Choose the Google account you want to use for this project and grant access.
  • Click Save.

What is Managed OAuth2?

n8n Cloud handles the OAuth2 handshake for you behind the scenes. You do not need to create a Google Cloud Console project, configure an OAuth consent screen, or copy client IDs. Just sign in and grant access.

Next, create the spreadsheet that will serve as your research log.

  • Open Google Sheets in a new browser tab.
  • Create a new blank spreadsheet.
  • Rename it to AI Research Log.
  • In the first row, type these column headers across cells A1 to E1: Date, Topic, Summary, Confidence, Status.

Now connect the Google Sheets node to your workflow's True branch.

  • Return to the n8n canvas editor.
  • Click the + button on the True output of your If node.
  • Search for Google Sheets and select the Google Sheets node.
  • In Credential to connect with, select the Google Sheets OAuth2 credential you just created.
  • Set Resource to Sheet Within Document.
  • Set Operation to Append Row.
  • In Document, select From list and choose AI Research Log.
  • In Sheet, select the default sheet (Sheet1).
  • Map the incoming data to your columns using expressions. Set Date to the current date, Topic to the research topic, Summary to the agent's summary output, Confidence to the confidence score, and Status to Approved.

How do I map expressions to columns?

Click the field next to each column name, then switch to the Expression tab. You can drag values from the input panel on the left, or type expressions like {{ $json.output }} to reference data from the previous node.

The exact field names depend on how your AI Agent formats its output. Look at the output panel of the If node to see the available fields.

Google Sheets not appearing in the document list?

Make sure you created the spreadsheet with the same Google account you used for the OAuth2 credential. If you used a different account, the sheet will not appear in the list.

Also confirm you saved the credential with a green checkmark before opening the Google Sheets node.

Help me troubleshoot my Google Sheets connection in n8n.

Add a Gmail node to email yourself approved research

The Google Sheets node logs data for reference. The Gmail node delivers a formatted summary straight to your inbox so you never miss an approved result.

  • Click the + button on the output of the Google Sheets node.
  • Search for Gmail and select the Gmail node.
  • In Credential to connect with, click Create New Credential.
  • Click Sign in with Google and grant access using the same Google account.
  • Click Save to store the credential.
  • Set Resource to Message.
  • Set Operation to Send.
  • In the To field, enter your own email address.
  • In the Subject field, use an expression to produce a subject like Research Approved: [Topic] where the topic is pulled dynamically from the agent's output.
  • Set Email Type to HTML.
  • In the Message field, use an expression to insert the formatted research summary from the AI Agent's output.

Use HTML for readable emails

Selecting HTML as the email type lets you use line breaks and basic formatting. You can wrap the agent's bullet-point output in <p> or <ul> tags to make the email scannable.

Getting a permission error when connecting Gmail?

n8n Cloud's Managed OAuth2 supports the Gmail node directly. If you see a permissions error, make sure you granted both Send email and View email permissions during the Google sign-in prompt.

Help me fix my Gmail credential connection in n8n.

Run the full end-to-end test

You now have the complete workflow chain: Chat Trigger, AI Agent, Telegram approval, Google Sheets, and Gmail. Time to verify both the approval and rejection paths produce the correct outcomes.

  • Click Chat on the Chat Trigger node to open the chat panel.
  • Send a research topic, for example: latest trends in AI automation 2026.
  • Wait for the research summary to appear in your Telegram chat.
  • Reply with /approve in Telegram.
  • Open your AI Research Log spreadsheet and verify a new row appeared with the research data.
  • Check your Gmail inbox for an email with the subject line containing your research topic.

Both outputs should now contain the approved research. Next, test the rejection path.

  • Return to the n8n chat panel and send a second topic, for example: competitors in AI automation agencies.
  • When the summary arrives in Telegram, reply with /reject.
  • Open your AI Research Log spreadsheet and confirm no new row was added.
  • Check your Gmail inbox and confirm no new email arrived for this topic.

What should I see?

After the approval test: your spreadsheet has a new row with the date, topic, summary, confidence score, and a status of Approved. Your inbox has a new email with the subject Research Approved: [your topic].

After the rejection test: the spreadsheet stays unchanged and no email arrives. The workflow's False branch handled the rejection without triggering any output nodes.

Approved but nothing in Sheets or Gmail?

Open the workflow execution log by clicking Executions in the left sidebar. Click the most recent execution to see which node failed. The most common issue is an expression error in the column mapping where the field name does not match the AI Agent's output structure.

My approved research isn't showing up in Google Sheets or Gmail. Help me debug.

Your agent now has full governed output. Approved research is logged and emailed. Rejected research goes nowhere. Next up, you will polish the workflow with documentation and save it to GitHub as your first portfolio piece.

Polish and Save to GitHub

Your research agent works end to end. Requests go in, structured research comes out, and nothing moves forward without your explicit approval in Telegram.

Now it is time to make this workflow production-ready. You will document the canvas so anyone (including future-you) can understand it at a glance, add safety nets for failures, and save everything to GitHub as your first portfolio piece.

In this step, get ready to:
  • Rename nodes and add Sticky Notes to document your workflow.
  • Add error handling and a timeout for stale approvals.
  • Export your workflow and upload it to a GitHub repository.
Document and rename your workflow nodes

Clear names and visual labels make your workflow readable months later and signal professionalism to clients reviewing your portfolio.

  • Click on the AI Agent node on your canvas to select it.
  • Press F2 on your keyboard to enter rename mode.
  • Type Research Agent and press Enter.
  • Repeat for the remaining nodes using these names:
  • Telegram Send node: Send for Approval.
  • Wait or Telegram Trigger node: Check Approval.
  • Google Sheets node: Log to Sheets.
  • Gmail node: Send Email.

Now add Sticky Notes to visually group the sections of your workflow.

  • Press Shift+S to add a Sticky Note to your canvas.
  • Double-click the note to edit it.
  • Type Trigger as the note text.
  • Drag the note behind the Chat Trigger node and resize it to frame that node.
  • Add three more Sticky Notes using Shift+S and label them: AI Agent + Tools, Approval Gate, and Output Channels.
  • Position each note behind the corresponding group of nodes on your canvas.

Why document your canvas?

When you share a workflow JSON, the Sticky Notes travel with it. Anyone who imports your workflow immediately sees the logical sections without reading every node.

This is especially important for client work, where someone else may need to maintain your automations.

  • Save your workflow by pressing Cmd+S (macOS) or Ctrl+S (Windows).
  • Verify that all five nodes show their new names and the four Sticky Notes are visible behind each group.

Node name not changing?

Make sure the node is selected (highlighted) before pressing F2. If a node's detail panel is open, close it first by clicking the canvas background, then click the node once to select it.

Help me rename nodes in my n8n workflow.

Add error handling and a timeout

Production workflows need safety nets. If the HTTP tool fails or you forget to reply to an approval request, the workflow should handle it gracefully instead of hanging forever.

  • Create a new workflow by pressing Cmd+Alt+N (macOS) or Ctrl+Alt+N (Windows).
  • In the new workflow, select Add first step.
  • Search for Error Trigger and select it to add it to the canvas.
  • Add a Telegram node after the Error Trigger by clicking the + connector on the Error Trigger node.
  • Search for Telegram and select Send a Text Message.
  • Set the Credential to connect with to your saved Telegram API credential.
  • Set Chat ID to your personal chat_id (the same one from your approval gate).
  • In the Text field, type a message like: Workflow failed! Error: {{ $json.execution.error.message }} in node: {{ $json.execution.lastNodeExecuted }}.
  • Name this workflow Error Handler and save it by pressing Cmd+S (macOS) or Ctrl+S (Windows).

What is an Error Trigger?

The Error Trigger node runs a separate workflow whenever a linked workflow fails. It receives data about the failed execution including the error message, the last node that ran, and a URL to the failed execution.

You do not need to publish the error workflow. It activates automatically when the linked workflow errors during a production run.

Now link this error workflow to your Research Agent workflow.

  • Switch back to your Research Agent workflow.
  • Click the three dots icon in the upper-right corner of the canvas.
  • Select Settings.
  • In the Error workflow dropdown, select Error Handler.
  • While in Settings, enable Timeout Workflow.
  • In the Timeout After field that appears, set the value to 24 hours.
  • Click Save to close the settings modal.

Why set a 24-hour timeout?

Without a timeout, the Wait node holds the execution open indefinitely if you never reply in Telegram. This consumes one of your concurrent execution slots on n8n Cloud.

A 24-hour timeout auto-cancels stale requests, freeing resources and keeping your workflow dashboard clean.

  • Save the workflow again by pressing Cmd+S (macOS) or Ctrl+S (Windows).

Don't see Error Handler in the dropdown?

Make sure you saved the Error Handler workflow in the previous step. The dropdown only shows saved workflows that contain an Error Trigger node as the first node.

Help me link my error workflow in n8n.

Export your workflow and upload to GitHub

Saving your workflow to GitHub creates a permanent record of your work. It also gives potential clients a direct link to see what you can build.

  • In your Research Agent workflow, click the three dots icon in the upper-right corner.
  • Select Download to export the workflow as a JSON file.
  • Your browser saves the file to your Downloads folder.

Now create a GitHub repository to store your portfolio.

  • Open https://github.com and sign in (create a free account if you do not have one).
  • Click the + icon in the top-right corner and select New repository.
  • Set the repository name to n8n-portfolio.
  • Set the visibility to Public.
  • Check Add a README file.
  • Click Create repository.
  • Inside the repository, click Add file and select Create new file.
  • In the filename field, type 01-research-agent/README.md to create the folder and file simultaneously.
  • In the file editor, write a brief description covering: what the workflow does, the problem it solves (ungoverned AI agents acting without human approval), and a note that a canvas screenshot is included.
  • Click Commit changes.
  • Navigate into the 01-research-agent folder in your repository.
  • Click Add file and select Upload files.
  • Drag in the workflow JSON file you exported from n8n.
  • Click Commit changes.

Finally, add a screenshot of your canvas to the repository.

  • Return to your n8n canvas and press 1 to zoom to fit the entire workflow.
  • Take a screenshot using Cmd+Shift+4 (macOS) or Win+Shift+S (Windows).
  • Back in GitHub, upload the screenshot to the 01-research-agent folder using the same Add file process.
  • Click Commit changes.

What should my repository look like?

Your n8n-portfolio repository should now have a root README and a folder called 01-research-agent containing three files: the workflow JSON, a README.md describing the project, and a screenshot of your canvas.

  • Verify the repository is public by opening it in an incognito browser window. You should see all files without being signed in.

Repository shows as private?

Go to your repository's Settings tab (the gear icon), scroll to the Danger Zone section, and click Change visibility to switch it to Public.

Help me make my GitHub repository public.

Secret mission

Add a Second Tool with Structured Output

Your agent currently uses a single HTTP Request Tool for general research. Real-world AI agents need to choose between multiple specialist tools based on the user's request. In this secret mission, you will add a second tool for competitor analysis and enforce a structured JSON output schema so the agent's responses are consistently formatted.

Clean Up Your Resources

Clean Up Your Resources

Decide whether to keep your resources running, pause them to come back later, or delete them entirely.

This project uses n8n Cloud (free trial), a pay-as-you-go OpenAI API key, and free services (Telegram, Google Sheets, Gmail, GitHub).

Cost warning

After your 14-day n8n Cloud free trial ends, the Starter plan costs 20 EUR/month billed annually. Your OpenAI API key is pay-as-you-go, so any workflow execution that calls the API will incur token costs.

If you are not actively using the workflow, unpublish it (Pause) or delete it and revoke your API key to avoid charges.

Resources you used:

  • n8n Cloud workspace (14-day free trial, no credit card required).
  • OpenAI API key (pay-as-you-go, estimated cost for this project: under $0.50).
  • Telegram Bot (free, created via @BotFather).
  • Google Sheet: "AI Research Log" (free, stored in Google Drive).
  • GitHub repository: n8n-portfolio (free).

Keep everything running

No action needed. Choose this if you are still actively building or plan to continue with the next project in the roadmap.

  • Your workflow stays active on n8n Cloud. It only consumes executions when triggered.
  • Monitor your usage in n8n under Settings > Usage.
  • Your OpenAI API key remains active. Token charges only apply when the workflow runs.
  • Your Telegram Bot, Google Sheet, and GitHub repository remain available at no cost.

Pause - I'll come back to this later

Unpublish the workflow so it stops consuming executions. Your work is preserved and you can re-publish any time.

  • Open your Research Agent workflow in the n8n canvas.
  • Click the dropdown arrow next to the Publish button in the canvas header.
  • Select Unpublish to deactivate the workflow.
  • Repeat for the Error Trigger workflow.
  • No executions will be consumed while the workflows are unpublished.

Delete - I don't want to use this again

Remove all project resources and start fresh. Your GitHub backup remains unless you choose to delete it too.

  • In n8n, open the Command Bar with Cmd+K (macOS) or Ctrl+K (Windows).
  • Type "delete" and select the Delete action for your Research Agent workflow.
  • Repeat the delete action for the Error Trigger workflow.
  • Go to Credentials in n8n. Delete the OpenAI API, Telegram API, Google Sheets, and Gmail credentials.
  • Go to https://platform.openai.com/account/api-keys. Find the key named "n8n-agent", click the delete or revoke option, and confirm.
  • In Telegram, open a chat with @BotFather and send /deletebot. Select your approval bot from the list to permanently delete it.
  • In Google Drive, find the "AI Research Log" spreadsheet, right-click it, and select Move to trash.
  • To delete the GitHub repository, go to your n8n-portfolio repository on GitHub. Click Settings, scroll to the Danger Zone section, and click Delete this repository.

Nice Work!

Nice Work!

You just built a governed AI Research Agent from scratch. Your workflow proves a powerful pattern: an AI agent that researches, summarizes, and delivers results only after explicit human approval.

Here's what you accomplished:

  • Built an AI Agent in n8n with tool-calling capabilities, powered by GPT-4.1 mini and HTTP Request tools that research topics on demand.
  • Implemented a human-in-the-loop approval gate using Telegram, ensuring no agent output reaches your channels without your explicit sign-off.
  • Connected multi-channel outputs (Google Sheets + Gmail) and saved your workflow to GitHub as a portfolio piece for future clients.
  • Secret Mission: Configured multi-tool routing with a Structured Output Parser, proving the agent makes intelligent decisions about which tool to use based on the request.

Ready to quiz yourself?