{ "id": "dsKnCFwysROIA4MT", "meta": { "instanceId": "workflow-6f173cdd", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:46.265839", "updatedAt": "2025-09-29T07:07:46.265854", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production" }, "name": "Agent with custom HTTP Request", "tags": [ "automation", "n8n", "production-ready", "excellent", "optimized" ], "nodes": [ { "id": "e7374976-f3c1-4f60-ae57-9eec65444216", "name": "On new manual Chat Message", "type": "n8n-nodes-base.noOp", "position": [ 763, 676 ], "parameters": {}, "typeVersion": 1, "notes": "This manualChatTrigger node performs automated tasks as part of the workflow." }, { "id": "97e84a23-9536-43cd-94e9-b8166be8ed32", "name": "OpenAI Chat Model", "type": "n8n-nodes-base.noOp", "position": [ 983, 896 ], "parameters": { "model": "gpt-4-1106-preview", "options": { "timeout": 300000, "temperature": 0.7, "frequencyPenalty": 0.3 } }, "credentials": { "openAiApi": { "id": "wPFAzp4ZHdLLwvkK", "name": "OpenAi account" } }, "typeVersion": 1, "notes": "This lmChatOpenAi node performs automated tasks as part of the workflow." }, { "id": "63d98361-8978-4042-84e7-53a0e226f946", "name": "HTTP Request", "type": "n8n-nodes-base.httpRequest", "onError": "continueRegularOutput", "position": [ 1360, 1200 ], "parameters": { "url": "{{ $env.BASE_URL }}", "options": { "response": { "response": { "neverError": true } }, "allowUnauthorizedCerts": true } }, "typeVersion": 4.1, "alwaysOutputData": false, "notes": "This httpRequest node performs automated tasks as part of the workflow." }, { "id": "17d4b5ae-f5d3-4793-8419-d3c879f7f50d", "name": "Exctract HTML Body", "type": "n8n-nodes-base.set", "position": [ 1780, 1480 ], "parameters": { "fields": { "values": [ { "name": "HTML", "stringValue": "={{ $json?.data.match(/]*>([\\s\\S]*?)<\\/body>/i)[1] }}" } ] }, "include": "selected", "options": {}, "includeFields": "HTML" }, "typeVersion": 3.2, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "36c38ee4-724c-4ba2-a59a-ac0bbc912e94", "name": "Is error?", "type": "n8n-nodes-base.if", "position": [ 1560, 1200 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{ $json.hasOwnProperty('error') }}", "value2": true } ] } }, "typeVersion": 1, "notes": "This if node performs automated tasks as part of the workflow." }, { "id": "4e4d97ce-14a9-4f4f-aa75-f218784d9ed9", "name": "Stringify error message", "type": "n8n-nodes-base.set", "position": [ 1780, 980 ], "parameters": { "fields": { "values": [ { "name": "page_content", "stringValue": "={{ $('QUERY_PARAMS').first()?.json?.query?.url == null ? \"INVALID action_input. This should be an HTTP query string like this: \\\"?url=VALIDURL&method=SELECTEDMETHOD\\\". Only a simple string value is accepted. JSON object as an action_input is NOT supported!\" : JSON.stringify($json.error) }}" } ] }, "include": "selected", "options": {}, "includeFields": "HTML" }, "typeVersion": 3.2, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "8452e5c4-aa29-4a02-9579-8d9da3727bcb", "name": "Execute Workflow Trigger", "type": "n8n-nodes-base.executeWorkflowTrigger", "position": [ 760, 1200 ], "parameters": {}, "typeVersion": 1, "notes": "This executeWorkflowTrigger node performs automated tasks as part of the workflow." }, { "id": "063220c2-fa4d-4d5e-9549-7712aaa72921", "name": "Remove extra tags", "type": "n8n-nodes-base.set", "position": [ 1980, 1480 ], "parameters": { "fields": { "values": [ { "name": "HTML", "stringValue": "={{ ($json.HTML || \"HTML BODY CONTENT FOR THIS SEARCH RESULT IS NOT AVAILABLE\").replace(/]*>([\\s\\S]*?)<\\/script>|]*>([\\s\\S]*?)<\\/style>|]*>([\\s\\S]*?)<\\/noscript>||]*>([\\s\\S]*?)<\\/iframe>|]*>([\\s\\S]*?)<\\/object>|]*>([\\s\\S]*?)<\\/embed>|]*>([\\s\\S]*?)<\\/video>|]*>([\\s\\S]*?)<\\/audio>|]*>([\\s\\S]*?)<\\/svg>/ig, '')}}" } ] }, "options": {} }, "typeVersion": 3.2, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "036511d7-a4be-4bbf-b4bc-47ddfabfe76f", "name": "Simplify output", "type": "n8n-nodes-base.set", "notes": "remove links and image URLs", "position": [ 2360, 1380 ], "parameters": { "fields": { "values": [ { "name": "HTML", "stringValue": "={{ $json.HTML.replace(/href\\s*=\\s*\"(.+?)\"/gi, 'href=\"NOURL\"').replace(/src\\s*=\\s*\"(.+?)\"/gi, 'src=\"NOIMG\"')}}" } ] }, "options": {} }, "notesInFlow": true, "typeVersion": 3.2 }, { "id": "5e2b5383-adcf-4de0-a406-4f5d631b5e8a", "name": "Simplify?", "type": "n8n-nodes-base.if", "position": [ 2180, 1480 ], "parameters": { "conditions": { "string": [ { "value1": "={{ $('CONFIG').first()?.json?.query?.method }}", "value2": "simplif", "operation": "contains" } ] } }, "typeVersion": 1, "notes": "This if node performs automated tasks as part of the workflow." }, { "id": "a0fc004a-ab0f-4b31-94df-50f5eee69c86", "name": "QUERY_PARAMS", "type": "n8n-nodes-base.set", "position": [ 960, 1200 ], "parameters": { "fields": { "values": [ { "name": "query", "type": "objectValue", "objectValue": "={{ $json.query.substring($json.query.indexOf('?') + 1).split('&').reduce((result, item) => (result[item.split('=')[0]] = decodeURIComponent(item.split('=')[1]), result), {}) }}" } ] }, "options": {} }, "typeVersion": 3.2, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "3b6599d6-ce9a-4861-9b52-07156eb52539", "name": "CONFIG", "type": "n8n-nodes-base.set", "position": [ 1160, 1200 ], "parameters": { "fields": { "values": [ { "name": "query.maxlimit", "type": "numberValue", "numberValue": "={{ $json?.query?.maxlimit == null ? 70000 : Number($json?.query?.maxlimit) }}" } ] }, "options": {} }, "typeVersion": 3.2, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "14f683be-76f6-4034-9a0e-d785738b135f", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [ 721, 1134 ], "parameters": { "width": 556.25, "height": 235.79999999999995, "content": "### Convert the query string into JSON, apply the limit for a page length" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "6deabcb7-a984-48ec-af2a-8c70b3a4e4bf", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [ 1720, 840 ], "parameters": { "width": 491, "height": 285.7, "content": "## Send an error message:\n1. If query param was incorrect, return the instruction. AI Agent should pick up on this and adapt the query on the next iteration.\n2. If the query is OK and an error was during the HTTP Request, then send back the original error message." }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "df1e8d00-0e18-44fa-8f94-8a53c27f7c88", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [ 1720, 1160 ], "parameters": { "width": 1200, "height": 472.5, "content": "## Post-processing of the HTML page:\n1. Keep only content\n2. Remove inline