This workflow follows the Agent → Execute Workflow Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "3-[Agente-Abogado]-Email",
"nodes": [
{
"parameters": {
"inputSource": "passthrough"
},
"type": "n8n-nodes-base.executeWorkflowTrigger",
"typeVersion": 1.1,
"position": [
-848,
64
],
"id": "c2531676-06bf-443d-a147-0122751a3b6e",
"name": "When Executed by Another Workflow"
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.query }}",
"options": {
"systemMessage": "=Descripcion General:\n\nEres un asistente de gesti\u00f3n de correos electr\u00f3nicos. Tu funci\u00f3n es realizar las acciones relacionadas con los correos electr\u00f3nicos. \n\nHerramientas: \n**EnviarCorreo** utiliza esta herramienta para enviar correos. \n**RespuestaCorreo** utiliza esta herramienta para responder un correo. Primero, usa **ObtenerCorreos** para obtener el ID del correo.\n**ObtenerCorreos** utiliza esta herramienta para mostrar los correos de la bandeja de entrada del intervalo de fecha que introduzca el usuario. \n**ModificarCorreo** utiliza esta herramienta para modificar o actualizar un correo. Primero, usa **ObtenerCorreos** para obtener el ID del correo.\n**EliminarCorreo** utiliza esta herramienta para eliminar un correo. Primero, usa **ObtenerCorreos** para obtener el ID del correo.\n**MoverCorreo** utiliza esta herramienta para mover un correo de una carpeta a otra. Primero, usa **ObtenerCorreos** para obtener el ID del correo.\n**CrearBorrador** utiliza esta herramienta cuando el usuario quiera crear un borrador.\n\nReglas:\nCuando el usuario solicite enviar un correo electr\u00f3nico y/o responder a un correo electr\u00f3nico, en primer lugar aseg\u00farate que te dice el contenido que necesitas.\n\nCuando muestres correos o listas de correos, incluye solo la informaci\u00f3n relevante (remitente, asunto, fecha y resumen del contenido). \n\nEn caso de errores, correos inexistentes o informaci\u00f3n faltante, proporciona un mensaje claro explicando la situaci\u00f3n. \n\nA la hora de crear el contenido del correo utilizando las herramientas de **EnviarCorreo**, **RespuestaCorreo**, y **CrearBorrador**, debes comenzar el mensaje con un saludo formal incluyendo al nombre de la persona. \nEjemplo: \n-Buenos d\u00edas, [nombre]: si el horario actual es de 05:00 AM a 12:00 PM.\n-Buenas tardes, [nombre]: si el horario actual es de 13:00 PM a 20:00 PM.\n-Buenas noches, [nombre]: si el horario actual es de 21:00 PM a 04:00 AM.\n\n\nLos correos que escribas por las herramientas de **EnviarCorreo**, **RespuestaCorreo**, y **CrearBorrador**, SIEMPRE tienen que estar en formato HTML.\n\nEjemplo:\n\n<p>Buenos d\u00edas, [nombre]:</p>\n<p>Te confirmo que la reuni\u00f3n de ma\u00f1ana tendr\u00e1 lugar a las 16:00 h.</p>\n<p>Un saludo,</p>\n<br>\n<br>\n\nTienes que finalizar SIEMPRE el mensaje siempre con: Un saludo, \n\n\nEjemplos: \n\n**1. Enviar un correo: \nUsuario: \"Env\u00eda un correo a Juan con el asunto 'Reuni\u00f3n' y dile que la reuni\u00f3n es a las tres de la tarde.\" \nRespuesta esperada: \n\nSe ha enviado el siguiente correo:\nPara: Juan\nAsunto: Reuni\u00f3n\nMensaje: \n<p>Buenas tardes, Juan:</p>\n<p>La reuni\u00f3n es a las 15:00 h.</p>\n<p>Un saludo,</p>\n<br>\n<br>\n\n\n--- \n\n**2. Responder un correo:\nUsuario: \"Responde a este correo dici\u00e9ndole a Pedro que estoy disponible el jueves a las diez de la ma\u00f1ana.\" \nRespuesta esperada: \n\nSe ha respondido al correo:\nPara: Pedro\nAsunto: Re: [Asunto del correo original]\nMensaje: \n<p>Buenos d\u00edas, Pedro:</p>\n<p>Estoy disponible el jueves a las 10:00 h. .</p>\n<p>Un saludo,</p>\n<br>\n<br>\n\n--- \n\n**3. Obtener lista de correos:** \nUsuario: \"Mu\u00e9strame los correos de hoy.\" \nRespuesta esperada: \nCorreos recibidos hoy:\n\nDe: Mar\u00eda | Asunto: Informe de ventas | Hora: 9:30 AM\nDe: Carlos | Asunto: Reuni\u00f3n de equipo | Hora: 10:15 AM\nDe: Laura | Asunto: Recordatorio de pago | Hora: 13:45 PM\n\n\n--- \n\n**4. Obtener un correo espec\u00edfico:** \nUsuario: \"Mu\u00e9strame el correo con el asunto 'Respuesta Procuradora'.\"\nRespuesta esperada: \n\nDe: Carlos\nAsunto: Reuni\u00f3n de equipo\nFecha: 24 de febrero de 2025, 10:15 AM\nMensaje: Hola, recuerden que tenemos reuni\u00f3n ma\u00f1ana a las 14:00 PM.\n\n\n--- \n\n**5. Eliminar un correo:** \nUsuario: \"Elimina el correo de Laura sobre el recordatorio de pago.\" \nRespuesta esperada: \nSe ha eliminado el correo correctamente.\n \n\nRecordatorios finales: \nFecha y hora actual: {{ $now }}.\n",
"maxIterations": 10
}
},
"id": "c35bbfca-e46e-48d5-84b7-0b6af2595df2",
"name": "Agente de Email",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.6,
"position": [
-480,
64
],
"onError": "continueErrorOutput"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"frequencyPenalty": 0,
"presencePenalty": 0,
"temperature": 0
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-1184,
480
],
"id": "85188db8-9bb1-4da9-9953-a83c98007ee0",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "39c2f302-03be-4464-a17a-d7cc481d6d44",
"name": "=response",
"value": "={{$json.output}}",
"type": "string"
}
]
},
"options": {}
},
"id": "6f53af25-7b93-459d-a143-09328deb3da8",
"name": "\u2705",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
0,
0
]
},
{
"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": "1044cec4-0713-4402-b671-f8908892e3e1",
"name": "\u274c",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
0,
208
]
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "RespuestaCorreo",
"operation": "reply",
"messageId": {
"__rl": true,
"value": "={{ $fromAI(\"ID\",\"the message ID\") }}",
"mode": "id"
},
"replyToSenderOnly": true,
"message": "={{ $fromAI(\"emailBody\") }}\n\n<div style=\"font-family: Arial, sans-serif; font-size: 14px; color: #1A4672;\">\n <p><strong>Jos\u00e9 Manuel Fern\u00e1ndez</strong><br>\n <em>Ingeniero Inform\u00e1tico Experto en IA</em></p>\n</div>",
"additionalFields": {
"bodyContentType": "html"
},
"options": {}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
-880,
784
],
"id": "c71d43ef-87f6-4452-83a0-38dc09398de5",
"name": "RespuestaCorreo",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "CrearBorrador",
"resource": "draft",
"subject": "={{ $fromAI('Subject') }}",
"bodyContent": "={{ $fromAI(\"emailBody\") }}\n\n<div style=\"font-family: Arial, sans-serif; font-size: 14px; color: #1A4672;\">\n <p><strong>Jos\u00e9 Manuel Fern\u00e1ndez</strong><br>\n <em>Ingeniero Inform\u00e1tico Experto en IA</em></p>\n</div>",
"additionalFields": {
"bodyContentType": "html",
"toRecipients": "={{ $fromAI(\"emailAddress\") }}"
}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
336,
672
],
"id": "27b44ad7-3cd8-402b-a451-1f5899b11822",
"name": "CrearBorrador",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "EliminarCorreo",
"operation": "delete",
"messageId": {
"__rl": true,
"value": "={{ $fromAI(\"ID\",\"the message ID\") }}",
"mode": "id"
}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
-32,
672
],
"id": "743336b1-394b-4772-898f-d75e91c28522",
"name": "EliminarCorreo",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "ModificarCorreo",
"operation": "update",
"messageId": {
"__rl": true,
"value": "={{ $fromAI(\"ID\",\"the message ID\") }}",
"mode": "id"
},
"updateFields": {
"bodyContent": "={{ $fromAI(\"emailBody\") }}",
"toRecipients": "={{ $fromAI('To') }}",
"subject": "={{ $fromAI('Subject') }}"
}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
-224,
672
],
"id": "abe4b036-a334-444b-9c0f-b6141b836fad",
"name": "ModificarCorreo",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "MoverCorreo",
"operation": "move",
"messageId": {
"__rl": true,
"value": "={{ $fromAI(\"ID\",\"the message ID\") }}",
"mode": "id"
},
"folderId": {
"__rl": true,
"value": "={{ $fromAI('Parent_Folder') }}",
"mode": "id"
}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
160,
672
],
"id": "00d2f0cd-b411-42f8-a1f9-b9ed764912cd",
"name": "MoverCorreo",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "EnviarCorreo",
"toRecipients": "={{ $fromAI(\"emailAddress\") }}",
"subject": "={{ $fromAI(\"subject\") }}",
"bodyContent": "={{ $fromAI(\"emailBody\") }}\n\n<div style=\"font-family: Arial, sans-serif; font-size: 14px; color: #1A4672;\">\n <p><strong>Claudio Luna</strong><br>\n <em>Ingeniero Inform\u00e1tico Experto en IA</em></p>\n</div>",
"additionalFields": {
"bodyContentType": "html"
}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
-1072,
752
],
"id": "8a454293-05d3-4fb3-b036-938b290cf22b",
"name": "EnviarCorreoO",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Enviar Correo",
"sendTo": "={{ $fromAI(\"emailAddress\") }}",
"subject": "={{ $fromAI(\"subject\") }}",
"message": "={{ $fromAI(\"emailBody\") }} <div style=\"font-family: Arial, sans-serif; font-size: 14px; color: #1A4672;\"> <p><strong>Claudio Luna</strong><br> <em>Ingeniero Inform\u00e1tico Experto en IA</em></p> </div>",
"options": {}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-928,
480
],
"id": "25bae6d8-896a-4f16-ab52-85fdc76f94ec",
"name": "EnviarCorreo",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Reply to a message in Gmail",
"operation": "reply",
"messageId": "={{ $fromAI(\"ID\",\"the message ID\") }}",
"message": "={{ $fromAI(\"emailBody\") }} <div style=\"font-family: Arial, sans-serif; font-size: 14px; color: #1A4672;\"> <p><strong>Claudio Luna </strong><br> <em>Ingeniero Inform\u00e1tico Experto en IA</em></p> </div>",
"options": {}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-672,
480
],
"id": "a38e631f-4117-44b1-accb-dd2fecf9f0b8",
"name": "RespuestaCorreo1",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "ObtenerCorreos",
"operation": "getAll",
"limit": "={{ $fromAI('Limit', `Cuantos emails quiere el usuario`, 'number') }}",
"output": "fields",
"fields": [
"receivedDateTime",
"from",
"sender",
"subject",
"bodyPreview"
],
"filtersUI": {
"values": {
"filters": {
"receivedAfter": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Received_After', ``, 'string') }}",
"receivedBefore": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Received_Before', ``, 'string') }}",
"sender": "={{ $fromAI(\"sender\",\"Quienes son los remitentes de los correos electr\u00f3nicos.\") }}"
}
}
},
"options": {}
},
"type": "n8n-nodes-base.microsoftOutlookTool",
"typeVersion": 2,
"position": [
336,
448
],
"id": "371e648e-468d-4be7-b72c-f461f6927e2a",
"name": "ObtenerCorreosO",
"disabled": true
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Get many messages in Gmail",
"operation": "getAll",
"limit": "={{ $fromAI('Limit', `Cuantos emails quiere el usuario`, 'number') }}",
"filters": {}
},
"type": "n8n-nodes-base.gmailTool",
"typeVersion": 2.1,
"position": [
-416,
480
],
"id": "b43941d6-b075-4b2e-8aad-36b48d504953",
"name": "ObtenerCorreos",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
}
],
"connections": {
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Agente de Email",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Agente de Email",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Agente de Email": {
"main": [
[
{
"node": "\u2705",
"type": "main",
"index": 0
}
],
[
{
"node": "\u274c",
"type": "main",
"index": 0
}
]
]
},
"RespuestaCorreo": {
"ai_tool": [
[]
]
},
"CrearBorrador": {
"ai_tool": [
[]
]
},
"EliminarCorreo": {
"ai_tool": [
[]
]
},
"ModificarCorreo": {
"ai_tool": [
[]
]
},
"MoverCorreo": {
"ai_tool": [
[]
]
},
"EnviarCorreoO": {
"ai_tool": [
[]
]
},
"EnviarCorreo": {
"ai_tool": [
[
{
"node": "Agente de Email",
"type": "ai_tool",
"index": 0
}
]
]
},
"RespuestaCorreo1": {
"ai_tool": [
[
{
"node": "Agente de Email",
"type": "ai_tool",
"index": 0
}
]
]
},
"ObtenerCorreosO": {
"ai_tool": [
[]
]
},
"ObtenerCorreos": {
"ai_tool": [
[
{
"node": "Agente de Email",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "10541558-219d-4061-91de-dbbce1548926",
"id": "mTDFT7cxuL6SbSDS",
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
3-[Agente-Abogado]-Email. Uses executeWorkflowTrigger, agent, lmChatOpenAi, microsoftOutlookTool. Event-driven trigger; 15 nodes.
Source: https://github.com/aiporvos/chatflow-legal/blob/main/flujos/3-[Agente-Abogado]-Email.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow serves a demo web page with an n8n chat widget and runs an OpenAI-powered support agent that looks up WooCommerce orders and DHL tracking details by calling the same workflow as a tool.
Zoom AI Meeting Assistant. Uses lmChatOpenAi, manualTrigger, stopAndError, zoom. Event-driven trigger; 24 nodes.
I prepared a comprehensive guide detailing how to create a Smart Agent that automates meeting task management by analyzing transcripts, generating tasks in Airtable, and scheduling follow-ups when nec
🤖Email Agent. Uses lmChatOpenAi, agent, gmailTool, executeWorkflowTrigger. Event-driven trigger; 12 nodes.
__Email_Agent. Uses agent, gmailTool, executeWorkflowTrigger, lmChatOpenAi. Event-driven trigger; 12 nodes.