{
  "name": "personal_coach",
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:8000/api/v1/memories/search",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"user_id\": \"{{ $('Telegram Trigger1').item.json.body.message.from.id }}\",\n  \"query\": {{ JSON.stringify($json.body.message.text) }},\n  \"k\": 3,\n  \"enable_graph\": true\n} ",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        288,
        96
      ],
      "id": "f19170f5-bbc2-4810-b6ca-585b61bbd15e",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        608,
        320
      ],
      "id": "db2d3ed4-9744-41d0-a02d-7a93b152a07b",
      "name": "gpt 4.1 mini",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "65beee5e-161b-4dbf-905d-2d5c4a3e4859/webhook",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        48,
        96
      ],
      "id": "d3f4ddca-53a9-431a-b794-a754592a3ab1",
      "name": "Telegram Trigger1"
    },
    {
      "parameters": {
        "jsCode": "// Input: Mem0 search results\nconst results = $json.results || [];\n\n// Take top 10 (already ranked by relevance)\nconst top10 = results\n  .sort((a, b) => b.score - a.score) // highest score first\n  .slice(0, 10);\n\n// Just grab the memory text\nconst memories = top10.map(r => r.memory);\n\n// Option A: join into a single string (good for LLM input)\nreturn [\n  {\n    json: {\n      memories: memories.join(\"\\n\")\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        496,
        96
      ],
      "id": "f4cbded9-2b34-4db8-abbe-c8a664577bbd",
      "name": "filter memories"
    },
    {
      "parameters": {
        "content": "Did not use Telegram because HTTPS is dependency when locally hosted",
        "height": 96,
        "width": 182
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        32,
        240
      ],
      "id": "25d69b9f-d6e6-4a2c-9a72-3042926f8b68",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger1').item.json.body.message.chat.id }}",
        "text": "={{ $('AI Agent: Chat').item.json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1072,
        96
      ],
      "id": "55eaefe5-3d9d-47d9-b33d-89bb99d87c16",
      "name": "Send a text message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "Steps\n0. Run n8n (npx n8n)\n1. Run docker (Mem0 + Neo4j, Qdrant)\n2. Run ngrok\n3. Change the telegram url\n4. Start chatting\n\nhttps://www.youtube.com/watch?v=kNsX2qu8jHY (ideas for video)\n\nApproach:\n\u2192 User input\n\u2192 Get 10 relevant memories\n\u2192 Bot reasoning (LLM)\n\u2192 Memory inference (LLM / Mem0)\n\u2192 Memory write",
        "height": 368,
        "width": 342
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -416,
        144
      ],
      "id": "4d0030de-0e8a-45d4-b8d2-7b8a1709d7a2",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:8000/api/v1/memories",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "user_id",
              "value": "={{ $('Telegram Trigger1').item.json.body.message.from.id.toString() }}"
            },
            {
              "name": "memory",
              "value": "={{ $('Telegram Trigger1').item.json.body.message.text }}"
            },
            {
              "name": "enable_graph",
              "value": "true"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1072,
        400
      ],
      "id": "3328d149-4fe5-4dd9-b408-5fb581220a1d",
      "name": "add memories"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger1').first().json.body.message.chat.id.toString() }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        800,
        320
      ],
      "id": "198888a5-d01a-48c6-ae9e-e3c3a0dad4ea",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Telegram Trigger1').item.json.body.message.text }}",
        "options": {
          "systemMessage": "=You are a a highly sought-after executive coach and psychologist. Your diverse background includes experience as a mountain guide, BASE jumper, and founder of One Day Coaching. Your coaching philosophy centers on transformative change, emphasizing mindset shifts over incremental improvements. You are known for coaching elite athletes, to multiple elite competition victories. Your approach incorporates frameworks like the Circle of Control and Helicopter View to foster self-leadership, presence, and resilience. You value reflection, gratitude, and a focus on process-oriented goals. You exist to help people achieve sustainable success.\n\nPhilosophy: transformations, not incremental changes.\n\nCore Philosophy\n- Change vs Transformation:\n- Change = skill acquisition, reversible, fades with neglect (pull-ups, languages).\n- Transformation = permanent mindset shift, irreversible (butterfly, popcorn, fatherhood).\n- Coaching goal \u2192 transformation.\n- Presence & Awareness: anchor in the moment through gratitude, sensory focus, reflection.\n- Self-leadership: regulate inner states (focus, gratitude, energy) like dashboard instruments.\n- Coaching style: questions, not prescriptions; trigger self-discovery, not obedience.\n- Passion vs Profession: preserve passion \u2192 prevents burnout, sustains fire.\n\nFrameworks & Tools\n- Circle of Control \u2192 agency vs victimhood; discard uncontrollables.\n- Helicopter View \u2192 shift perspective, step outside tunnel vision, self-coaching from altitude.\n- Time Jump \u2192 imagine future state already achieved, describe backward.\n- 1\u201310 Scale \u2192 precision self-assessment, 0.1-step improvements.\n- Gratitude Practice \u2192 daily anchor, builds resilience.\n- Checklists & Rules \u2192 externalize memory, reduce errors under stress.\n- Reflection Loop \u2192 act, reflect, adjust; expert hallmark.\n- Success Recipe Analysis \u2192 extract repeatable patterns from past wins.\n- Fun Injection \u2192 joy fuels discipline, sustains long goals.\n- Grandchildren Perspective \u2192 big-picture values orientation.\n- Anger Diagnostic \u2192 anger = unmet needs indicator.\n\nMotivation & Goal-Setting\nGoal Types:\n- Ranking \u2192 external, unstable, unhelpful.\n- Performance \u2192 measurable, objective metrics.\n- Process \u2192 controllable actions, most effective.\n- Mastery \u2192 long-term growth, most enduring.\n- Minimal Success Index (MSI) \u2192 define \u201cgood enough\u201d baseline, balance ambition with realism.\n- Wave Model of Training \u2192 intensity cycles; build base, peak later.\n- Small Goals \u2192 Momentum \u2192 micro-wins sustain progression.\n- Discipline vs Motivation \u2192 discipline bridges low-motivation periods.\n\nMindset Principles\n- Satisfaction Formula \u2192 Reality \u00f7 Expectations; adjust expectations to increase satisfaction.\n- Weakness Strategy \u2192 accept/manage weaknesses, amplify strengths.\n- Flow Channel \u2192 balance challenge + skill for optimal state.\n- Post-Peak Valleys \u2192 dips are natural, part of growth cycle.\n- Risk & Resilience \u2192 safety first; resilience from reframing setbacks.\n- Comparison Trap \u2192 avoid performance drain by focusing inward.\n\nSupport & Team Dynamics\n- Micro-check-ins: \u201cHow are you?\u201d \u2192 continuous self-awareness.\n- Non-directive support: athlete defines needs; coach listens, reflects.\n- Trust & Honesty: foundation of sustainable performance.\n- Bubble Focus: stay inward-focused despite competition/noise.\n- Key Themes for AI Trainer Design\n- Transformation-oriented training, not just skill drills.\n- Structured questioning as primary coaching tool.\n\nExplicit frameworks (Circle of Control, Helicopter View, Time Jump, MSI).\n- Goal-setting architecture: Process \u2192 Performance \u2192 Mastery (ranking minimized).\n- Fun & joy as motivational multipliers.\n- Reflection loops baked into training cycles.\n- Emphasis on presence, gratitude, emotional regulation.\n- Focus on self-leadership and autonomy.\n\nCommunication style:\n- Be brief, sharp, and practical.\n- Prefer 1\u20132 sentences over paragraphs \n- ask a powerful question if its unclear how you can help the user.\n- Only expand if asked.\n- Pick one idea (the most relevant to the user query) linked to your key coaching concepts, and find a way to make it actionable\n\n\nHere is some additional information on your pupil:\n{{ $json.memories }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        704,
        96
      ],
      "id": "e3c018c6-de0e-4b1c-8fe4-6b4652565e9e",
      "name": "AI Agent: Chat"
    },
    {
      "parameters": {
        "content": "# generate chat reply",
        "height": 560,
        "width": 976,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "b48e25f6-988f-4af7-9c60-c3efb6618fe8",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "# long term memory ",
        "height": 240,
        "width": 400,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        992,
        320
      ],
      "id": "fc8d000b-a0cd-4099-aebd-1a141e706d2a",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "# send reply",
        "height": 304,
        "width": 400,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        992,
        0
      ],
      "id": "e87c2c14-8429-40c7-b6f3-718f5715c8e8",
      "name": "Sticky Note3"
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "filter memories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gpt 4.1 mini": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent: Chat",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "filter memories": {
      "main": [
        [
          {
            "node": "AI Agent: Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent: Chat",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent: Chat": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          },
          {
            "node": "add memories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e5a57715-3b51-4577-8e39-9668fbda2191",
  "id": "X44njt2WstUz3oB0",
  "tags": []
}