{
  "name": "Calendar Agent PAT",
  "nodes": [
    {
      "parameters": {},
      "id": "fe125dca-0e8e-471a-b484-0916b4b7bc0c",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1,
      "position": [
        -520,
        600
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "72e23432-5b42-44f4-8df5-2f31131b7e77",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -420,
        820
      ],
      "credentials": {
        "openAiApi": {
          "id": "VRTmeW2iB7lCT299",
          "name": "OpenAi account 2"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7ab380a2-a8d3-421c-ab4e-748ea8fb7904",
              "name": "response",
              "value": "Unable to perform task. Please try again.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1f87983-d1b9-469c-ba52-3f5b880bde5c",
      "name": "Try Again",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        480,
        620
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "39c2f302-03be-4464-a17a-d7cc481d6d44",
              "name": "=response",
              "value": "={{$json.output}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "7a1f116e-0e5f-4f6a-aee2-7661c0062ac9",
      "name": "Success",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        460
      ]
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "damiandan06@gmail.com",
          "mode": "list",
          "cachedResultName": "damiandan06@gmail.com"
        },
        "start": "={{ $fromAI(\"starttime\",\"the time the user asks for the event to start\") }}",
        "end": "={{ $fromAI(\"endtime\",\"the time the user asks for the event to end\") }}",
        "additionalFields": {
          "attendees": [],
          "summary": "={{ $fromAI(\"name\",\"the name of the calendar event\") }}"
        }
      },
      "id": "659e7b6a-b1fb-49e7-9ae2-c60ca1a56ac8",
      "name": "Create Event",
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.1,
      "position": [
        -120,
        820
      ],
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "FQqb80U9Tlx584NG",
          "name": "Google Calendar account"
        }
      }
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "damiandan06@gmail.com",
          "mode": "list",
          "cachedResultName": "damiandan06@gmail.com"
        },
        "start": "={{ $fromAI(\"starttime\",\"the time the user asks for the event to start\") }}",
        "end": "={{ $fromAI(\"endtime\",\"the time the user asks for the event to end\") }}",
        "additionalFields": {
          "attendees": [
            "={{ $fromAI(\"attendeeEmail\",\"the email of the user asks the event to be sceduled with\") }}"
          ],
          "summary": "={{ $fromAI(\"name\",\"the name of the calendar event\") }}"
        }
      },
      "id": "a00e22da-d45a-42fd-bc25-837c5377a8ce",
      "name": "Create Event with Attendee",
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.1,
      "position": [
        20,
        820
      ],
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "FQqb80U9Tlx584NG",
          "name": "Google Calendar account"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "calendar": {
          "__rl": true,
          "value": "damiandan06@gmail.com",
          "mode": "list",
          "cachedResultName": "damiandan06@gmail.com"
        },
        "returnAll": true,
        "options": {
          "timeMin": "={{ $fromAI(\"oneDayBefore\",\"one day before the day that the user requested\") }}",
          "timeMax": "={{ $fromAI(\"oneDayAfter\",\"one day after the day that the user requested\") }}"
        }
      },
      "id": "e534d7f3-d52c-4d11-996e-8dba93fa80ce",
      "name": "Get Events",
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.1,
      "position": [
        -260,
        820
      ],
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "FQqb80U9Tlx584NG",
          "name": "Google Calendar account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.query }}",
        "options": {
          "systemMessage": "=You are a calendar assistant. You have access to multiple tools to take any action within calendar. Here is the current date/time: {{ $now }}\n\nCreate Event:\nIf an end date isn't specified for the event, assume it will be 60 minutes long. Use this tool if there is no attendee specified.\n\nCreate Event with Attendee:\nIf an end date isn't specified for the event, assume it will be 60 minutes long. Use this tool WHEN AN ATTENDEE IS SPECIFIED.\n\nGet Events:\nUse this tool to get events from a certain day and summarize them. Make sure you fetch just not canceled events."
        }
      },
      "id": "7cd28d19-1c34-4981-8c16-87c5927c6333",
      "name": "Calendar Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        -300,
        600
      ],
      "onError": "continueErrorOutput"
    }
  ],
  "pinData": {},
  "connections": {
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Calendar Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Event": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create Event with Attendee": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Events": {
      "ai_tool": [
        [
          {
            "node": "Calendar Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar Agent": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Try Again",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/London",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "86c0ebd1-3271-4334-8ab3-12d88c8f290f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "d1853d6d92799d2de46a947c80ac9a5af91665397cc93a1b568769b332366e37"
  },
  "id": "KbQDlZ6kwu7g7D0M",
  "tags": []
}