free_workflows / Agent Swarm.json
LouisAlexis's picture
Upload Agent Swarm.json
b75f55f verified
{
"name": "Agent Swarm",
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"id": "d159b470-a761-4212-81f7-e5620a4b70ad",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.1,
"position": [
-784,
32
],
"webhookId": "99eab1a0-569d-4f0f-a49e-578a02abfe63",
"credentials": {
"telegramApi": {
"id": "9jQWan3cOz3tE62s",
"name": "Telegram account 2"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "fe7ecc99-e1e8-4a5e-bdd6-6fce9757b234",
"name": "text",
"value": "={{ $json.message.text }}",
"type": "string"
}
]
},
"options": {}
},
"id": "4df0d4ce-4702-438f-a55d-e5d0f7a597b9",
"name": "Set 'Text'",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-400,
48
]
},
{
"parameters": {
"resource": "file",
"fileId": "={{ $json.message.voice.file_id }}"
},
"id": "8cb45750-a44f-4d85-a3bc-e7c68183a21a",
"name": "Download Voice File",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
-464,
-128
],
"webhookId": "c0b376b1-7b63-41b6-8063-0b3096b8333d",
"credentials": {
"telegramApi": {
"id": "9jQWan3cOz3tE62s",
"name": "Telegram account 2"
}
}
},
{
"parameters": {
"resource": "audio",
"operation": "transcribe",
"options": {}
},
"id": "2a5e779c-0df0-420a-9809-fe699e89a581",
"name": "Transcribe Audio",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.6,
"position": [
-304,
-128
],
"credentials": {
"openAiApi": {
"id": "WnxUhaEPMn5hIsEp",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"leftValue": "={{ $json.message.voice.file_id }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Voice"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "8c844924-b2ed-48b0-935c-c66a8fd0c778",
"leftValue": "={{ $json.message.text }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Text"
}
]
},
"options": {}
},
"id": "c6870141-ff59-4023-9edd-bea8dc2f4db1",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-640,
32
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.input }}",
"options": {
"systemMessage": "=# Overview\nYou are the ultimate personal assistant. Your job is to send the user's query to the correct tool. You should never be writing emails or creating summaries — your sole responsibility is to call the correct tool.\n\n## Tools\n- **Think**: Use this to think deeply or if you get stuck\n- **emailAgent**: Use this tool to take action in email\n- **calendarAgent**: Use this tool to take action in calendar\n- **contactAgent**: Use this tool to get, update, or add contacts\n- **contentCreator**: Use this tool to create blog posts\n- **webAgent**: Use this tool to perform deeper web research or get current weather info\n- **youtubeAgent**: Use this tool to find high-performing videos or manage video ideas\n\n## Rules\n- Some actions require you to look up contact information first. For the following actions, you must get contact information and send that to the agent who needs it:\n - sending emails\n - drafting emails\n - creating calendar event with attendee\n\n## Instructions\n1) Call the necessary tools based on the user's request\n2) Use the **Think** tool to verify you took the right steps. This tool should be called every time.\n\n## Examples\n1) \n- Input: send an email to nate herkelman asking him what time he wants to leave \n - Action: Use **contactAgent** to get Nate Herkelman's email \n - Action: Use **emailAgent** to send the email. You will pass the tool a query like: \n \"send Nate Herkelman an email to ask what time he wants to leave. here is his email: [email address]\"\n- Output: The email has been sent to Nate Herkelman. Anything else I can help you with?\n\n## Final Reminders\nHere is the current date/time: {{ $now }}\n",
"returnIntermediateSteps": true
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2.1,
"position": [
32,
32
],
"id": "c0b2f900-a968-4771-a44a-f60e2c86de8b",
"name": "AI Agent",
"onError": "continueErrorOutput"
},
{
"parameters": {
"sendTo": "={{ $fromAI(\"emailAddress\") }}",
"subject": "={{ $fromAI(\"subject\") }}",
"message": "={{ $fromAI(\"emailBody\") }}",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-128,
592
],
"id": "8f4459e1-fe08-44c0-9e3f-184492975ed5",
"name": "Send Email",
"webhookId": "86c8c4b1-13bb-4ebe-acb9-30e1d7082d55",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"operation": "getAll",
"limit": "={{ $fromAI(\"limit\",\"how many emails the user wants\") }}",
"simple": false,
"filters": {
"sender": "={{ $fromAI(\"sender\",\"who the emails are from\") }}"
},
"options": {}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-512,
592
],
"id": "6e3b3131-b9bc-4aac-82ed-cd25a2be96d1",
"name": "Get Emails",
"webhookId": "af4b3298-9037-44b0-aa12-2acbfbb5e66f",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"resource": "draft",
"subject": "={{ $fromAI(\"subject\") }}",
"emailType": "html",
"message": "={{ $fromAI(\"emailBody\") }}",
"options": {
"threadId": "={{ $fromAI(\"threadID\") }}",
"sendTo": "={{ $fromAI(\"emailAddress\") }}"
}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-128,
448
],
"id": "28aba68c-a827-4016-bcba-6131e5e8605c",
"name": "Create Draft",
"webhookId": "17016bce-d7d7-428a-a56c-f6ea122db8be",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"operation": "reply",
"messageId": "={{ $fromAI(\"ID\",\"the message ID\") }}",
"message": "={{ $fromAI(\"emailBody\") }}",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-384,
448
],
"id": "a45b702d-84cd-4c3e-a2ea-d7a3391b4213",
"name": "Email Reply",
"webhookId": "114785e6-a859-432b-81b4-c490c1c35b1c",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"resource": "label",
"returnAll": true
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-384,
592
],
"id": "e014918c-0790-48e7-9e00-4e1e74187093",
"name": "Get Labels",
"webhookId": "9e08b59e-792d-4566-83f1-9263c9ad86ae",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $fromAI(\"ID\",\"the ID of the message\") }}",
"labelIds": "={{ $fromAI(\"labelID\") }}"
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-256,
448
],
"id": "f4cec2b0-d0b3-4caa-8004-438c27437ad7",
"name": "Label Emails",
"webhookId": "0e951529-2e6d-40bf-ac40-fc0947e242e2",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"operation": "markAsUnread",
"messageId": "={{ $fromAI(\"messageID\") }}"
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-256,
592
],
"id": "2cd2e2d3-53f8-47f4-ac7e-455f9f668897",
"name": "Mark Unread",
"webhookId": "a35af9d8-f67d-4ff9-803f-59ec6356e795",
"credentials": {
"gmailOAuth2": {
"id": "KY7391f1ZHRL52Nu",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"toolDescription": "An email agent for all email actions",
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
"options": {
"systemMessage": "=# Overview\nYou are an email management assistant. All emails must be formatted professionally in HTML and signed off as \"Nate.\" \n\n**Email Management Tools** \n - Use \"Send Email\" to send emails. \n - Use \"Create Draft\" if the user asks for a draft. \n - Use \"Get Emails\" to retrieve emails when requested.\n - Use \"Get Labels\" to retrieve labels.\n - Use \"Mark Unread\" to mark an email as unread. You must use \"Get Emails\" first so you have the message ID of the email to flag.\n - Use \"Label Email\" to flag an email. You must use \"Get Emails\" first so you have the message ID of the email to flag. Then you must use \"Get Labels\" so you have the label ID.\n - Use \"Email Reply\" to reply to an email. You must use \"Get Emails\" first so you have the message ID of the email to reply to.\n\n## Final Notes\n- Here is the current date/time: {{ $now }}"
}
},
"type": "@n8n/n8n-nodes-langchain.agentTool",
"typeVersion": 2.2,
"position": [
-320,
272
],
"id": "e2c22d68-04bc-4873-8144-5c54fe542f0f",
"name": "Email Agent"
},
{
"parameters": {
"calendar": {
"__rl": true,
"value": "nateherk88@gmail.com",
"mode": "list",
"cachedResultName": "nateherk88@gmail.com"
},
"start": "={{ $fromAI(\"eventStart\") }}",
"end": "={{ $fromAI(\"eventEnd\") }}",
"additionalFields": {
"attendees": [
"={{ $fromAI(\"eventAttendeeEmail\") }}"
],
"summary": "={{ $fromAI(\"eventTitle\") }}"
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
272,
592
],
"id": "0db404c6-ad6d-4c87-9c87-4ad6e9812620",
"name": "Create Event with Attendee",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "HYMNtkm0oglf42QP",
"name": "Google Calendar account"
}
}
},
{
"parameters": {
"calendar": {
"__rl": true,
"value": "nateherk88@gmail.com",
"mode": "list",
"cachedResultName": "nateherk88@gmail.com"
},
"start": "={{ $fromAI(\"eventStart\") }}",
"end": "={{ $fromAI(\"eventEnd\") }}",
"additionalFields": {
"attendees": [],
"summary": "={{ $fromAI(\"eventTitle\") }}"
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
16,
592
],
"id": "8ccf4ec0-b4a3-4bb4-b5cc-4316c1b4264e",
"name": "Create Event",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "HYMNtkm0oglf42QP",
"name": "Google Calendar account"
}
}
},
{
"parameters": {
"operation": "getAll",
"calendar": {
"__rl": true,
"value": "nateherk88@gmail.com",
"mode": "list",
"cachedResultName": "nateherk88@gmail.com"
},
"timeMin": "={{ $fromAI(\"dayBefore\",\"the day before the date the user requested\") }}",
"timeMax": "={{ $fromAI(\"dayAfter\",\"the day after the date the user requested\") }}",
"options": {}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
272,
448
],
"id": "329ad6fe-5391-46a6-bc34-657f7a331c01",
"name": "Get Events",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "HYMNtkm0oglf42QP",
"name": "Google Calendar account"
}
}
},
{
"parameters": {
"operation": "delete",
"calendar": {
"__rl": true,
"value": "nateherk88@gmail.com",
"mode": "list",
"cachedResultName": "nateherk88@gmail.com"
},
"eventId": "={{ $fromAI(\"eventID\") }}",
"options": {}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
144,
448
],
"id": "9344ea9a-682e-491b-a0ff-aa98d918260d",
"name": "Delete Event",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "HYMNtkm0oglf42QP",
"name": "Google Calendar account"
}
}
},
{
"parameters": {
"operation": "update",
"calendar": {
"__rl": true,
"value": "nateherk88@gmail.com",
"mode": "list",
"cachedResultName": "nateherk88@gmail.com"
},
"eventId": "={{ $fromAI(\"eventID\") }}",
"updateFields": {
"end": "={{ $fromAI(\"endTime\") }}",
"start": "={{ $fromAI(\"startTime\") }}"
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
144,
592
],
"id": "c85de60d-c0fd-4bbe-a600-a7bd8e5258ed",
"name": "Update Event",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "HYMNtkm0oglf42QP",
"name": "Google Calendar account"
}
}
},
{
"parameters": {
"toolDescription": "A calendar agent for all calendar actions",
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
"options": {
"systemMessage": "=# Overview\nYou are a calendar assistant. Your responsibilities include creating, getting, and deleting events in the user's calendar.\n\n**Calendar Management Tools** \n - Use \"Create Event with Attendee\" when an event includes a participant. \n - Use \"Create Event\" for solo events. \n - Use \"Get Events\" to fetch calendar schedules when requested.\n - Use \"Delete Event\" to delete an event. You must use \"Get Events\" first to get the ID of the event to delete.\n - Use \"Update Event\" to update an event. You must use \"Get Events\" first to get the ID of the event to update.\n\n## Final Notes\nHere is the current date/time: {{ $now }}\nIf a duration for an event isn't specified, assume it will be one hour."
}
},
"type": "@n8n/n8n-nodes-langchain.agentTool",
"typeVersion": 2.2,
"position": [
32,
272
],
"id": "f003a78c-4241-44ce-a2e2-d16dbcf96d0f",
"name": "Calendar Agent"
},
{
"parameters": {
"operation": "search",
"base": {
"__rl": true,
"value": "appK0rbtvf9e7vt6w",
"mode": "list",
"cachedResultName": "Contacts",
"cachedResultUrl": "https://airtable.com/appK0rbtvf9e7vt6w"
},
"table": {
"__rl": true,
"value": "tbl08JGCfUK1RhXsG",
"mode": "list",
"cachedResultName": "Contacts",
"cachedResultUrl": "https://airtable.com/appK0rbtvf9e7vt6w/tbl08JGCfUK1RhXsG"
},
"options": {}
},
"type": "n8n-nodes-base.airtableTool",
"typeVersion": 2.1,
"position": [
512,
432
],
"id": "20868164-0e88-412e-9808-03d702aff18b",
"name": "Get Contacts",
"credentials": {
"airtableTokenApi": {
"id": "UlAGE0msyITVkoCN",
"name": "Nate Airtable"
}
}
},
{
"parameters": {
"operation": "upsert",
"base": {
"__rl": true,
"value": "appK0rbtvf9e7vt6w",
"mode": "list",
"cachedResultName": "Contacts",
"cachedResultUrl": "https://airtable.com/appK0rbtvf9e7vt6w"
},
"table": {
"__rl": true,
"value": "tbl08JGCfUK1RhXsG",
"mode": "list",
"cachedResultName": "Contacts",
"cachedResultUrl": "https://airtable.com/appK0rbtvf9e7vt6w/tbl08JGCfUK1RhXsG"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"name": "={{ $fromAI(\"name\") }}",
"email": "={{ $fromAI(\"emailAddress\") }}",
"phoneNumber": "={{ $fromAI(\"phoneNumber\") }}"
},
"matchingColumns": [
"name"
],
"schema": [
{
"id": "name",
"displayName": "name",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "email",
"displayName": "email",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "phoneNumber",
"displayName": "phoneNumber",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.airtableTool",
"typeVersion": 2.1,
"position": [
624,
432
],
"id": "5efe9b78-8125-4735-8228-2cac814199ba",
"name": "Add or Update Contact",
"credentials": {
"airtableTokenApi": {
"id": "UlAGE0msyITVkoCN",
"name": "Nate Airtable"
}
}
},
{
"parameters": {
"toolDescription": "Contact agent for all contact actions, like getting contacts",
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
"options": {
"systemMessage": "=# Overview\nYou are a contact management assistant. Your responsibilities include looking up contacts, adding new contacts, or updating a contact's information.\n\n**Contact Management** \n - Use \"Get Contacts\" to retrieve contact information. \n - Use \"Add or Update Contact\" to store new contact information or modify existing entries. "
}
},
"type": "@n8n/n8n-nodes-langchain.agentTool",
"typeVersion": 2.2,
"position": [
384,
272
],
"id": "41d0303b-4e45-4fdf-bc59-25f5529ae72c",
"name": "Contact Agent"
},
{
"parameters": {
"query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Query', ``, 'string') }}",
"options": {}
},
"type": "@tavily/n8n-nodes-tavily.tavilyTool",
"typeVersion": 1,
"position": [
624,
752
],
"id": "9d6f4470-5802-4c68-b07e-cedb991b7901",
"name": "Tavily",
"credentials": {
"tavilyApi": {
"id": "LEjQvwuyOKYvoBIn",
"name": "Tavily account"
}
}
},
{
"parameters": {
"model": "sonar",
"messages": {
"message": [
{
"content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('message0_Text', ``, 'string') }}"
}
]
},
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.perplexityTool",
"typeVersion": 1,
"position": [
736,
752
],
"id": "979b0bfc-30b8-47e7-9d6c-0003a23f7de1",
"name": "Perplexity",
"credentials": {
"perplexityApi": {
"id": "5djL3YQiuN26EJiA",
"name": "Perplexity account"
}
}
},
{
"parameters": {
"format": "imperial",
"cityName": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('City', ``, 'string') }}",
"language": "en"
},
"type": "n8n-nodes-base.openWeatherMapTool",
"typeVersion": 1,
"position": [
848,
752
],
"id": "9e678c45-81ca-46c2-9cb3-d945b0510864",
"name": "OpenWeatherMap",
"credentials": {
"openWeatherMapApi": {
"id": "AoobPcMhq7n8fgfA",
"name": "OpenWeatherMap account 2"
}
}
},
{
"parameters": {
"toolDescription": "A research agent for all research actions",
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
"options": {
"systemMessage": "=# Overview\nYou are a web research assistant. Your responsibilities include conducting quick web searches, performing deeper research, and retrieving current weather information. \n\n**Web Search & Research** \n - Use **Tavily** for quick factual lookups, recent news, or verifying specific pieces of information. \n - Use **Perplexity** when a question requires deeper research, multiple perspectives, or synthesized answers from various sources. \n\n**Weather Information** \n - Use **Open Weather Map** to retrieve current weather data, including temperature, conditions, and forecasts for a given location.\n\nAlways explain your reasoning briefly when choosing between Tavily and Perplexity. Prioritize clarity, credibility, and helpfulness in your responses.\n"
}
},
"type": "@n8n/n8n-nodes-langchain.agentTool",
"typeVersion": 2.2,
"position": [
496,
592
],
"id": "7861e79b-ce62-4671-81ca-dfd1e487afff",
"name": "Web Agent"
},
{
"parameters": {
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
"options": {
"systemMessage": "=# Overview\nYou are a YouTube content assistant. Your responsibilities include researching high-performing YouTube videos, retrieving existing video ideas, and adding new content ideas to the video database. Your goal is to support content strategy and ideation with relevant, high-quality inputs.\n\n**Video Idea Management** \n - Use **Get Ideas** to retrieve existing YouTube video ideas from the internal database. \n - Use **Add Idea** to contribute new video ideas to the database for future content planning.\n\n**Content Research** \n - Use **YouTube Videos** to search for high-performing videos on a given topic. Analyze trends, titles, formats, and engagement to inspire new content strategies.\n\nWhen suggesting or adding an idea, be specific, creative, and align your suggestions with proven YouTube best practices.\n"
}
},
"type": "@n8n/n8n-nodes-langchain.agentTool",
"typeVersion": 2.2,
"position": [
752,
272
],
"id": "ed69b961-64b8-4173-b37d-ca981aca70b3",
"name": "YouTube Agent"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
-720,
272
],
"id": "1cde38b9-d9f7-4157-ac3c-08afba6410f2",
"name": "GPT 4.1-mini",
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
-512,
448
],
"id": "2e1de035-ab0a-4979-8acb-423aab43286c",
"name": "GPT 4.1-mini1",
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
16,
448
],
"id": "418d1d71-9e88-48d5-965f-595a4a3476c4",
"name": "GPT 4.1-mini2",
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
384,
432
],
"id": "4fe79fd7-c3b2-4ddf-bcdd-041884a0161b",
"name": "GPT 4.1-mini3",
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
512,
752
],
"id": "d9da1ca7-aee5-43f0-8a7c-6ea5ef96f129",
"name": "GPT 4.1-mini4",
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
}
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"typeVersion": 1,
"position": [
752,
432
],
"id": "9bb9fef9-062b-4444-9db3-9c73e113688a",
"name": "GPT 4.1-mini5",
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
}
},
{
"parameters": {
"jsCode": "// Initialize the output arrays\nconst steps = [];\nconst tokens = [];\nlet totalTokens = 0; // Changed to track total tokens instead of cost\n\n// Process each item in the input\nfor (const item of $input.all()) {\n let data = item.json;\n \n // Check if the data is an array itself (like your example JSON)\n if (Array.isArray(data)) {\n // Process each object in the array\n for (const obj of data) {\n // Extract steps information\n if (obj.intermediateSteps && Array.isArray(obj.intermediateSteps)) {\n for (const step of obj.intermediateSteps) {\n if (step.action) {\n steps.push({\n tool: step.action.tool,\n toolInput: step.action.toolInput,\n observation: step.observation\n });\n }\n }\n }\n \n // Extract token information\n if (obj.intermediateSteps && Array.isArray(obj.intermediateSteps)) {\n for (const step of obj.intermediateSteps) {\n if (step.action && step.action.messageLog && Array.isArray(step.action.messageLog)) {\n for (const message of step.action.messageLog) {\n if (message.kwargs && message.kwargs.response_metadata && message.kwargs.response_metadata.usage) {\n const usage = message.kwargs.response_metadata.usage;\n tokens.push({\n prompt_tokens: usage.prompt_tokens,\n completion_tokens: usage.completion_tokens,\n total_tokens: usage.total_tokens,\n model_name: message.kwargs.response_metadata.model_name\n });\n \n // Add the tokens to our running total\n if (typeof usage.total_tokens === 'number') {\n totalTokens += usage.total_tokens;\n }\n }\n }\n }\n }\n }\n }\n } else {\n // If data is not an array, process it as a single object\n // Extract steps information\n if (data.intermediateSteps && Array.isArray(data.intermediateSteps)) {\n for (const step of data.intermediateSteps) {\n if (step.action) {\n steps.push({\n tool: step.action.tool,\n toolInput: step.action.toolInput,\n observation: step.observation\n });\n }\n }\n }\n \n // Extract token information\n if (data.intermediateSteps && Array.isArray(data.intermediateSteps)) {\n for (const step of data.intermediateSteps) {\n if (step.action && step.action.messageLog && Array.isArray(step.action.messageLog)) {\n for (const message of step.action.messageLog) {\n if (message.kwargs && message.kwargs.response_metadata && message.kwargs.response_metadata.usage) {\n const usage = message.kwargs.response_metadata.usage;\n tokens.push({\n prompt_tokens: usage.prompt_tokens,\n completion_tokens: usage.completion_tokens,\n total_tokens: usage.total_tokens,\n model_name: message.kwargs.response_metadata.model_name\n });\n \n // Add the tokens to our running total\n if (typeof usage.total_tokens === 'number') {\n totalTokens += usage.total_tokens;\n }\n }\n }\n }\n }\n }\n }\n}\n\n// Return the processed data with total_tokens included\nreturn [{\n json: {\n steps: steps,\n tokens: tokens,\n total_tokens: totalTokens\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
400,
-128
],
"id": "63853af6-7842-4e4e-abe4-2ca3324dd2d8",
"name": "Clean Up"
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "144h5vN3d_SsZMNkZncQAKMrwJ3wkceUEq47dO7FwLyA",
"mode": "list",
"cachedResultName": "Agent Logs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/144h5vN3d_SsZMNkZncQAKMrwJ3wkceUEq47dO7FwLyA/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/144h5vN3d_SsZMNkZncQAKMrwJ3wkceUEq47dO7FwLyA/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Timestamp": "={{ $now.format('yyyy-MM-dd hh:m a') }}",
"Workflow": "={{ $workflow.name }}",
"Input": "={{ $('Input').item.json.input }}",
"Output": "={{ $('AI Agent').item.json.output }}",
"Actions": "={{ JSON.stringify($json.steps, null, 2) }}",
"Tokens": "={{ JSON.stringify($json.tokens, null, 2) }}",
"Total Tokens": "={{ $json.total_tokens }}"
},
"matchingColumns": [],
"schema": [
{
"id": "Timestamp",
"displayName": "Timestamp",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Workflow",
"displayName": "Workflow",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Input",
"displayName": "Input",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Output",
"displayName": "Output",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Actions",
"displayName": "Actions",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Tokens",
"displayName": "Tokens",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Total Tokens",
"displayName": "Total Tokens",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
544,
-128
],
"id": "a04febdb-3ab6-4d0d-839e-41302e6a45a1",
"name": "Append row in sheet",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "s7PIUa59FFmDLn1e",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"documentId": {
"__rl": true,
"value": "15CpqbdciFb023LElHxiDQ-CSfbXg-Gk6g5A7Dl_b8Ls",
"mode": "list",
"cachedResultName": "Video Ideas",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/15CpqbdciFb023LElHxiDQ-CSfbXg-Gk6g5A7Dl_b8Ls/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Ideas",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/15CpqbdciFb023LElHxiDQ-CSfbXg-Gk6g5A7Dl_b8Ls/edit#gid=0"
},
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.6,
"position": [
976,
432
],
"id": "c74716af-0859-4611-ac9f-e3408787bad9",
"name": "Get Ideas",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "s7PIUa59FFmDLn1e",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "15CpqbdciFb023LElHxiDQ-CSfbXg-Gk6g5A7Dl_b8Ls",
"mode": "list",
"cachedResultName": "Video Ideas",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/15CpqbdciFb023LElHxiDQ-CSfbXg-Gk6g5A7Dl_b8Ls/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Ideas",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/15CpqbdciFb023LElHxiDQ-CSfbXg-Gk6g5A7Dl_b8Ls/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Idea": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Idea', `Idea title`, 'string') }}",
"Description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', `Idea description`, 'string') }}"
},
"matchingColumns": [],
"schema": [
{
"id": "Idea",
"displayName": "Idea",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Description",
"displayName": "Description",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.6,
"position": [
1088,
432
],
"id": "512d1138-ac85-437f-aea4-775e037d70bf",
"name": "Add Idea",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "s7PIUa59FFmDLn1e",
"name": "Demo 4/2"
}
}
},
{
"parameters": {
"toolDescription": "Use this tool to find high-performing YouTube videos",
"method": "POST",
"url": "https://api.apify.com/v2/acts/streamers~youtube-scraper/run-sync-get-dataset-items",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "token",
"value": "YOUR APIFY API KEY"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"dateFilter\": \"month\",\n \"downloadSubtitles\": false,\n \"hasCC\": false,\n \"hasLocation\": false,\n \"hasSubtitles\": false,\n \"is360\": false,\n \"is3D\": false,\n \"is4K\": false,\n \"isBought\": false,\n \"isHD\": false,\n \"isHDR\": false,\n \"isLive\": false,\n \"isVR180\": false,\n \"maxResultStreams\": 0,\n \"maxResults\": {{$fromAI(\"maxResults\",\"how many videos the user wants, if not specified, default to 3\",\"number\",3)}},\n \"maxResultsShorts\": 0,\n \"oldestPostDate\": \"6 months\",\n \"preferAutoGeneratedSubtitles\": false,\n \"saveSubsToKVS\": false,\n \"searchQueries\": [\n \"{{$fromAI(\"searchTerm\",\"The topic of the video to search for\")}}\"\n ],\n \"sortVideosBy\": \"POPULAR\",\n \"sortingOrder\": \"views\"\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequestTool",
"typeVersion": 4.2,
"position": [
864,
432
],
"id": "711ff26b-12f5-4bce-8b2c-38404e240c73",
"name": "YouTube Videos"
},
{
"parameters": {},
"type": "@n8n/n8n-nodes-langchain.toolThink",
"typeVersion": 1,
"position": [
-608,
272
],
"id": "82df1709-f6c5-494a-82d3-1736c8fa2866",
"name": "Think"
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
-480,
272
],
"id": "6aac22a1-fc25-4a1c-bf36-97bed47aa766",
"name": "Simple Memory"
},
{
"parameters": {
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"text": "={{ $json.error }}",
"additionalFields": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
400,
32
],
"id": "73e21514-aead-4097-ba1f-edca396b6599",
"name": "Error Message",
"webhookId": "7065a160-b927-43b6-b327-feec46cc0088",
"credentials": {
"telegramApi": {
"id": "9jQWan3cOz3tE62s",
"name": "Telegram account 2"
}
}
},
{
"parameters": {
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"text": "={{ $('AI Agent').item.json.output }}",
"additionalFields": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
688,
-128
],
"id": "3619a814-7347-42c9-b9f0-1fe99230681f",
"name": "Response",
"webhookId": "4d174459-d5cc-4297-a449-369d3f10ef23",
"credentials": {
"telegramApi": {
"id": "9jQWan3cOz3tE62s",
"name": "Telegram account 2"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "976cf2c9-01b6-46cf-97b4-675a67ca57bc",
"name": "input",
"value": "={{ $json.text }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-128,
32
],
"id": "ca521c58-31b2-4ebb-91b0-32cb3be30303",
"name": "Input"
},
{
"parameters": {
"content": "# ⚙️ Setup Guide \n**Author:** [Nate Herk](https://www.youtube.com/@nateherk)\n\nFollow these steps to get your n8n AI agent workflow fully configured and connected:\n\n### ✅ Step 1: Connect Your Telegram Account \nUse the **Telegram Trigger** node to link your Telegram account. This allows you to interact with your agent via Telegram. Make sure it's fully connected—it’s used in both the **Telegram Response** nodes and the **Simple Memory** node.\n\n### ✅ Step 2: Add Your [OpenRouter](https://openrouter.ai/) API Key \nThis is the \"brain\" of your AI agent. Plug in your API key using the **HTTP Request** or **Credential** node to power intelligent responses.\n\n### ✅ Step 3: Connect Your App Integrations \nSet up the following API connections so your agent can take meaningful actions:\n- **Gmail**\n- **Google Calendar**\n- **Airtable**\n- **Google Sheets**\n- **Apify** – Used in the YouTube video node. \n 💡 *Use code* **`30NATEHERK`** *for 30% off your first 3 months at [Apify](https://www.apify.com/?fpr=nate)*\n\n### ✅ Step 4: Connect Research & Utility APIs \nAdd these keys for more powerful features:\n- [**Tavily API Key**](https://www.tavily.com/)\n- [**Perplexity API Key**](https://www.perplexity.ai/)\n- [**Open Weather Map API Key**](https://openweathermap.org/api)\n\n### ✅ Step 5: Link Your Google Sheets Templates \n- 📄 [Agent Action Log Sheet](https://docs.google.com/spreadsheets/d/1PlRVi9Iv2n11SPYdshjhPGWccRCpKLHn3PjUkJEjgAQ/edit?usp=sharing) – Logs the agent’s actions.\n- 🎬 [YouTube Ideas Sheet](https://docs.google.com/spreadsheets/d/1Jazczp5HtPwcJvu6bmJQrjkqt31S7adVqIFVCqXZwGk/edit?usp=sharing) – Used for the YouTube agent’s video ideas.\n\n### 🚀 Final Step: Start Prompting \nWith everything connected, start chatting with your agent on Telegram and watch it take intelligent action across your tool stack!\n",
"height": 912,
"width": 784
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-1696,
-160
],
"id": "95e569c1-9095-4bf9-b5c9-9e9cdd0b6202",
"name": "Sticky Note"
}
],
"pinData": {},
"connections": {
"Telegram Trigger": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Download Voice File": {
"main": [
[
{
"node": "Transcribe Audio",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Download Voice File",
"type": "main",
"index": 0
}
],
[
{
"node": "Set 'Text'",
"type": "main",
"index": 0
}
]
]
},
"Set 'Text'": {
"main": [
[
{
"node": "Input",
"type": "main",
"index": 0
}
]
]
},
"Transcribe Audio": {
"main": [
[
{
"node": "Input",
"type": "main",
"index": 0
}
]
]
},
"Send Email": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get Emails": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Create Draft": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Email Reply": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get Labels": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Label Emails": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Mark Unread": {
"ai_tool": [
[
{
"node": "Email Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Email Agent": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Create Event with Attendee": {
"ai_tool": [
[
{
"node": "Calendar Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Create Event": {
"ai_tool": [
[
{
"node": "Calendar Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get Events": {
"ai_tool": [
[
{
"node": "Calendar Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Delete Event": {
"ai_tool": [
[
{
"node": "Calendar Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Update Event": {
"ai_tool": [
[
{
"node": "Calendar Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Calendar Agent": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get Contacts": {
"ai_tool": [
[
{
"node": "Contact Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Add or Update Contact": {
"ai_tool": [
[
{
"node": "Contact Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Contact Agent": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Tavily": {
"ai_tool": [
[
{
"node": "Web Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Perplexity": {
"ai_tool": [
[
{
"node": "Web Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenWeatherMap": {
"ai_tool": [
[
{
"node": "Web Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Web Agent": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"YouTube Agent": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"GPT 4.1-mini": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"GPT 4.1-mini1": {
"ai_languageModel": [
[
{
"node": "Email Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"GPT 4.1-mini2": {
"ai_languageModel": [
[
{
"node": "Calendar Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"GPT 4.1-mini3": {
"ai_languageModel": [
[
{
"node": "Contact Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"GPT 4.1-mini4": {
"ai_languageModel": [
[
{
"node": "Web Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"GPT 4.1-mini5": {
"ai_languageModel": [
[
{
"node": "YouTube Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Clean Up",
"type": "main",
"index": 0
}
],
[
{
"node": "Error Message",
"type": "main",
"index": 0
}
]
]
},
"Clean Up": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Append row in sheet": {
"main": [
[
{
"node": "Response",
"type": "main",
"index": 0
}
]
]
},
"Get Ideas": {
"ai_tool": [
[
{
"node": "YouTube Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Add Idea": {
"ai_tool": [
[
{
"node": "YouTube Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"YouTube Videos": {
"ai_tool": [
[
{
"node": "YouTube Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Think": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Input": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "4b3d4355-2bbf-4539-bde0-de77cdfb18c6",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "95e5a8c2e51c83e33b232ea792bbe3f063c094c33d9806a5565cb31759e1ad39"
},
"id": "Mfd52rCSFqRe9E2o",
"tags": []
}