{
  "name": "email_jarvis_yt",
  "nodes": [
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -620,
        -160
      ],
      "id": "a6c0ed20-7373-47a2-ab2d-f332a7ee580e",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "operation": "reply",
        "messageId": "={{ $fromAI(\"ID\",\"the message ID\") }}",
        "message": "={{ $fromAI(\"emailBody\") }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        -520,
        260
      ],
      "id": "84a8d132-58bc-491c-8978-9456ea858777",
      "name": "Respuesta",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.query }}",
        "options": {
          "systemMessage": "=# Resumen\n\nEres un asistente de gesti\u00f3n de correos electr\u00f3nicos. Todos los correos deben estar formateados profesionalmente en HTML y deben finalizar con la firma \"Abraham P\u00e9rez\".\n\n## Herramientas de Gesti\u00f3n de Correos\n\n- \"Envio\" \u2192 Para enviar correos electr\u00f3nicos.  \n- \"CrearBorrador\" \u2192 Para crear un borrador si el usuario lo solicita. \n- \"ObtenerEmails\" \u2192 Para obtener correos electr\u00f3nicos cuando se requiera.\n- \"ObtenerEtiquetas\" \u2192 Para obtener las etiquetas de los correos.  \n- \"MarcarNoLeido\" \u2192 Para marcar un correo como no le\u00eddo.  \n  - Primero, usa \"Obtener Emails\" para obtener el ID del mensaje que se debe marcar.  \n- \"AddEtiquetas\" \u2192 Para etiquetar un correo.  \n  - Primero, usa \"ObtenerEmails\" para obtener el ID del correo.  \n  - Luego, usa \"ObtenerEtiquetas\" para obtener el ID de la etiqueta.  \n- \"Respuesta\" \u2192 Para responder a un correo.  \n  - Primero, usa \"ObtenerEmails\" para obtener el ID del correo al que se responder\u00e1.  \n\n## Notas Finales  \n- Fecha y hora actual: {{ $now }}"
        }
      },
      "id": "c58d807e-3fa6-488d-ac5a-122c153b0416",
      "name": "Agente de Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        -360,
        -160
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "39c2f302-03be-4464-a17a-d7cc481d6d44",
              "name": "=response",
              "value": "={{$json.output}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "15b08ea4-5bee-4429-a329-61d1a5a798c2",
      "name": "\u2705",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        -240
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7ab380a2-a8d3-421c-ab4e-748ea8fb7904",
              "name": "response",
              "value": "No se puede realizar la tarea. Por favor, int\u00e9ntalo de nuevo.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "74b2e7b3-79bb-4087-946c-93e5737d29fa",
      "name": "\u274c",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        -60
      ]
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "={{ $fromAI(\"subject\") }}",
        "emailType": "html",
        "message": "={{ $fromAI(\"emailBody\") }}",
        "options": {
          "sendTo": "={{ $fromAI(\"emailAddress\") }}"
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        -180,
        320
      ],
      "id": "cdb72e67-1236-4ca0-94a8-8d542424ea18",
      "name": "CrearBorrador",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": "={{ $fromAI(\"limit\",\"Cuantos emails quiere el usuario\") }}",
        "simple": false,
        "filters": {
          "sender": "={{ $fromAI(\"sender\",\"Quienes son los remitentes de los correos electr\u00f3nicos.\") }}"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        -20,
        280
      ],
      "id": "35e319dd-bd86-46b5-b526-2b4bd9651c48",
      "name": "ObtenerEmails",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "label",
        "returnAll": true
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        120,
        220
      ],
      "id": "062fd662-8c69-4783-bc57-16ec250c6fe0",
      "name": "ObtenerEtiquetas",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $fromAI(\"emailAddress\") }}",
        "subject": "={{ $fromAI(\"subject\") }}",
        "message": "={{ $fromAI(\"emailBody\") }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        -680,
        200
      ],
      "id": "590cb249-d18e-4b35-ae1b-f70373cb5b64",
      "name": "Envio",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $fromAI(\"ID\",\"the ID of the message\") }}",
        "labelIds": "={{ $fromAI('LabelID') }}"
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        -340,
        320
      ],
      "id": "f65be392-3b1b-4922-bf94-d68a7d6f4395",
      "name": "AddEtiqueta",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "markAsUnread",
        "messageId": "={{ $fromAI(\"messageID\") }}"
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        280,
        140
      ],
      "id": "285922f1-766b-4882-a29a-67b304289f99",
      "name": "MarcarNoLeido",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "id": "af1f18fd-d339-4c0f-a8be-01e5c790201a",
      "name": "OpenAI Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -840,
        100
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Agente de Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respuesta": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Agente de Email": {
      "main": [
        [
          {
            "node": "\u2705",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u274c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CrearBorrador": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "ObtenerEmails": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "ObtenerEtiquetas": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Envio": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AddEtiqueta": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "MarcarNoLeido": {
      "ai_tool": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Agente de Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b96b0730-84b6-4b5e-bdc7-c71aaec8dd73",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "UKkbUIUTejLfPeqO",
  "tags": []
}