{
  "name": "beispiel2Apointment",
  "id": "LW0Mq5pKXBupOtjy",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "af19bd67-074c-44e5-b56e-2a3a531c0ca4",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        -256,
        -16
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "ce5303b8-5036-4946-a61f-4c9c8f599673",
              "leftValue": "={{ $json.message.from.id }}",
              "rightValue": 1387316504,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -16,
        -16
      ],
      "id": "2879e2e2-f1e9-42fc-95d7-00be9594a1c4",
      "name": "If"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=Du bist ein freundlicher Termin-Buchungs-Assistent f\u00fcr den Google Kalender 'n8nTest1'. Antworte immer auf Deutsch. Heute ist {{ $today.toFormat('dd.MM.yyyy') }}.\n\nAblauf, wenn ein Nutzer einen Termin vereinbaren m\u00f6chte:\n1. Ermittle das gew\u00fcnschte Datum. Wenn der Nutzer 'heute', 'morgen', '\u00fcbermorgen' o.\u00e4. sagt, berechne selbst das korrekte Datum im Format YYYY-MM-DD (heute ist {{ $today.toFormat('yyyy-MM-dd') }}).\n2. Rufe das Werkzeug 'google_calendar_tool' auf, um die Verf\u00fcgbarkeit zu pr\u00fcfen: action='list', date='YYYY-MM-DD'.\n3. Nenne dem Nutzer die freien Zeiten.\n4. Frage nach der gew\u00fcnschten Uhrzeit und dem Namen (falls noch nicht bekannt).\n5. Rufe das Werkzeug 'google_calendar_tool' erneut auf, um zu buchen: action='book', date='YYYY-MM-DD', time='HH:MM', name='Kundenname'.\n6. Best\u00e4tige dem Nutzer den eingetragenen Termin.\n\nWICHTIG: Das Werkzeug erwartet immer separate Felder (action, date, time, name) \u2013 niemals einen JSON-String. F\u00fcr 'list' gen\u00fcgen action und date. F\u00fcr 'book' werden action, date, time und name ben\u00f6tigt."
        }
      },
      "id": "0ae7fa60-47fc-4d50-9749-97b2f1fb6921",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        240,
        -48
      ]
    },
    {
      "parameters": {
        "model": "openai/gpt-4o-mini",
        "options": {
          "baseURL": "https://openrouter.ai/api/v1"
        }
      },
      "id": "2ce95f9b-c0be-4e55-9976-04c8ea04fea9",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -16,
        208
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "c66c48b2-7490-4b59-9b66-553eddaca044",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.1,
      "position": [
        528,
        -48
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        256,
        160
      ],
      "id": "f2f42712-c153-43dc-9900-182bacd83671",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "name": "google_calendar_tool",
        "description": "Pr\u00fcfe freie Zeiten oder buche Termine im Google Kalender. Felder: action ('list' = Verf\u00fcgbarkeit pr\u00fcfen, 'book' = Termin buchen), date (YYYY-MM-DD), time (HH:MM, nur bei 'book'), name (Kundenname, nur bei 'book').",
        "workflowId": {
          "__rl": true,
          "value": "dTDeXr5LFA4PoULZ",
          "mode": "list",
          "cachedResultName": "google_calendar_subworkflow"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "action": "={{ $fromAI('action', 'Entweder \"list\" um die Verf\u00fcgbarkeit zu pr\u00fcfen oder \"book\" um einen Termin zu buchen', 'string') }}",
            "date": "={{ $fromAI('date', 'Das Datum im Format YYYY-MM-DD', 'string') }}",
            "time": "={{ $fromAI('time', 'Die Uhrzeit im Format HH:MM, nur beim Buchen erforderlich', 'string', '') }}",
            "name": "={{ $fromAI('name', 'Der Name des Kunden, nur beim Buchen erforderlich', 'string', '') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "action",
              "displayName": "action",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            },
            {
              "id": "time",
              "displayName": "time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            },
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "id": "workflow-tool-id",
      "name": "google_calendar_tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.1,
      "position": [
        120,
        340
      ]
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "google_calendar_tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  }
}