{
  "name": "Beginner AI Agent",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=You are a helpful assistant.nnBefore creating events or sending emails, get contact information from the “Get Contact” tool.nnSign off on emails with the name "Duncan"nnThe current date/time is: {{ $now.format('EEEE, yyyy-MM-dd') }}nnAlways send emails to anyone attending a meeting letting them know it has been scheduled and include the meeting details and meeting link.nnAlways embed meeting links in plain text using HTMLn"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        600,
        -80
      ],
      "id": "e4e4fe53-236b-4db0-a8b1-5c627e5061ef",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        260,
        320
      ],
      "id": "e98e17cd-1746-4e37-9782-95f20bb4cde8",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "T48ghmUDQ7z0HSKB",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.from.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        420,
        300
      ],
      "id": "f87f7d3b-4b6a-4426-85c7-41a3c8f636c6",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Consume the Gmail API. Send and draft emails. ",
        "resource": "draft",
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To_Email', ``, 'string') }}"
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        540,
        300
      ],
      "id": "e368755b-75e6-4173-a1e2-5d2c415ea4fc",
      "name": "Gmail",
      "webhookId": "f15c17d7-7f9f-4995-9e4a-dbee0c103a17",
      "credentials": {
        "gmailOAuth2": {
          "id": "DMOkv26zA3q06Dlv",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Call this tool to get the first and last names, and email addresses of contacts. The Input is a person's name. Output is a person's name and email address.",
        "documentId": {
          "__rl": true,
          "value": "1PqWVPtuapi8flUVuAAEexodXLY7GLIr-kpVl1CflMYk",
          "mode": "list",
          "cachedResultName": "Contact List",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PqWVPtuapi8flUVuAAEexodXLY7GLIr-kpVl1CflMYk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PqWVPtuapi8flUVuAAEexodXLY7GLIr-kpVl1CflMYk/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        680,
        280
      ],
      "id": "408e6c82-3078-4ca8-a606-75eeba02e38d",
      "name": "Get Contact",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "VftE0eOzfWVcNhgX",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "duncanrogoff@gmail.com",
          "mode": "list",
          "cachedResultName": "duncanrogoff@gmail.com"
        },
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "additionalFields": {
          "attendees": [
            "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Attendees', ``, 'string') }}"
          ],
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        820,
        260
      ],
      "id": "18177d48-4ebd-4c9c-855d-a3d7dab665e4",
      "name": "Google Calendar",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "2GWOyLUYEmtUyl2l",
          "name": "Google Calendar account"
        }
      }
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        -500,
        0
      ],
      "id": "39a0f422-a746-44e9-8193-c668eea91271",
      "name": "Telegram Trigger",
      "webhookId": "83fb1b5c-8bf3-4bdb-8f5f-c60e5a371aac",
      "credentials": {
        "telegramApi": {
          "id": "oVHqtToSEiGhAGLA",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2a4fbfc0-7fc5-484a-89a6-cb4534002880",
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Audio"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -280,
        0
      ],
      "id": "2c98654b-3f1d-446c-be93-16cd145e243d",
      "name": "Switch"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ece7537b-5f82-4d84-8ccf-dfa44e522673",
              "name": "message.text",
              "value": "={{ $('Telegram Trigger').item.json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        60,
        -120
      ],
      "id": "3eedb552-0753-4c11-8d65-ae4d13b0e8f7",
      "name": "storeText"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $('Telegram Trigger').item.json.message.voice.file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -100,
        80
      ],
      "id": "7579912e-f725-4153-b7bb-749053781169",
      "name": "Telegram",
      "webhookId": "09641b78-d218-4b2b-9e3a-f41643a5ec66",
      "credentials": {
        "telegramApi": {
          "id": "oVHqtToSEiGhAGLA",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        60,
        80
      ],
      "id": "c1f8b0d0-632a-48ad-a809-63183b7b0ef4",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "T48ghmUDQ7z0HSKB",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        320,
        -80
      ],
      "id": "a110e898-5a06-472c-b7d2-92ac19171971",
      "name": "Merge"
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Contact": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "storeText",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "storeText": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cc60fb6e-382e-46de-894e-327594d71a31",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ca3f3f1b54754cc6a8bf7018ef2c4b3d517f36ec4d32b4741e6f00bea7ac9b4a"
  },
  "id": "UkFdvBXF6cwUwtj4",
  "tags": []
}