Mi flujo de trabajo 5

Avanzado

Este es unautomatización que contiene 19 nodos.Utiliza principalmente nodos como Code, Merge, Airtable, HttpRequest, ManualTrigger. Analizar el rendimiento de correos y optimizar campañas de marketing con GPT-4, SendGrid y Airtable

Requisitos previos
  • Clave de API de Airtable
  • Pueden requerirse credenciales de autenticación para la API de destino
  • Clave de API de OpenAI

Categoría

-
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "42b2652ebb0a87755df4710a5630695eec8e35cb0ce04a63b0e25751b1f044f1"
  },
  "name": "My workflow 5",
  "tags": [],
  "nodes": [
    {
      "id": "05a392cc-4f92-4716-8738-6a0fbd45e3ed",
      "name": "Al hacer clic en 'Ejecutar flujo de trabajo'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -16,
        384
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1da7c095-0587-46fa-ae74-558f9cf7d0e1",
      "name": "Sendgrid Data Pull",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        176,
        496
      ],
      "parameters": {
        "url": "https://api.sendgrid.com/v3/stats",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "start_date",
              "value": "={{ $now.minus(7, 'days').format('yyyy-MM-dd') }}"
            },
            {
              "name": "end_date",
              "value": "={{ $now.format('yyyy-MM-dd') }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "KB5CcNJcpZPU6DRn",
          "name": "Sendgrid"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "abeda94c-de1e-492d-b63a-ad01ad1f7ab2",
      "name": "Actualizar registro",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1024,
        464
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apptBBudqpCku19Sw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw",
          "cachedResultName": "Untitled Base"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tbl2nb9vURHJVghpw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw/tbl2nb9vURHJVghpw",
          "cachedResultName": "Email Campaign Performance"
        },
        "columns": {
          "value": {
            "id": "={{ $json.id }}",
            "ctr": "={{ $json.ctr }}",
            "delivered": "={{ $json.delivered }}",
            "open_rate": "={{ $json.open_rate }}",
            "week_ending": "={{ $json.week_ending }}",
            "unique_opens": "={{ $json.unique_opens }}",
            "unique_clicks": "={{ $json.unique_clicks }}",
            "performance_delta": 0
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "week_ending",
              "type": "dateTime",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "week_ending",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "delivered",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "delivered",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "unique_opens",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "unique_opens",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "unique_clicks",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "unique_clicks",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "open_rate",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "open_rate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ctr",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "ctr",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt_version",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "prompt_version",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "changes_made",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "changes_made",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "subject_line_used",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "subject_line_used",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_template_used",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "email_template_used",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "performance_delta",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "performance_delta",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "decision",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "decision",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "typecast": true
        },
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "77pJURtbEjVETtBQ",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "eaacc354-b476-42e1-aae1-49bdffa6e87c",
      "name": "Buscar registros",
      "type": "n8n-nodes-base.airtable",
      "position": [
        400,
        608
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apptBBudqpCku19Sw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw",
          "cachedResultName": "Untitled Base"
        },
        "sort": {
          "property": [
            {
              "field": "week_ending",
              "direction": "desc"
            }
          ]
        },
        "limit": 1,
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tbl2nb9vURHJVghpw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw/tbl2nb9vURHJVghpw",
          "cachedResultName": "Email Campaign Performance"
        },
        "options": {},
        "operation": "search",
        "returnAll": false
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "77pJURtbEjVETtBQ",
          "name": "Airtable Personal Access Token account"
        }
      },
      "executeOnce": false,
      "typeVersion": 2.1
    },
    {
      "id": "6af1e213-6695-4fad-98f9-a1be2db331fb",
      "name": "Fusionar",
      "type": "n8n-nodes-base.merge",
      "position": [
        720,
        464
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "aadc8253-4066-472a-9cbd-92ab2cb07a74",
      "name": "Buscar registros1",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1168,
        464
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apptBBudqpCku19Sw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw",
          "cachedResultName": "Untitled Base"
        },
        "limit": 4,
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tbl2nb9vURHJVghpw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw/tbl2nb9vURHJVghpw",
          "cachedResultName": "Email Campaign Performance"
        },
        "options": {},
        "operation": "search",
        "returnAll": false
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "77pJURtbEjVETtBQ",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "da85d884-583f-46e1-aab0-fc2fbf44311f",
      "name": "Crear un registro",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1856,
        464
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "apptBBudqpCku19Sw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw",
          "cachedResultName": "Untitled Base"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tbl2nb9vURHJVghpw",
          "cachedResultUrl": "https://airtable.com/apptBBudqpCku19Sw/tbl2nb9vURHJVghpw",
          "cachedResultName": "Email Campaign Performance"
        },
        "columns": {
          "value": {
            "ctr": 0,
            "decision": "={{ $json.decision }}",
            "delivered": 0,
            "open_rate": 0,
            "week_ending": "={{ $json.week_ending }}",
            "unique_opens": 0,
            "unique_clicks": 0,
            "test_directive": "={{ $json.test_directive }}",
            "test_variable ": "={{ $json.test_variable }}",
            "confidence_level": "={{ $json.confidence_level }}",
            "test_hypothesis ": "={{ $json.test_hypothesis }}",
            "performance_delta": 0,
            "implementation_instruction": "={{ $json.implementation_instruction }}"
          },
          "schema": [
            {
              "id": "week_ending",
              "type": "dateTime",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "week_ending",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "delivered",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "delivered",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "unique_opens",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "unique_opens",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "unique_clicks",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "unique_clicks",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "open_rate",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "open_rate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ctr",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "ctr",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt_version",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "prompt_version",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "changes_made",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "changes_made",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "subject_line_used",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "subject_line_used",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_body",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "email_body",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "performance_delta",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "performance_delta",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "decision",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "decision",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "icp ",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "icp ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "test_variable ",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "test_variable ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "test_hypothesis ",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "test_hypothesis ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "confidence_level",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "confidence_level",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "use_case ",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "use_case ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "test_directive",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "test_directive",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "implementation_instruction",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "implementation_instruction",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "typecast": true
        },
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "77pJURtbEjVETtBQ",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "90478127-979e-4a99-ae48-9bcd15ad54fe",
      "name": "Nota adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        304
      ],
      "parameters": {
        "width": 1184,
        "height": 496,
        "content": "## Update Previous Week's Data\n"
      },
      "typeVersion": 1
    },
    {
      "id": "73a3a0e3-582d-4916-90b9-dbf3a6ee5f78",
      "name": "Nota adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        304
      ],
      "parameters": {
        "width": 528,
        "height": 496,
        "content": "## Previous week analysis"
      },
      "typeVersion": 1
    },
    {
      "id": "8c5c2ab1-d5ed-4282-89f2-a336fff022ad",
      "name": "Nota adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        304
      ],
      "parameters": {
        "width": 448,
        "height": 496,
        "content": "## Testing instructions for coming week"
      },
      "typeVersion": 1
    },
    {
      "id": "46c405d5-e363-42d7-b166-1948d5bbf45c",
      "name": "Nota adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        -96
      ],
      "parameters": {
        "width": 1184,
        "height": 384,
        "content": "## Prompt Injection\n**<!-- EMAIL OPTIMIZATION GUIDANCE - START -->\n\n## Performance Intelligence from Previous Campaigns\n\nAnother AI agent has analyzed your recent email performance data and identified opportunities for improvement. Consider these data-driven insights while crafting your email:\n\n**Previous Performance:**\n{{ $json.baseline_performance }}\n\n**Key Finding:**\n{{ $json.analysis }}\n\n**Recommended Test:**\n- **What to change:** {{ $json.test_variable }}\n- **How to change it:** {{ $json.test_directive }}\n- **Specific instruction:** {{ $json.implementation_instruction }}\n- **Expected outcome:** {{ $json.test_hypothesis }}\n- **Confidence level:** {{ $json.confidence_level }}\n- **Target metric:** Improve {{ $json.success_metric }} by {{ $json.target_improvement }}\n\n⚠️ **Important:** You maintain creative control. These are data-informed suggestions based on what hasn't worked and what we believe will work better. Use your judgment to incorporate these insights while ensuring the email remains authentic and aligned with the brand voice.\n\n## Required Output Format\n\nYour response MUST include these specific fields in your output (in addition to any other content you generate):\n\n```json\n{\n  \"subject_line_used\": \"[The exact subject line you created]\",\n  \"email_body\": \"[The complete email body text you created]\",\n  \"icp\": \"[Target audience/Ideal Customer Profile for this email]\",\n  \"use_case\": \"[Primary use case or problem this email addresses]\"\n}\n```\n\n<!-- EMAIL OPTIMIZATION GUIDANCE - END -->"
      },
      "typeVersion": 1
    },
    {
      "id": "479113e4-e753-40b1-ae8d-d72d7e7cda62",
      "name": "Nota adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        -96
      ],
      "parameters": {
        "width": 448,
        "height": 384,
        "content": "## INTEGRATION INSTRUCTIONS\n\n**Copy and paste the optimization prompt below directly into your email generation prompt as a standalone section.**\n\n### Setup Requirements:\n1. **Before your email node:** Add \"Get Record\" to retrieve the most recent week's recommendations\n2. **After your email node:** Add \"Update Record\" to save what was actually sent\n3. **Use the provided \"Most Recent Week\" code** to identify the correct row for both operations\n4. **Connect to Airtable:** Map the JSON fields to the provided Airtable template\n\nOnce configured, the system runs autonomously—analyzing performance and optimizing future emails automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "5ca4055b-256d-423d-8a69-51ce35a0bb8b",
      "name": "Pull Most Recent Week",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        608
      ],
      "parameters": {
        "jsCode": "// Get the record from Airtable List\nconst record = $input.all()[0].json;\n\nreturn [{\n  json: {\n    id: record.id\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "fef40f34-74c2-440d-a36a-741184d8c98c",
      "name": "Data X-Form",
      "type": "n8n-nodes-base.code",
      "position": [
        400,
        448
      ],
      "parameters": {
        "jsCode": "// Get ALL items (each day is a separate item)\nconst allDays = $input.all();\nlet delivered = 0;\nlet unique_opens = 0;\nlet unique_clicks = 0;\n\n// Loop through each day (each item)\nallDays.forEach(item => {\n  const day = item.json;\n  delivered += day.stats[0].metrics.delivered;\n  unique_opens += day.stats[0].metrics.unique_opens;\n  unique_clicks += day.stats[0].metrics.unique_clicks;\n});\n\n// Calculate rates from totals\nconst open_rate = delivered > 0 ? unique_opens / delivered : 0;\nconst ctr = delivered > 0 ? unique_clicks / delivered : 0;\n\nreturn [{\n  json: {\n    week_ending: new Date().toISOString(),  // ← Changed this line\n    delivered: delivered,\n    unique_opens: unique_opens,\n    unique_clicks: unique_clicks,\n    open_rate: open_rate,\n    ctr: ctr\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "cba63111-b8a7-43b1-91cd-72aab8d0af6b",
      "name": "Data Fusionar",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        464
      ],
      "parameters": {
        "jsCode": "// Just combine the objects cleanly\nconst stats = $input.all()[0].json;\nconst recordInfo = $input.all()[1].json;\n\nreturn [{\n  json: {\n    id: recordInfo.id,\n    ...stats  // Spread all stats fields\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7c91372e-74d2-46e3-a40a-85afb327a797",
      "name": "Previous Week Analysis",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1296,
        464
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are an email optimization specialist analyzing historical performance patterns.\n\nPerformance data (last 4 weeks):\n{{ JSON.stringify($input.all().map(item => item.json), null, 2) }}\n\nIMPORTANT: Analyze ALL weeks for context, but base your recommendation on the MOST RECENT week's performance (the first record in the array).\n\nIMPORTANT: Each recipient only sees our email ONCE. Declining performance means our message is becoming less relevant to NEW recipients, not that people are tired of seeing it.\n\nAnalyze trends to identify ONE element to test based on the most recent week:\n- Most recent week performance is your PRIMARY focus\n- Use previous weeks for trend context only\n- Declining open rates = Subject line losing relevance to current market context/needs\n- Declining CTR = Value prop or CTA not resonating with current audience priorities  \n- Stable low metrics = Fundamental mismatch with audience expectations\n- Week-to-week variance = Inconsistent targeting or timing\n\nConsider:\n- Seasonal/temporal relevance (what's top of mind NOW?)\n- Market shifts (new competitors, trends, problems emerging)\n- Audience evolution (are we reaching different segments?)\n\nOutput a SINGLE test variable that adapts to CURRENT market conditions.\n\nFormat your response as JSON:\n{\n  \"analysis\": \"Open rates fell 15% over 3 weeks - subject line may not reflect current audience priorities\",\n  \"decision\": \"test_subject_line\",\n  \"test_variable\": \"subject_line_relevance\",\n  \"test_hypothesis\": \"Addressing current market concerns will increase relevance and open rates\",\n  \"confidence_level\": \"high\",\n  \"test_directive\": \"Reference current/timely pain point\",\n  \"implementation_instruction\": \"IMPORTANT: Frame the subject line around a problem or opportunity that's particularly relevant RIGHT NOW in your industry, not timeless benefits\",\n  \"baseline_performance\": \"12% open rate, 1.5% CTR\",\n  \"success_metric\": \"open_rate\",\n  \"target_improvement\": \"15%\"\n}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "oge162MIvDKTkyvR",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "0b834d38-c9e2-46f3-b7f2-615bce2dfab4",
      "name": "Parse Output",
      "type": "n8n-nodes-base.code",
      "position": [
        1568,
        464
      ],
      "parameters": {
        "jsCode": "// Get the GPT response (should be just one item now)\nconst gptResponse = $input.first().json;\n\n// Parse the JSON content from the message\nconst analysis = JSON.parse(gptResponse.message.content);\n\n// Get the most recent week_ending from your previous data\n// This assumes you have access to the original data from Search records1\n// You may need to pass this through from an earlier node\nconst previousData = $('Search records1').first().json;\nconst lastWeekEnding = previousData.week_ending;\n\n// Calculate next week's date (7 days after the most recent week_ending)\nconst nextWeekDate = new Date(lastWeekEnding);\nnextWeekDate.setDate(nextWeekDate.getDate() + 7);\n\n// Format the date as full ISO string for Airtable\nconst weekEnding = nextWeekDate.toISOString();\n\n// Return formatted data for Airtable\nreturn [{\n  json: {\n    week_ending: weekEnding,\n    decision: analysis.decision,\n    test_variable: analysis.test_variable,\n    test_hypothesis: analysis.test_hypothesis,\n    confidence_level: analysis.confidence_level,\n    test_directive: analysis.test_directive,\n    implementation_instruction: analysis.implementation_instruction,\n    baseline_performance: analysis.baseline_performance,\n    success_metric: analysis.success_metric,\n    target_improvement: analysis.target_improvement,\n    analysis: analysis.analysis,\n    // Initialize performance metrics as 0 for the upcoming week\n    delivered: 0,\n    unique_opens: 0,\n    unique_clicks: 0,\n    open_rate: 0,\n    ctr: 0,\n    performance_delta: 0\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "dbe1a199-7f8b-4c69-b6e4-9152d3119b48",
      "name": "Nota adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -96
      ],
      "parameters": {
        "width": 528,
        "height": 384,
        "content": "## PURPOSE\n\nThis flow functions as a true agentic, drag-and-drop extension that continuously improves any automated email campaign. Simply add the Airtable template, connect it to your email sending node, and link the remaining components. The system automatically analyzes previous weeks' performance data, evaluates results, and updates future strategies based on past decisions—constantly optimizing toward better email engagement. \n\n**Requirements:** SendGrid or similar email service provider (ESP) for tracking metrics."
      },
      "typeVersion": 1
    },
    {
      "id": "17f731d5-650e-432d-8691-a1c1e28e4e5f",
      "name": "Disparador programado",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -16,
        640
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Data Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Merge": {
      "main": [
        [
          {
            "node": "abeda94c-de1e-492d-b63a-ad01ad1f7ab2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fef40f34-74c2-440d-a36a-741184d8c98c": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0b834d38-c9e2-46f3-b7f2-615bce2dfab4": {
      "main": [
        [
          {
            "node": "da85d884-583f-46e1-aab0-fc2fbf44311f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "abeda94c-de1e-492d-b63a-ad01ad1f7ab2": {
      "main": [
        [
          {
            "node": "aadc8253-4066-472a-9cbd-92ab2cb07a74",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "eaacc354-b476-42e1-aae1-49bdffa6e87c": {
      "main": [
        [
          {
            "node": "5ca4055b-256d-423d-8a69-51ce35a0bb8b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "aadc8253-4066-472a-9cbd-92ab2cb07a74": {
      "main": [
        [
          {
            "node": "7c91372e-74d2-46e3-a40a-85afb327a797",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "1da7c095-0587-46fa-ae74-558f9cf7d0e1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1da7c095-0587-46fa-ae74-558f9cf7d0e1": {
      "main": [
        [
          {
            "node": "fef40f34-74c2-440d-a36a-741184d8c98c",
            "type": "main",
            "index": 0
          },
          {
            "node": "eaacc354-b476-42e1-aae1-49bdffa6e87c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5ca4055b-256d-423d-8a69-51ce35a0bb8b": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "7c91372e-74d2-46e3-a40a-85afb327a797": {
      "main": [
        [
          {
            "node": "0b834d38-c9e2-46f3-b7f2-615bce2dfab4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "05a392cc-4f92-4716-8738-6a0fbd45e3ed": {
      "main": [
        [
          {
            "node": "1da7c095-0587-46fa-ae74-558f9cf7d0e1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos19
Categoría-
Tipos de nodos8
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34