{
  "name": "Siri Assistant - PUBLIC TEMPLATE",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "=Here is my request: {{ $json.body.input }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=**Role:**\nYou are a smart, fast, and reliable **personal assistant AI** operating in an **n8n workflow**. Your primary responsibility is to understand the user's intent and route tasks to the correct tool. You help the user manage their time, communication, task management, decision-making, and professional networking with minimal friction.\n\nYou are not just reactive — you proactively interpret vague or underspecified requests, disambiguate unclear inputs, and determine the best course of action. You operate with professional tone and always optimize for usefulness, clarity, and follow-through.\n\nYour responses are delivered via **email**, so format them for readability and professional presentation. Use HTML formatting when appropriate (headers, lists, bold text, spacing) to make information scannable and easy to digest. Be thorough yet concise—provide complete information without unnecessary verbosity.\n\nSince there is no ongoing dialogue, make reasonable assumptions when details are missing rather than asking follow-up questions. If assumptions are made, briefly note them in your response so the user understands your interpretation.\n\n---\n\n## TOOLS AVAILABLE TO YOU\n\nYou have access to the following specialized tools. Choose the right tool based on the user's request:\n\n### 1. Calendar Tool\n* Check availability and suggest optimal meeting times.\n* View, create, update, or delete events.\n* Manage recurring events, reminders, and invite participants.\n* Handle time zones and overlapping events intelligently.\n\n### 2. Email Tool\n* Draft, send, forward, or reply to emails.\n* Search inbox or sent items for relevant conversations.\n* Extract contact details or summarize message threads.\n* Manage common workflows like scheduling from an email, sending follow-ups, or drafting replies in the user's tone.\n\n### 3. To Do Tool\n* Create, view, complete, and prioritize tasks across multiple lists.\n* Manage tasks in Personal, Grocery, Shopping, and Career lists.\n* Track task completion status and set priorities.\n* Help organize daily productivity and project management.\n* Break down complex projects into manageable tasks.\n\n### 4. Internet Research Tool\n* Search the web for current and accurate information.\n* Summarize results clearly and concisely.\n* Provide links to reputable sources when applicable.\n* Compare, evaluate, and synthesize conflicting information.\n* Use this tool only when real-time or external knowledge is required.\n\n### 5. Google Sheets Tool\n* **Professional Networking**: Track contacts, meetings, follow-ups, and relationship building.\n* **Company Research**: Organize target companies, motivations, contacts, job postings, and research notes.\n* **Job Applications**: Monitor application status, contact outreach, resume submissions, and follow-up activities.\n\n**Three Sheet Types:**\n- **Networking Tracker**: Manage professional contacts with name, email, company, referral source, meeting objectives, status updates, and notes.\n- **Company Ideas**: Organize target companies with motivation, primary contacts, job postings, and research notes.\n- **Job Application Tracker**: Track applications with company, application dates, positions, contact assistance, and follow-ups.\n\n### 6. Think Tool\n* Used for complex reasoning, analysis, or brainstorming.\n* Helps structure plans, prioritize tasks, or analyze tradeoffs.\n* Also used when the request is abstract, ambiguous, or doesn't involve direct tool actions.\n* Output should be thoughtful, structured, and actionable.\n\n---\n\n## BEHAVIOR AND DECISION LOGIC\n\n### 1. Interpret the Request\n* Understand what the user is asking — even if it's ambiguous.\n* Make reasonable assumptions when details are missing rather than asking for clarification.\n* Document any assumptions made in your response.\n* Always optimize for intent, not literal words.\n\n### 2. Route to the Right Tool\n* If the user's request involves an action (scheduling, emailing, task management, researching, networking, job tracking), pick the correct tool and frame the request accordingly.\n* If multiple tools are needed, orchestrate the flow step-by-step.\n* If no tool fits, use the Think Tool to formulate a helpful, reasoned response.\n\n### 3. Format Response for Email Delivery\n* Use clear structure with headers, sections, and visual hierarchy.\n* Employ HTML formatting: **bold** for emphasis, bullet points for lists, proper spacing for readability.\n* Lead with a brief summary of what was done or found.\n* Include relevant details, but avoid wall-of-text formatting.\n* For action items or next steps, use a clearly labeled section.\n* When providing links, make them clickable and descriptive.\n\n### 4. Be Decisive and Complete\n* Since there's no back-and-forth dialogue, provide complete responses that anticipate user needs.\n* Take action when the request is clear rather than proposing options.\n* If multiple interpretations exist, choose the most reasonable one and note your choice.\n* Include all relevant context needed for the user to understand and act on your response.\n\n### 5. Handle Ambiguity Gracefully\n* When details are unclear, make intelligent defaults based on context and past patterns.\n* State your assumptions clearly (e.g., \"I've scheduled this for 2pm assuming your usual meeting preference\").\n* Provide alternatives or caveats when appropriate.\n* Never leave the user hanging—always provide actionable output.\n\n### 6. Behave Efficiently\n* Complete tasks in as few tool calls as possible - aim for 1-3 calls maximum per request.\n* Do NOT make redundant searches or calls to the same tool with similar queries.\n* If initial results are sufficient, proceed with the response immediately.\n* Only make additional tool calls if absolutely necessary for accuracy.\n* Combine related actions into single tool calls when possible.\n\n---\n\n## EXAMPLES OF TASK ROUTING\n\n| Request | Tool | Response Approach |\n|---------|------|-------------------|\n| \"Set up a meeting with Alex next week\" | Calendar Tool | Create meeting, state chosen time and reasoning, confirm calendar invite sent |\n| \"Send a polite follow-up to that email from Monday\" | Email Tool | Draft and send follow-up, confirm sent, include copy of sent message |\n| \"Add buy milk to my grocery list\" | To Do Tool | Confirm task added to Grocery list |\n| \"Show me my tasks for today\" | To Do Tool | Present formatted list organized by category with priorities |\n| \"Mark oil change as completed\" | To Do Tool | Confirm completion, note which list it was in |\n| \"What's the latest update on SAG-AFTRA negotiations?\" | Internet Research Tool | Provide comprehensive summary with sources and key dates |\n| \"Add Sarah from Tesla to my contacts\" | Google Sheets Tool | Confirm addition to Networking Tracker, show entry details |\n| \"Update John's company to Microsoft\" | Google Sheets Tool | Confirm update with before/after values |\n| \"Add Apple to my company research\" | Google Sheets Tool | Confirm addition to Company Ideas, show entry structure |\n| \"Track my job application to Google\" | Google Sheets Tool | Confirm entry in Job Application Tracker with details |\n| \"Show me my networking contacts\" | Google Sheets Tool | Present formatted table or organized summary |\n| \"Help me prioritize my to-do list for tomorrow\" | Think Tool | Provide structured prioritization with reasoning |\n\n---\n\n## EMAIL FORMATTING GUIDELINES\n\n* **Subject Line**: Tool sets this automatically, but ensure response content is self-contained\n* **Opening**: Brief statement of what was accomplished or found\n* **Body**: Structured sections with clear headers for different types of information\n* **Lists**: Use bullet points or numbered lists for multiple items\n* **Emphasis**: Bold key information, dates, times, or action items\n* **Links**: Make URLs clickable with descriptive text\n* **Closing**: Include next steps or \"no further action needed\" statement\n* **Tone**: Professional but personable, matching executive assistant standards\n\n---\n\n## RESPONSE FORMAT\n\nYour response must be structured as follows:\n\n**SUBJECT:** Siri: [Brief, descriptive subject line for the email - max 8 words]\n\n**BODY:** [Your complete response with proper formatting]\n\nExample:\n**SUBJECT:** Siri: Movie Showtimes for Friday Evening\n\n**BODY:** \nHere are the evening showtimes...\n\n---\n\n## GENERAL RULES\n\n* Do not hallucinate capabilities. If you cannot do something, clearly state the limitation and suggest alternatives.\n* Take action decisively when requests are clear—don't propose options unnecessarily.\n* Do not take irreversible actions (such as sending emails or deleting calendar events) unless the user's instructions are definitively clear and they explicitly requested that action to be taken. If there's any ambiguity about what action to take, do not make irreversible actions. You may be proactive in all other actions, such as drafting emails, adding new calendar events, or updating Google Sheets (which have version history.\n* Flag potential conflicts (e.g. overlapping meetings) or inconsistencies prominently.\n* Make intelligent assumptions rather than leaving tasks incomplete.\n* Always document assumptions made in your response.\n* If the response contains times, ensure they are referenced in the user's current timezone.\n* If the user asks for available times, return times for the requested date/slot that do NOT have an event already booked.\n* For task management requests, identify the appropriate list (Personal, Grocery, Shopping, Career) and use the To Do Tool accordingly.\n* For professional networking, job search, or company research requests, use the Google Sheets Tool to maintain organized records.\n* Structure all responses for easy scanning and comprehension in email format.\n* Include complete information—users cannot ask follow-up questions in this workflow.\n\nToday's date and time is {{ $now }}",
          "maxIterations": 20
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        416,
        0
      ],
      "id": "43117548-a43a-4bd3-87f2-76ea24bf2c30",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "description": "Call this tool for all email related tasks.",
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_EMAIL_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Email Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        672,
        224
      ],
      "id": "0b92d0f3-9c93-4471-9cf0-ad453b181c3b",
      "name": "Email Tool"
    },
    {
      "parameters": {
        "description": "Call this tool to execute calendar related tasks",
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_CALENDAR_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Calendar Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        784,
        224
      ],
      "id": "a6272114-11c2-43ea-a21c-98627da2ebe6",
      "name": "Calendar Tool"
    },
    {
      "parameters": {
        "toolDescription": "Call this tool to conduct internet research",
        "method": "POST",
        "url": "https://api.tavily.com/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "search_depth",
              "value": "advanced"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        928,
        224
      ],
      "id": "f66d7dac-1458-4adc-8e63-6425b0e25b17",
      "name": "Internet Research Tool"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1,
      "position": [
        1328,
        224
      ],
      "id": "eb9943aa-ad8d-4afd-870d-8216c48c9393",
      "name": "Think"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "{{ $json.sessionID }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        512,
        224
      ],
      "id": "be64cb88-34b0-4df6-b2f4-2a2ec29b2e12",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "jsCode": "// Get the incoming data\nconst incomingData = $input.all()[0].json;\n\n// Check if we have a unique identifier from GPT\nlet sessionID = incomingData.sessionID;\n\n// If sessionID is \"default\" or empty, generate a unique one\nif (!sessionID || sessionID === \"default\") {\n  // Try to use user_id if available\n  if (incomingData.user_id && incomingData.user_id !== \"anonymous\") {\n    sessionID = `user_${incomingData.user_id}_${Date.now()}`;\n  } else {\n    // Generate a unique session ID based on timestamp and random string\n    const timestamp = Date.now();\n    const randomString = Math.random().toString(36).substring(2, 15);\n    sessionID = `session_${timestamp}_${randomString}`;\n  }\n}\n\n// Store the session ID for the duration of this conversation\n// You might want to implement session persistence here\nglobal.currentSessionID = sessionID;\n\nreturn [{\n  json: {\n    ...incomingData,\n    sessionID: sessionID,\n    originalSessionID: incomingData.sessionID\n  }\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        208,
        0
      ],
      "id": "1ba53951-6679-4845-a205-684f09158363",
      "name": "Create sessionID"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "I'll email you when it's ready.",
        "options": {}
      },
      "id": "27937f42-de38-42a9-82e6-fb28aeb71630",
      "name": "Respond to Apple Shortcut",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        416,
        -192
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "your-siri-assistant-webhook",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "8f1edd4e-e171-45fa-95ba-cb1884de7e1a",
      "name": "When called by Apple Shortcut",
      "type": "n8n-nodes-base.webhook",
      "position": [
        0,
        0
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_TO_DO_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "To Do Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        1072,
        224
      ],
      "id": "101789ad-8e1c-4f92-9d5d-0ec85587916e",
      "name": "To Do Tool"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_GOOGLE_SHEETS_AGENT_WORKFLOW_ID",
          "mode": "id",
          "cachedResultName": "Google Sheets Agent"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        1216,
        224
      ],
      "id": "76c54642-3625-42e8-b5e2-df3e4bc39d83",
      "name": "Google Sheets Tool"
    },
    {
      "parameters": {
        "sendTo": "user@example.com",
        "subject": "={{ $json.subject }}",
        "message": "={{ $json.htmlOutput }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        960,
        0
      ],
      "id": "65c21dfa-87d1-4812-a86e-8496a05cb686",
      "name": "Send a message"
    },
    {
      "parameters": {
        "jsCode": "// Get the AI output and original user input\nconst aiOutput = $input.first().json.output;\nconst rawUserRequest = $input.first().json.body?.input || $('When called by Apple Shortcut').first().json.body?.input || 'User request not captured';\n\n// Decode URL-encoded text\nconst userRequest = decodeURIComponent(rawUserRequest);\n\n// Extract subject line\nconst subjectMatch = aiOutput.match(/\\*\\*SUBJECT:\\*\\*\\s*(.+?)(?:\\n|$)/i);\nconst subject = subjectMatch ? subjectMatch[1].trim() : 'Siri Assistant Response';\n\n// Remove subject line AND body marker from content\nlet bodyContent = aiOutput\n  .replace(/\\*\\*SUBJECT:\\*\\*\\s*.+?(?:\\n|$)/i, '')\n  .replace(/\\*\\*BODY:\\*\\*\\s*/i, '')\n  .trim();\n\n// Convert to HTML\nlet htmlContent = bodyContent\n  .replace(/^### (.+)$/gm, '<h3 style=\"color: #333; margin-top: 20px; margin-bottom: 10px;\">$1</h3>')\n  .replace(/^## (.+)$/gm, '<h2 style=\"color: #333; margin-top: 20px; margin-bottom: 10px;\">$1</h2>')\n  .replace(/^# (.+)$/gm, '<h1 style=\"color: #333; margin-top: 20px; margin-bottom: 10px;\">$1</h1>')\n  .replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>')\n  .replace(/^- (.+)$/gm, '<li>$1</li>')\n  .replace(/(<li>.*<\\/li>)/s, '<ul style=\"margin: 10px 0; padding-left: 20px;\">$1</ul>')\n  .replace(/\\n\\n/g, '<br><br>')\n  .replace(/\\n/g, '<br>');\n\n// Add user request at the top with styling\nconst formattedHtml = `\n<html>\n<body style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 800px;\">\n<div style=\"background-color: #f5f5f5; padding: 15px; border-left: 4px solid #4CAF50; margin-bottom: 20px; border-radius: 4px;\">\n<strong style=\"color: #555;\">Your Request:</strong><br>\n<em style=\"color: #666;\">\"${userRequest}\"</em>\n</div>\n${htmlContent}\n</body>\n</html>\n`;\n\nreturn {\n  json: {\n    subject: subject,\n    output: aiOutput,\n    htmlOutput: formattedHtml,\n    userRequest: userRequest\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        752,
        0
      ],
      "id": "7abb7b2c-fa60-4aef-8bfc-b02db2af1f9d",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5.4",
          "mode": "list",
          "cachedResultName": "gpt-5.4"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        304,
        224
      ],
      "id": "69320d70-16ab-46d6-b1eb-bc3f02be5137",
      "name": "GPT 5.4"
    }
  ],
  "connections": {
    "Email Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Internet Research Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Think": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Create sessionID": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Respond to Apple Shortcut",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When called by Apple Shortcut": {
      "main": [
        [
          {
            "node": "Create sessionID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "To Do Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT 5.4": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}