Agente de soporte al cliente con IA

Avanzado

Este es unSupport, AIflujo de automatización del dominio deautomatización que contiene 32 nodos.Utiliza principalmente nodos como Code, Switch, Webhook, HttpRequest, Agent, combinando tecnología de inteligencia artificial para lograr automatización inteligente. Procesamiento automático de soporte al cliente con agentes de IA de Zendesk y documentación de Mintlify

Requisitos previos
  • Punto final de HTTP Webhook (n8n generará automáticamente)
  • Pueden requerirse credenciales de autenticación para la API de destino
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
{
  "id": "YEArXtErE6aQQmka",
  "meta": {
    "instanceId": "c52c57a23340de7df966f9e47d97a3fb8c52621d4c39f6342366d1114449002a",
    "templateCredsSetupCompleted": true
  },
  "name": "AI customer support agent",
  "tags": [],
  "nodes": [
    {
      "id": "79ff2d59-8fac-42cd-a61b-0f87723af80a",
      "name": "Agente de IA",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3256,
        420
      ],
      "parameters": {
        "text": "={{ $json.aiResponse }}",
        "options": {
          "systemMessage": "You are a helpful AI support assistant for <YOUR-DOMAIN>. A customer has asked a question, and relevant information has already been fetched from the documentation.  \nYour task is to:\n\n- Summarize and rephrase the fetched content into a clear and friendly response.  \n- Keep the response within 120 words.  \n- Start the reply with “Hi,\\n”.  \n- End the reply with “Best regards,\\n AI support agent”.  \n- Don't mention any billing, compliance, or sales teams.  \n- Don't offer the customer to contact <YOUR-DOMAIN>.  \n- Keep the tone professional, polite, and supportive. Avoid technical jargon unless necessary.  \n- If the information is partial or the question is unclear, mention it briefly and offer a helpful direction.  \n- If the customer says their proxy is not working, politely ask for more details such as:\n  - Which software or tool they are using  \n  - Whether they can recheck their configuration  \n  - If possible, to share a screenshot of the issue  \n\nOutput your answer as a properly formatted JSON object:\n\n{\n  \"ticket\": {\n    \"comment\": {\n      \"body\": \"Hi,\\n\\n{Response to customer}\\n\\nBest regards,\\nAI support agent\",\n      \"public\": true\n    },\n    \"status\": \"pending\"\n  }\n}\n\nKeep the tone professional, polite, and supportive. Avoid technical jargon unless necessary. If the information is partial or the question is unclear, mention it briefly and offer a helpful direction and escalate to a human support agent."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "1322e147-e25f-476e-9823-1898c5ec0e82",
      "name": "Modelo de chat OpenRouter",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        3344,
        640
      ],
      "parameters": {
        "model": "deepseek/deepseek-r1-distill-llama-70b:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "Occaxdxf05gIKN42",
          "name": "alexanderg-bd"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9769ad77-a395-4251-b45e-aa817482d821",
      "name": "Enrutador de mensajes",
      "type": "n8n-nodes-base.switch",
      "position": [
        1496,
        99
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "billing",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "83dbaa68-8ece-4cd9-b553-e05157c03afd",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "\"category\": \"billing\""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "advertisement",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c4409784-1d61-43c6-8f00-038888fb8853",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "\"category\": \"advertisement\""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "fraud",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cf2b9652-c9a1-4101-b525-46a947de5b3c",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "\"category\": \"fraud\""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "other",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fc49d233-30eb-403e-934f-9f0b59b0836e",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "\"category\": \"other\""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "ccc9a63b-d5ed-460f-be44-0bb62a8439d0",
      "name": "¿Nuevo ticket?",
      "type": "n8n-nodes-base.switch",
      "position": [
        1936,
        420
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "new",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "45668a4b-48c9-48d1-869e-0769701c415d",
                    "operator": {
                      "type": "string",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.topicId }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "existing",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "acc77f71-06a9-444b-a780-9319490ab014",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.topicId }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "1a448d28-8c30-4aaf-b6c2-6c15ac7a1544",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -640,
        120
      ],
      "webhookId": "d5df4915-3245-468d-970f-54e7bf8f4084",
      "parameters": {
        "path": "d5df4915-3245-468d-970f-54e7bf8f4084",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "2db01f51-b260-4dbb-ab88-9745612f774b",
      "name": "Analizar conversación",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        220
      ],
      "parameters": {
        "jsCode": "// Define the agent's author_id (update this to match your system)\nconst supportStaffId = 19780258553884;\n\n// Get the input data (from previous node)\nconst comments = items[0].json.comments;\nconst subject = items[0].json.subject;\nconst ticketId = $('Fetch Zendesk ticket').first().json.ticket.id\n\n// Filter only public comments\nconst publicComments = comments.filter(comment => comment.public === true && comment.type === 'Comment');\n\n// Build the conversation array\nconst conversation = publicComments.map(comment => {\n    return {\n        role: comment.author_id === supportStaffId ? 'support_agent' : 'customer',\n        message: comment.body\n    };\n});\n\n// Return the final structured output\nreturn [\n    {\n        json: {\n            subject: subject,\n            conversation: conversation,\n            ticketId: ticketId\n        }\n    }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "4d7ab1c4-73fc-4894-ab8c-3b27a4e3ec28",
      "name": "Buscar topicId de Mintlify",
      "type": "n8n-nodes-base.code",
      "position": [
        1716,
        420
      ],
      "parameters": {
        "jsCode": "const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\n// Get tags from the Zendesk ticket\nconst tags = $('Fetch Zendesk ticket').first().json.ticket.tags || [];\n\n// Find the first tag that matches the UUID format\nconst topicId = tags.find(tag => uuidRegex.test(tag)) || null;\n\n// Return with new field\nreturn [\n  {\n    json: {\n      ...items[0].json,\n      topicId: topicId\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "70fd61ed-65a2-4d80-b419-c8dac980649c",
      "name": "Agregar topicID de Mintlify al ticket",
      "type": "n8n-nodes-base.code",
      "position": [
        2596,
        320
      ],
      "parameters": {
        "jsCode": "// Get topicId from tags[0] in the other node\nconst topicId = $('Add Mintlify topicId to ticket tags').first().json.tags?.[0] || null;\n\n// Get the current item (from \"Parse conversation\")\nconst item = $('Parse conversation').first().json.conversation\n\n// Extract and simplify the conversation to only include message fields\nconst conversation = (item || []).map(entry => ({\n  message: entry.message\n}));\n\n// Build and return the final output\nreturn [\n  {\n    json: {\n      conversation,\n      topicId\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "059f2573-2a5c-464e-8114-cb08cd7b11b3",
      "name": "Crear tema de chat Mintlify",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2156,
        320
      ],
      "parameters": {
        "url": "https://api-dsc.mintlify.com/v1/chat/topic",
        "method": "POST",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <YOUR-API-KEY>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7b561eb4-add1-43d2-8957-8fe684e257e2",
      "name": "Agregar topicId de Mintlify a etiquetas del ticket",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2376,
        320
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $('Fetch Zendesk ticket').item.json.ticket.id }}/tags",
        "method": "PUT",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "tags",
              "value": "={{ $json.topicId }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d499662f-be7a-4319-bbae-5a5e5477cc54",
      "name": "Eliminar ticket",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1716,
        20
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $('Parse conversation').item.json.ticketId }}",
        "method": "DELETE",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f0d52e9e-034a-452d-81a9-7904d62f6114",
      "name": "Verificar si hay agente humano asignado",
      "type": "n8n-nodes-base.switch",
      "position": [
        -200,
        120
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Don't involve",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3a2d99f6-2c18-4515-9b6b-ea346067b9fe",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ticket.assignee_id }}",
                    "rightValue": 19780258553884
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Involve",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3dd54bce-0b01-43a8-85a8-539937d22670",
                    "operator": {
                      "type": "string",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.ticket.assignee_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "d2ebc6e6-f164-40ee-8910-6a1c3bc85f70",
      "name": "Si hay humano asignado, no responder",
      "type": "n8n-nodes-base.noOp",
      "position": [
        20,
        20
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "439d7ac6-5335-4660-a94f-b4f5f616f335",
      "name": "Modelo de chat OpenRouter1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        3940,
        640
      ],
      "parameters": {
        "model": "deepseek/deepseek-r1-distill-llama-70b:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "Occaxdxf05gIKN42",
          "name": "alexanderg-bd"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d8a6bb45-beaf-41dc-b615-34e58d22f447",
      "name": "Verificar incertidumbre",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3852,
        420
      ],
      "parameters": {
        "text": "={{ $json.ticket.comment.body }}",
        "options": {
          "systemMessage": "You are a classification assistant. Your task is to analyze the support agent's reply and determine whether it expresses uncertainty or lack of confidence.\n\nUncertainty may be indicated by phrases such as:\n- \"I'm not sure\"\n- \"I don't know\"\n- \"Unfortunately, I cannot help\"\n- \"I don't have enough information\"\n- \"You may want to check with someone else\"\n- \"This might not be accurate\"\n- \"Possibly\"\n- \"It could be\"\n- \"The documentation does not provide specific pricing information\"\n\nIf the reply contains any of these or similar expressions, return:\n\n{\n  \"isUncertain\": true\n}\n\nIf the reply is confident, helpful, and provides a clear answer, return:\n\n{\n  \"isUncertain\": false\n}\n\nOnly return the JSON object. Do not include any explanation or additional text."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "78d023f3-71b4-49a4-885a-197862b29c9b",
      "name": "Si hay más de x respuestas, no responder",
      "type": "n8n-nodes-base.noOp",
      "position": [
        900,
        320
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "aad3ff45-fc88-4400-90f2-6a46972da86d",
      "name": "Si es incierto, no responder",
      "type": "n8n-nodes-base.noOp",
      "position": [
        4448,
        320
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ee1525fc-e2b3-4a0f-a5eb-3347e48c0f08",
      "name": "Modelo de chat OpenRouter2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1208,
        340
      ],
      "parameters": {
        "model": "deepseek/deepseek-r1-distill-llama-70b:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "Occaxdxf05gIKN42",
          "name": "alexanderg-bd"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "65e03e7e-e86f-495e-9b2e-04ac4e33a40a",
      "name": "Clasificador de mensajes",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1120,
        120
      ],
      "parameters": {
        "text": "={{ $json.conversation[0].message }}",
        "options": {
          "systemMessage": "You are a classification assistant. Your task is to analyze a customer's message and classify it into one of the following categories:\n\n- billing: The customer is asking about charges, refunds, invoices, payments, crypto transactions, or requesting a custom plan that is not listed on the website. Do not include messages related to plan auto-renewal, switching to a monthly plan, removing a payment method, or how to view receipts.\n- advertisement: The customer is proposing a partnership, collaboration, promotion, review, or business opportunity.\n- fraud: The customer is reporting or discussing issues related to hacking, DDoS attacks, griefing, illegal use, abuse, stealing, spam, bots, reselling, surveys or any suspicious or malicious activity.\n- other: The message does not clearly fit into any of the above categories.\n\nOutput your answer as a properly formatted JSON object:\n\n{\n  \"category\": \"billing\"\n}\n\nOnly return the JSON object. Do not include any explanation or additional text."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "02612319-2fdf-4c2e-801b-8e374baa9ccf",
      "name": "Enrutador de incertidumbre",
      "type": "n8n-nodes-base.switch",
      "position": [
        4228,
        420
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "uncertain",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bc93432b-5015-4dac-beda-68ab221ed4f2",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "true"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "certain",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7d4dc081-6d62-4b9c-9344-15713b21bb30",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "false"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "9b04c360-cb9c-4614-b0ab-15bd936d9243",
      "name": "Sospecha de facturación - escalar",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1716,
        -180
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $('Fetch Zendesk ticket').item.json.ticket.id }}",
        "method": "PUT",
        "options": {},
        "jsonBody": "{\n  \"ticket\": {\n    \"comment\": {\n      \"body\": \"Hi,\\n\\nThis request is related to billing and was forwarded to a human agent. We will return to you as soon as possible.\\n\\nBest regards,\\nAI support agent\",\n      \"public\": true\n    },\n    \"status\": \"open\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8c3bb2e4-76d6-4be9-b1d7-4d1f9738f682",
      "name": "Sospecha de fraude - escalar",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1716,
        220
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $('Fetch Zendesk ticket').item.json.ticket.id }}",
        "method": "PUT",
        "options": {},
        "jsonBody": "{\n  \"ticket\": {\n    \"comment\": {\n      \"body\": \"Hi,\\n\\nYour message appears to involve activity that may violate our Acceptable Use Policy. Please review our guidelines here: https://<YOUR-DOMAIN>.com/legal/acceptable-use-policy.\\n\\nIf you believe this is a mistake or need further clarification, feel free to provide more context.\\n\\nBest regards,\\nAI support agent\",\n      \"public\": true\n    },\n    \"status\": \"pending\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b5292f27-97a5-4e57-a082-6a74f2b31ec0",
      "name": "Respuesta generada por Mintlify (nueva)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2816,
        320
      ],
      "parameters": {
        "url": "https://api-dsc.mintlify.com/v1/chat/message",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "topicId",
              "value": "={{ $('Add Mintlify topicID to ticket').item.json.topicId }}"
            },
            {
              "name": "message",
              "value": "={{ $json.conversation[0].message }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <YOUR-API-KEY>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "X-Mintlify-Base-Url",
              "value": "https://docs.<YOUR-DOMAIN>.com"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c7f53efc-7513-48ba-9ad5-e5a977a181bd",
      "name": "Respuesta generada por Mintlify (existente)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2816,
        520
      ],
      "parameters": {
        "url": "https://api-dsc.mintlify.com/v1/chat/message",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "topicId",
              "value": "={{ $json.topicId }}"
            },
            {
              "name": "message",
              "value": "={{ $('Flip conversation to get the last message').item.json.conversation[0].message }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <YOUR-API-KEY>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "X-Mintlify-Base-Url",
              "value": "https://docs.<YOUR-DOMAIN>.com"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e1aa2510-f473-4e23-8d9e-f36d889c97ff",
      "name": "Contar cuántas veces respondió la IA",
      "type": "n8n-nodes-base.switch",
      "position": [
        680,
        220
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Keep AI",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fb02a796-2f4d-45a7-8c3a-d2bae8bb9964",
                    "operator": {
                      "type": "number",
                      "operation": "lte"
                    },
                    "leftValue": "={{ $json.aiReplyCount }}",
                    "rightValue": 3
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Involve a human agent",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "774acb34-caeb-4596-9404-9d97844708de",
                    "operator": {
                      "type": "number",
                      "operation": "gt"
                    },
                    "leftValue": "={{ $json.aiReplyCount }}",
                    "rightValue": 3
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "9e5a90c0-4a7e-4745-bef2-6f6b8dad3c50",
      "name": "Obtener ticket Zendesk",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -420,
        120
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $json.body.ticket.id }}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1188f26f-3a37-40aa-b6b8-01dede339b39",
      "name": "Obtener conversación del ticket",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        20,
        220
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $json.ticket.id }}/comments",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "63f16b5d-6ca2-40ca-b4c8-4b5a33b2ef1c",
      "name": "Contar respuestas de IA",
      "type": "n8n-nodes-base.code",
      "position": [
        460,
        220
      ],
      "parameters": {
        "jsCode": "// Get the conversation array from the first input item\nconst conversation = $input.first().json.conversation || [];\n\n// Count how many messages are from support_agent\nconst supportAgentReplyCount = conversation.filter(msg => msg.role === 'support_agent').length;\n\n// Return the count\nreturn [\n  {\n    json: {\n      aiReplyCount: supportAgentReplyCount\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "ced12732-e0ba-4787-a8ea-0b5673567f80",
      "name": "Invertir conversación para obtener último mensaje",
      "type": "n8n-nodes-base.code",
      "position": [
        900,
        120
      ],
      "parameters": {
        "jsCode": "// Get the first item from input\nconst item = $input.first();\n\n// Reverse the conversation array\nconst reversedConversation = $('Parse conversation').first().json.conversation.reverse();\n\n// Return the modified object\nreturn [\n  {\n    json: {\n      conversation: reversedConversation,\n      ticketId: item.json.ticketId\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "c7994f00-1ef5-4c40-abff-c277d4fa0047",
      "name": "Analizar respuesta de Mintlify",
      "type": "n8n-nodes-base.code",
      "position": [
        3036,
        420
      ],
      "parameters": {
        "jsCode": "const response = $input.first().json.data\nconst [answer, citationsRaw] = response.split('||');\nconst citations = citationsRaw ? JSON.parse(citationsRaw) : [];\n\nlet final = answer;\nif (citations.length > 0) {\n  final += '\\n\\n📚 Related Docs:\\n';\n  citations.forEach((c, i) => {\n    final += `${i + 1}. [${c.metadata.title}](https://docs.<YOUR-DOMAIN>.com${c.link})\\n`;\n  });\n}\n\nreturn {\n  aiResponse: answer,\n  citations,\n  finalResponse: final\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "bd74c61c-eea7-480e-ab1d-a84fa564fbaa",
      "name": "Analizar respuesta de IA",
      "type": "n8n-nodes-base.code",
      "position": [
        3632,
        420
      ],
      "parameters": {
        "jsCode": "// Get the raw output string\nconst rawOutput = $input.first().json.output;\n\n// Try to extract only the JSON part using a regex\nconst jsonMatch = rawOutput.match(/\\{[\\s\\S]*\\}/);\n\n// If no match found, throw an error\nif (!jsonMatch) {\n  throw new Error('No valid JSON object found in the string.');\n}\n\n// Parse the matched JSON string\nconst parsed = JSON.parse(jsonMatch[0]);\n\n// Ensure it's a plain object\nif (typeof parsed !== 'object' || Array.isArray(parsed)) {\n  throw new Error('Parsed JSON must be a plain object');\n}\n\n// Return parsed object\nreturn [\n  {\n    json: parsed\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "ad38d9c9-d7c4-4ef1-bcc4-3547dc0eef21",
      "name": "Responder ticket y poner en pendiente",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4448,
        520
      ],
      "parameters": {
        "url": "=https://<YOUR-DOMAIN>.zendesk.com/api/v2/tickets/{{ $('Fetch Zendesk ticket').item.json.ticket.id }}",
        "method": "PUT",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "jsonBody": "={{ JSON.stringify($('Parse AI response').item.json) }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "zendeskApi"
      },
      "credentials": {
        "zendeskApi": {
          "id": "QWXVjGSazzYgVhxw",
          "name": "Zendesk"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "08338dd4-507c-4c74-b594-91d11c418a51",
  "connections": {
    "1a448d28-8c30-4aaf-b6c2-6c15ac7a1544": {
      "main": [
        [
          {
            "node": "9e5a90c0-4a7e-4745-bef2-6f6b8dad3c50",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "79ff2d59-8fac-42cd-a61b-0f87723af80a": {
      "main": [
        [
          {
            "node": "bd74c61c-eea7-480e-ab1d-a84fa564fbaa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ccc9a63b-d5ed-460f-be44-0bb62a8439d0": {
      "main": [
        [
          {
            "node": "059f2573-2a5c-464e-8114-cb08cd7b11b3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "c7f53efc-7513-48ba-9ad5-e5a977a181bd",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d499662f-be7a-4319-bbae-5a5e5477cc54": {
      "main": [
        []
      ]
    },
    "9769ad77-a395-4251-b45e-aa817482d821": {
      "main": [
        [
          {
            "node": "9b04c360-cb9c-4614-b0ab-15bd936d9243",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d499662f-be7a-4319-bbae-5a5e5477cc54",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "8c3bb2e4-76d6-4be9-b1d7-4d1f9738f682",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "4d7ab1c4-73fc-4894-ab8c-3b27a4e3ec28",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "63f16b5d-6ca2-40ca-b4c8-4b5a33b2ef1c": {
      "main": [
        [
          {
            "node": "e1aa2510-f473-4e23-8d9e-f36d889c97ff",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d8a6bb45-beaf-41dc-b615-34e58d22f447": {
      "main": [
        [
          {
            "node": "02612319-2fdf-4c2e-801b-8e374baa9ccf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bd74c61c-eea7-480e-ab1d-a84fa564fbaa": {
      "main": [
        [
          {
            "node": "d8a6bb45-beaf-41dc-b615-34e58d22f447",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "65e03e7e-e86f-495e-9b2e-04ac4e33a40a": {
      "main": [
        [
          {
            "node": "9769ad77-a395-4251-b45e-aa817482d821",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2db01f51-b260-4dbb-ab88-9745612f774b": {
      "main": [
        [
          {
            "node": "63f16b5d-6ca2-40ca-b4c8-4b5a33b2ef1c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "02612319-2fdf-4c2e-801b-8e374baa9ccf": {
      "main": [
        [
          {
            "node": "aad3ff45-fc88-4400-90f2-6a46972da86d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ad38d9c9-d7c4-4ef1-bcc4-3547dc0eef21",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9e5a90c0-4a7e-4745-bef2-6f6b8dad3c50": {
      "main": [
        [
          {
            "node": "f0d52e9e-034a-452d-81a9-7904d62f6114",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1322e147-e25f-476e-9823-1898c5ec0e82": {
      "ai_languageModel": [
        [
          {
            "node": "79ff2d59-8fac-42cd-a61b-0f87723af80a",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "439d7ac6-5335-4660-a94f-b4f5f616f335": {
      "ai_languageModel": [
        [
          {
            "node": "d8a6bb45-beaf-41dc-b615-34e58d22f447",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "ee1525fc-e2b3-4a0f-a5eb-3347e48c0f08": {
      "ai_languageModel": [
        [
          {
            "node": "65e03e7e-e86f-495e-9b2e-04ac4e33a40a",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "c7994f00-1ef5-4c40-abff-c277d4fa0047": {
      "main": [
        [
          {
            "node": "79ff2d59-8fac-42cd-a61b-0f87723af80a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1188f26f-3a37-40aa-b6b8-01dede339b39": {
      "main": [
        [
          {
            "node": "2db01f51-b260-4dbb-ab88-9745612f774b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4d7ab1c4-73fc-4894-ab8c-3b27a4e3ec28": {
      "main": [
        [
          {
            "node": "ccc9a63b-d5ed-460f-be44-0bb62a8439d0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "059f2573-2a5c-464e-8114-cb08cd7b11b3": {
      "main": [
        [
          {
            "node": "7b561eb4-add1-43d2-8957-8fe684e257e2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "70fd61ed-65a2-4d80-b419-c8dac980649c": {
      "main": [
        [
          {
            "node": "b5292f27-97a5-4e57-a082-6a74f2b31ec0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f0d52e9e-034a-452d-81a9-7904d62f6114": {
      "main": [
        [
          {
            "node": "d2ebc6e6-f164-40ee-8910-6a1c3bc85f70",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "1188f26f-3a37-40aa-b6b8-01dede339b39",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b5292f27-97a5-4e57-a082-6a74f2b31ec0": {
      "main": [
        [
          {
            "node": "c7994f00-1ef5-4c40-abff-c277d4fa0047",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7b561eb4-add1-43d2-8957-8fe684e257e2": {
      "main": [
        [
          {
            "node": "70fd61ed-65a2-4d80-b419-c8dac980649c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e1aa2510-f473-4e23-8d9e-f36d889c97ff": {
      "main": [
        [
          {
            "node": "ced12732-e0ba-4787-a8ea-0b5673567f80",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "78d023f3-71b4-49a4-885a-197862b29c9b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c7f53efc-7513-48ba-9ad5-e5a977a181bd": {
      "main": [
        [
          {
            "node": "c7994f00-1ef5-4c40-abff-c277d4fa0047",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ced12732-e0ba-4787-a8ea-0b5673567f80": {
      "main": [
        [
          {
            "node": "65e03e7e-e86f-495e-9b2e-04ac4e33a40a",
            "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 - Soporte, Inteligencia Artificial

¿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 nodos32
Categoría2
Tipos de nodos7
Descripción de la dificultad

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

Autor
Alex Gurinovich

Alex Gurinovich

@alexg

Project Manager with a Computer Science background and extensive experience in QA and NOC. Passionate about driving innovation, streamlining processes, and leading projects and ideas to success.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34