AutomationFlowsWeb Scraping › Ai-powered Reasoning and Response Workflow

Ai-powered Reasoning and Response Workflow

ByMauricio Perera @rckflr on n8n.io

This workflow is designed to handle user inputs via a webhook, process the inputs with the Google Gemini API (specifically the gemini-2.0-flash-thinking-exp-1219 model), and return a structured response to the user. The response includes three key elements: reasoning, the final…

Webhook trigger★★★★☆ complexity8 nodesHTTP Request
Web Scraping Trigger: Webhook Nodes: 8 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #2680 — we link there as the canonical source.

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 →

Download .json
{
  "id": "0tZbdRF64nAiQHSF",
  "tags": [],
  "nodes": [
    {
      "id": "92d4affa-acbe-4114-a8f7-3ff2ba472061",
      "name": "Send Request to Google Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3720,
        -140
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-thinking-exp-1219:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"text\": \"{{ $json.query.input }}\"\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"temperature\": 1,\n    \"topK\": 64,\n    \"topP\": 0.95,\n    \"maxOutputTokens\": 8192,\n    \"responseMimeType\": \"text/plain\"\n  }\n} ",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e2550819-5719-4ba2-8844-71f3bdfb8f6a",
      "name": "Return Response to User",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        4500,
        -140
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={{ $json.response }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "51d3c73c-9077-4d22-9a3e-e14a460b9c3e",
      "name": "Receive User Input",
      "type": "n8n-nodes-base.webhook",
      "position": [
        3340,
        -140
      ],
      "parameters": {
        "path": "b767b67a-9fab-4f73-97f8-b17a55b8d2be",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "e8c643fc-c07a-4b38-a6eb-b6c8c60e09d5",
      "name": "Process API Response",
      "type": "n8n-nodes-base.code",
      "position": [
        4100,
        -140
      ],
      "parameters": {
        "jsCode": "// Retrieve all input data from the previous node\nconst items = $input.all();\n\n// Initialize an array to store the URIs\nlet uris = [];\nlet answer = \"\";\nlet reasoning = \"\";\n\n// Process each input item\nitems.forEach(item => {\n  // Navigate to the citationSources array within citationMetadata\n  const citationSources = item.json.candidates?.[0]?.citationMetadata?.citationSources;\n\n  // Check if citationSources exists and is an array\n  if (Array.isArray(citationSources)) {\n    // Extract the URI from each source and add it to the uris array\n    citationSources.forEach(source => {\n      if (source.uri) {\n        uris.push(source.uri);\n      }\n    });\n  }\n\n  // Extract reasoning and answer\n  reasoning = item.json.candidates?.[0]?.content?.parts?.[0]?.text || \"\";\n  answer = item.json.candidates?.[0]?.content?.parts?.[1]?.text || \"\";\n});\n\n// Wrap the URIs, reasoning, and answer inside a single response object\nreturn uris.length > 0 || reasoning || answer \n  ? [{ json: { response: { citation: uris, reasoning, answer } } }] \n  : [];\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "dcb63058-5fa5-417e-bce7-a1fc4aea2daa",
      "name": "Sticky Note - Receive User Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3220,
        -280
      ],
      "parameters": {
        "width": 340,
        "height": 380,
        "content": "This node receives user input via a webhook and acts as the starting point of the workflow. Make sure to properly configure the path to ensure requests are correctly routed."
      },
      "typeVersion": 1
    },
    {
      "id": "dcc76788-020e-45ff-86d3-4c126f93bf6c",
      "name": "Sticky Note - Send Request to Google Gemini",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3600,
        -280
      ],
      "parameters": {
        "width": 340,
        "height": 380,
        "content": "This node sends a request to the Google Gemini API to generate content based on the user's input. Properly configure parameters like temperature, topK, topP, and maxOutputTokens to customize the response."
      },
      "typeVersion": 1
    },
    {
      "id": "cbf0e447-bb05-410a-a635-c8aa7a5400fe",
      "name": "Sticky Note - Process API Response",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3980,
        -280
      ],
      "parameters": {
        "width": 340,
        "height": 380,
        "content": "This node processes and organizes the response obtained from the API to structure reasoning, answers, and citations, if available. Ensure the JavaScript code is correctly configured."
      },
      "typeVersion": 1
    },
    {
      "id": "1a249638-0cce-4370-978e-6a88923ff544",
      "name": "Sticky Note - Return Response to User",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4380,
        -280
      ],
      "parameters": {
        "width": 340,
        "height": 380,
        "content": "This node finalizes the workflow by sending the processed response back to the user. Verify that the response format meets client expectations."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6e06959e-0dcd-4c47-adc8-30e5633167e3",
  "connections": {
    "Receive User Input": {
      "main": [
        [
          {
            "node": "Send Request to Google Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process API Response": {
      "main": [
        [
          {
            "node": "Return Response to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Request to Google Gemini": {
      "main": [
        [
          {
            "node": "Process API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow is designed to handle user inputs via a webhook, process the inputs with the Google Gemini API (specifically the gemini-2.0-flash-thinking-exp-1219 model), and return a structured response to the user. The response includes three key elements: reasoning, the final…

Source: https://n8n.io/workflows/2680/ — original creator credit. Request a take-down →

More Web Scraping workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Web Scraping

This n8n template provides enterprise-level version control for your workflows using GitHub integration. Stop losing hours to broken workflows and manual exports – get proper commit history, visual di

n8n, Execute Workflow Trigger, HTTP Request +1
Web Scraping

This flow creates dummy files for every item added in your *Arrs (Radarr/Sonarr) with the tag .

HTTP Request, Ssh
Web Scraping

This workflow acts as a central API gateway for all technical indicator agents in the Binance Spot Market Quant AI system. It listens for incoming webhook requests and dynamically routes them to the c

HTTP Request
Web Scraping

Sign PDF documents with legally-compliant digital signatures using X.509 certificates. Supports multiple PAdES signature levels (B, T, LT, LTA) with optional visible stamps.

Execute Command, HTTP Request, Read Write File +1
Web Scraping

📡 This workflow serves as the central Alpha Vantage API fetcher for Tesla trading indicators, delivering cleaned 20-point JSON outputs for three timeframes: , , and . It is required by the following a

HTTP Request