{
  "name": "Your Personal Assistant AI Agent That Makes Phone Calls",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "3c14c9dc-30d6-49e0-a802-e9480d22e5ea",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        880,
        120
      ],
      "credentials": {
        "openAiApi": {
          "id": "LSihAOI8NTU3m5ce",
          "name": "OpenAi account 3"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "efaa58a1-468f-4ebe-82d1-2670845868f0",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        1860,
        540
      ],
      "credentials": {
        "openAiApi": {
          "id": "LSihAOI8NTU3m5ce",
          "name": "OpenAi account 3"
        }
      }
    },
    {
      "parameters": {
        "model": "text-embedding-3-small",
        "options": {}
      },
      "id": "66707bfb-b2ee-4c3b-b357-f4c652d800c8",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1,
      "position": [
        2200,
        780
      ],
      "credentials": {
        "openAiApi": {
          "id": "LSihAOI8NTU3m5ce",
          "name": "OpenAi account 3"
        }
      }
    },
    {
      "parameters": {
        "name": "Knowledge_Base",
        "description": "Call this tool to get information about my company."
      },
      "id": "b75b3042-e266-437b-9620-3bbda3db742d",
      "name": "Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "typeVersion": 1,
      "position": [
        1540,
        380
      ]
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "documentId": {
          "__rl": true,
          "value": "1rP7rhJqPzOYO11UxARnceK46ViDhK56ikejVIDCke8o",
          "mode": "list",
          "cachedResultName": "Contact database",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1rP7rhJqPzOYO11UxARnceK46ViDhK56ikejVIDCke8o/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1rP7rhJqPzOYO11UxARnceK46ViDhK56ikejVIDCke8o/edit#gid=0"
        },
        "options": {}
      },
      "id": "9ff5aa0c-7227-4e8a-85c3-d387e42eb0e6",
      "name": "Contacts Data",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        980,
        440
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "TQHNRwbFTxYXwnxr",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Listen for incoming events').first().json.message.from.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "cd7a40bc-6347-406a-b196-50a7853cbba3",
      "name": "Respond to Me",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1560,
        0
      ],
      "webhookId": "59625d03-4fda-4130-ae7f-4894ccc6d7f8",
      "credentials": {
        "telegramApi": {
          "id": "uO0lVtfdNYsEA99Q",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "updates": [
          "*"
        ],
        "additionalFields": {}
      },
      "id": "cc54661d-9e98-4313-a375-29a79e21ab81",
      "name": "Listen for incoming events",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -260,
        180
      ],
      "webhookId": "322dce18-f93e-4f86-b9b1-3305519b7834",
      "typeVersion": 1
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{$json.message.voice.file_id}}"
      },
      "id": "a81adfff-44f1-4642-a9ab-ea1d09f997e4",
      "name": "Download voice file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        240,
        300
      ],
      "typeVersion": 1.2,
      "webhookId": "08250cc3-cbfe-4cb0-9b83-942d77d12906",
      "credentials": {
        "telegramApi": {
          "id": "uO0lVtfdNYsEA99Q",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "bccbce0a-7786-49c9-979a-7a285cb69f78",
              "name": "CombinedMessage",
              "type": "string",
              "value": "={{ $json.message && $json.message.text ? $json.message.text : ($json.text ? $json.text : '') }}"
            },
            {
              "id": "5b1fc9f5-1408-4099-88cc-a23725c9eddb",
              "name": "Message Type ",
              "type": "string",
              "value": "={{ $json?.message?.text && !$json?.text ? \"text query\" : (!$json?.message?.text && $json?.text ? \"voice message\" : \"unknown type message\") }}"
            },
            {
              "id": "1e9a17fa-ec5d-49dc-9ff6-1f28b57fb02e",
              "name": "Source Type",
              "type": "string",
              "value": "={{ $('Listen for incoming events').item.json.message.forward_origin ? \" forwarded\" : \"\" }}"
            }
          ]
        },
        "options": {}
      },
      "id": "7edb4d45-2918-44dc-a661-586a8b9be518",
      "name": "Combine content and set properties",
      "type": "n8n-nodes-base.set",
      "position": [
        660,
        20
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "chatId": "={{ $('Listen for incoming events').first().json.message.from.id }}",
        "text": "=Sorry, {{ $('Listen for incoming events').first().json.message.from.first_name }}! This command is not supported yet. Please send text or voice messages.",
        "additionalFields": {
          "appendAttribution": false,
          "parse_mode": "Markdown"
        }
      },
      "id": "f42370e8-2e83-4b86-bcfc-66e97fcb1ea6",
      "name": "Send error message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -40,
        460
      ],
      "typeVersion": 1.2,
      "webhookId": "c219800e-42ba-4ca6-ba25-07eda647ea98",
      "credentials": {
        "telegramApi": {
          "id": "uO0lVtfdNYsEA99Q",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendChatAction",
        "chatId": "={{ $('Listen for incoming events').first().json.message.from.id }}"
      },
      "id": "7f723964-6287-4d7c-8864-9057901fa16f",
      "name": "Send Typing action",
      "type": "n8n-nodes-base.telegram",
      "position": [
        0,
        0
      ],
      "typeVersion": 1.2,
      "webhookId": "fd992425-5d02-40c8-a179-c0e2b4f98d97",
      "credentials": {
        "telegramApi": {
          "id": "uO0lVtfdNYsEA99Q",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "/"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Text"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "dd41bbf0-bee0-450b-9160-b769821a4abc",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice}}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Voice"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "325dc515-089e-4e77-aa88-ca8ca76fe45e",
      "name": "Determine content type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -20,
        200
      ],
      "typeVersion": 3.2
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {
          "language": "",
          "temperature": 0.7
        }
      },
      "id": "66848dd8-b06a-43b7-bc6f-c2b2f59ef996",
      "name": "Convert audio to text",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        420,
        300
      ],
      "typeVersion": 1.5,
      "credentials": {
        "openAiApi": {
          "id": "LSihAOI8NTU3m5ce",
          "name": "OpenAi account 3"
        }
      }
    },
    {
      "parameters": {
        "name": "Calendar_Agent",
        "description": "Call this tool to take actions within Calendar",
        "workflowId": {
          "__rl": true,
          "value": "KbQDlZ6kwu7g7D0M",
          "mode": "list",
          "cachedResultName": "Calendar Agent PAT"
        }
      },
      "id": "4f5abd41-c7f0-4afb-b683-1487c666855e",
      "name": "Calendar Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        1160,
        500
      ]
    },
    {
      "parameters": {
        "name": "Email_Agent",
        "description": "Call this tool to take any email actions",
        "workflowId": {
          "__rl": true,
          "value": "rqpQ9Rb7mqEeubDP",
          "mode": "list",
          "cachedResultName": "Email Agent PAT"
        }
      },
      "id": "692bd065-0fbe-45eb-8bec-480a5534dcd8",
      "name": "Email Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        1340,
        480
      ]
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Listen for incoming events').item.json.message.chat.id }}"
      },
      "id": "29853fad-b8eb-4967-a5f1-803c2d2cc5d9",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.2,
      "position": [
        800,
        400
      ]
    },
    {
      "parameters": {
        "pineconeIndex": {
          "__rl": true,
          "value": "text-embedding-3-small",
          "mode": "list",
          "cachedResultName": "text-embedding-3-small"
        },
        "options": {
          "pineconeNamespace": "=Adaptify AI SOP"
        }
      },
      "id": "fb134eff-ae73-42b0-96f7-cc0bca6d3744",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "typeVersion": 1,
      "position": [
        1440,
        680
      ],
      "credentials": {
        "pineconeApi": {
          "id": "4k7uLBMP6I3s4bOf",
          "name": "PineconeApi account 4"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.CombinedMessage }}",
        "options": {
          "systemMessage": "=#Role\n\nYou are Emily, Damian's personal assistant. Your primary role is to delegate tasks to the appropriate tool—you do not complete tasks yourself. Instead, you ensure that each request is routed correctly, with all necessary details passed to the right tool for execution.\n\n## Tools:\n\n- Phone Call Agent → Initiates phone calls by following provided instructions, ensuring clear and effective communication.\n\nContacts Data: For any task involving communication (e.g., calls, emails, or scheduling), always retrieve and verify contact details using the Contacts Data tool before passing them to the relevant agent.\n\nEmail Agent: Use this for handling all email-related actions, such as sending messages, setting up replies, or forwarding emails. Only send emails to verified email addresses found in the Contacts list. Always sign emails as \"Damian\" and NEVER use placeholders like \"[Your Name].\"\n\nIf an email address for a recipient cannot be found in the Contacts list, do not attempt to send the email or use placeholder addresses like \"@example.com\". \n\nCalendar Agent: Use this for scheduling, updating, or managing calendar events.\n\n\n### How to Use the Phone Call Agent:\n\nIf the user wants to make a phone call, trigger the Phone call Agent tool.\nEnsure the following details are passed to the calling agent:\nfirst_name → The name of the person or business being called.\ntype → The contact type (e.g., \"Doctor,\" \"Client,\" \"Supplier\").\ninstructions → A clear, concise description of what needs to be discussed or achieved on the call.\nphone_number → Must be formatted in E.164 format (e.g., \"+xxxxxxxxxxxx\").\ncall_purpose → The reason for the call.\nresponse_style → Determines whether responses should be concise or detailed.\ntone → Defines how the assistant should sound (e.g., friendly, professional).\npause_between_sentences → Controls the pacing of speech.\nfallback_response → A predefined response if the assistant is unsure of an answer.\nThe calling agent already understands it is a personal assistant making the call, so only provide essential details—avoid unnecessary context or explanations.\n\nExample Usage:\nUser Input: \"Call my accountant to ask about tax deductions for this year.\"\n\nAction:\n\nFirst, fetch the accountant’s phone number from the Contacts Data tool.\nEnsure the number is in E.164 format (e.g., \"+xxxxxxxxxxxx\").\nInvoke the Phone call Agent tool, passing the following details:\n\n{\n  \"first_name\": \"Mark Dan\",\n  \"type\": \"Accountant\",\n  \"instructions\": \"Ask about available tax deductions for this year and clarify if there are any changes in tax regulations that might affect Damian.\",\n  \"phone_number\": \"+xxxxxxxxxxxx\",\n  \"call_purpose\": \"Tax deduction inquiry\",\n  \"response_style\": \"concise\",\n  \"tone\": \"friendly\",\n  \"pause_between_sentences\": \"short\",\n  \"fallback_response\": \"I'm not sure, but I'll check with Damian and get back to you.\"\n}\nResponse to User: \"I spoke with Mark. He will send over a list of tax deductions by the end of the day.\"\n\n\n\n#### Rules & Best Practices:\nAlways respond in English.\nAlways delegate tasks using the correct tool—never complete them manually.\nIf a request requires contact details, fetch them first before proceeding.\nDo not include user questions in emails or phone call instructions.\nKeep responses clear, structured, and professional.\nEnsure efficient and proactive delegation to maintain a seamless workflow.\n\nWhen a task requires using one or more of these tools, make sure to identify which tool is most appropriate, pass along the relevant details, and execute the actions needed to complete the task. Your goal is to be proactive, precise, and organized in managing these resources to provide a smooth experience for the user.\n\nHere is the current time/date: {{ $now.format('DD')}}\n\n"
        }
      },
      "id": "a3812761-c233-4418-a12d-90396d9abb70",
      "name": "Personal Assistant",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        1120,
        0
      ],
      "retryOnFail": false
    },
    {
      "parameters": {
        "name": "phone_call_agent",
        "description": "Use this tool to call someone.\n",
        "workflowId": {
          "__rl": true,
          "value": "hv6YLKIEOyf5Rs46",
          "mode": "list",
          "cachedResultName": "Make a phone call PAT"
        },
        "specifyInputSchema": true,
        "jsonSchemaExample": "{\n  \"query\": {\n    \"first_name\": \"\",\n    \"type\": \"\",\n    \"instructions\": \"\",\n    \"phone_number\": \"\",\n    \"call_purpose\": \"\",\n    \"response_style\": \"concise\",\n    \"tone\": \"friendly\",\n    \"pause_between_sentences\": \"short\",\n    \"fallback_response\": \"I'm not sure, but I'll check with Damian and get back to you.\"\n  }\n}\n\n"
      },
      "id": "dd74de33-7b60-462f-89f8-cf437e21eb15",
      "name": "Phone Call Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        1260,
        740
      ]
    }
  ],
  "pinData": {
    "Listen for incoming events": [
      {
        "json": {
          "update_id": 137833006,
          "message": {
            "message_id": 279,
            "from": {
              "id": 6666718552,
              "is_bot": false,
              "first_name": "Damian",
              "last_name": "Dan",
              "language_code": "en"
            },
            "chat": {
              "id": 6666718552,
              "first_name": "Damian",
              "last_name": "Dan",
              "type": "private"
            },
            "date": 1737398398,
            "voice": {
              "duration": 9,
              "mime_type": "audio/ogg",
              "file_id": "AwACAgQAAxkBAAIBF2eOmH5fSxjOHxeqtS06fu7Oy5gbAALgGgAC-ehwUHnIya9HJz2sNgQ",
              "file_unique_id": "AgAD4BoAAvnocFA",
              "file_size": 187468
            }
          }
        }
      }
    ]
  },
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Knowledge Base",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base": {
      "ai_tool": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Contacts Data": {
      "ai_tool": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Listen for incoming events": {
      "main": [
        [
          {
            "node": "Determine content type",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Typing action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download voice file": {
      "main": [
        [
          {
            "node": "Convert audio to text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine content and set properties": {
      "main": [
        [
          {
            "node": "Personal Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine content type": {
      "main": [
        [
          {
            "node": "Combine content and set properties",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download voice file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send error message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert audio to text": {
      "main": [
        [
          {
            "node": "Combine content and set properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calendar Agent": {
      "ai_tool": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Email Agent": {
      "ai_tool": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "Knowledge Base",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Personal Assistant": {
      "main": [
        [
          {
            "node": "Respond to Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Phone Call Agent": {
      "ai_tool": [
        [
          {
            "node": "Personal Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "caa763b2-d566-4f6f-b72f-e590f68f6a8e",
  "meta": {
    "instanceId": "ae59e6b831344dba624c99cbe778a4bc47150f8e64de86a8011d15bac8e58c21"
  },
  "id": "Ruq5hY5xOtwgjih7",
  "tags": []
}