AutomationFlowsAI & RAG › AI Agent 2

AI Agent 2

AI Agent 2. Uses agent, lmChatOpenAi, toolWikipedia, toolCalculator. Event-driven trigger; 17 nodes.

Event trigger★★★★☆ complexityAI-powered17 nodesAgentLm Chat Open AiTool WikipediaTool CalculatorGoogle Calendar ToolTelegram TriggerTelegramOpen Ai
AI & RAG Trigger: Event Nodes: 17 Complexity: ★★★★☆ AI nodes: yes

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "AI Agent 2",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=You are a highly efficient AI assistant designed to manage calendar events and ensure seamless communication with attendees.\n\nToday\u2019s date: {{ $now }}\nYour primary functions:\n1. Searching, creating, and updating events\n2. Create or update a row in the Google Sheet with the calendar title, description, ID, and length\nSearch First \u2013 Always search for an existing event before creating a new one.\nNo Duplicates \u2013 If an event already exists and needs modifications, update it instead of creating a new one.\nRelative Dates \u2013 Ensure new events are scheduled relative to today\u2019s date.\nConfirmation Output \u2013 Always return a clear response with event details, including a direct link to the calendar event.\nAutomated Google Sheets Notification \u2013 When a new event is created or updated, automatically send a data to the google sheet.\nDo not create new calendar events or new email threads if the user wants to change or update an existing an existing calendar event\nIf there's no time provided for the calendar invite, please assume it's 1 hour in length\nOutput Format:\nIf searching: Display matching events or indicate none were found.\nIf creating: Confirm the event details, provide the calendar link, and trigger an email notification to the attendee.\nIf updating: Confirm the changes made, provide the updated calendar link, and send an update email by replying to the existing email thread.\nStay efficient, accurate, and proactive in communication while avoiding unnecessary event duplication."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        340,
        0
      ],
      "id": "3f801c04-c235-4e0a-a7a7-6a72e6850409",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        160,
        220
      ],
      "id": "1a94838b-81e5-4040-b224-6cf28092d3ee",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "typeVersion": 1,
      "position": [
        420,
        220
      ],
      "id": "51346481-694d-4e09-bf33-784622d2dc3e",
      "name": "Wikipedia"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        540,
        220
      ],
      "id": "075e56e3-883a-42d3-b503-ebb92dd3c5cb",
      "name": "Calculator"
    },
    {
      "parameters": {
        "operation": "getAll",
        "calendar": {
          "__rl": true,
          "value": "e65463fc466fd521dc1ecc1964b4d6dbac77710e2a00f0a73b597f41477d9def@group.calendar.google.com",
          "mode": "list",
          "cachedResultName": "AI Agent"
        },
        "timeMax": "={{ $now.plus({ day: 1 }) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        660,
        220
      ],
      "id": "7aeacf97-0cab-413f-a2cc-e45ab79b6ad6",
      "name": "Google Calendar",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "e65463fc466fd521dc1ecc1964b4d6dbac77710e2a00f0a73b597f41477d9def@group.calendar.google.com",
          "mode": "list",
          "cachedResultName": "AI Agent"
        },
        "start": "={{ $fromAI(\"start\", \"this is the start time of the event\") }}",
        "end": "={{ $fromAI(\"end\", \"This is the end time of the event\") }}",
        "additionalFields": {
          "attendees": [],
          "summary": "={{ $fromAI(\"summary\", \"this is the summary of th eve t\") }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        820,
        220
      ],
      "id": "0e31ab41-46a7-4489-bbf4-ab09e538dedc",
      "name": "Google Calendar1",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        -1200,
        0
      ],
      "id": "2decba19-0388-4f07-ba9e-ce492618b01b",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        700,
        0
      ],
      "id": "c46de7bc-ee8a-4720-b498-613b3278ea89",
      "name": "Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4330c3b5-edd3-403b-a71c-541c45365152",
              "leftValue": "={{ $json.message.voice }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {
          "ignoreCase": true
        }
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -980,
        0
      ],
      "id": "d995acb5-5702-4879-ba9c-53926ce4f580",
      "name": "If"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $('Telegram Trigger').item.json.message.voice.file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -760,
        -100
      ],
      "id": "b9ac0a9b-7e6c-4280-aa26-dfeb0f9a32af",
      "name": "Telegram1",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -560,
        -100
      ],
      "id": "46a02946-3be3-45b3-a35e-e17ddf535d07",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "836f712d-d3a7-43d1-9c9b-811edbb67e15",
              "name": "text",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -340,
        -100
      ],
      "id": "a024afbd-6f1c-48be-914f-d99b9d078d04",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "62c30d8d-8ae7-4194-b1a0-1db781143f25",
              "name": "text",
              "value": "={{ $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -760,
        100
      ],
      "id": "90e227ee-a7c5-44c0-8d0c-f29798b56f57",
      "name": "Edit Fields1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        20,
        0
      ],
      "id": "ac4c8001-c088-4c38-b54f-a9b67c609909",
      "name": "Merge"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        300,
        220
      ],
      "id": "8d4beb7b-4d5c-4c78-a00c-df2576989617",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1r8MFFizLldwJMbbkLnClsP6YqyklRU6vEj-WE3nCmvY",
          "mode": "list",
          "cachedResultName": "Log Events",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1r8MFFizLldwJMbbkLnClsP6YqyklRU6vEj-WE3nCmvY/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1r8MFFizLldwJMbbkLnClsP6YqyklRU6vEj-WE3nCmvY/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $now }}",
            "Title": "={{ $fromAI(\"eventTitle\", \"title of the calendar event\") }}",
            "Description": "={{ $fromAI(\"eventDescription\", \"description of the calendar event\") }}",
            "Length": "={{ $fromAI(\"eventLength\", \"length of the calendar event\") }}",
            "ID": "={{ $fromAI(\"eventID\", \"ID of the calendar event\") }}",
            "Start Time": "={{ $fromAI(\"eventStartTime\", \"start time of the calendar event\") }}",
            "End Time": "={{ $fromAI(\"eventEndTime\", \"end time of the calendar event\") }}"
          },
          "matchingColumns": [
            "ID"
          ],
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Start Time",
              "displayName": "Start Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "End Time",
              "displayName": "End Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Length",
              "displayName": "Length",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "ID",
              "displayName": "ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        1160,
        220
      ],
      "id": "f3fab6a2-feda-46e7-a987-82287662c098",
      "name": "Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "calendar": {
          "__rl": true,
          "value": "e65463fc466fd521dc1ecc1964b4d6dbac77710e2a00f0a73b597f41477d9def@group.calendar.google.com",
          "mode": "list",
          "cachedResultName": "AI Agent"
        },
        "eventId": "={{ $fromAI(\"eventID\", \"ID of event\") }}",
        "updateFields": {
          "end": "={{ $fromAI(\"endTime\", \"end time of event\") }}",
          "start": "={{ $fromAI(\"startTime\", \"start time of event\") }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        1000,
        220
      ],
      "id": "b6ae7b9b-26e2-4e34-9a49-c8fac6a3b5af",
      "name": "Google Calendar2",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wikipedia": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram1": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar2": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d317b89d-c752-49c5-8271-083413b9d71a",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "oPdwNb3juYcAZIe5",
  "tags": []
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

About this workflow

AI Agent 2. Uses agent, lmChatOpenAi, toolWikipedia, toolCalculator. Event-driven trigger; 17 nodes.

Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →