AutomationFlowsAI & RAG › Webhook -> Analytics + Anthropic

Webhook -> Analytics + Anthropic

Webhook -> Analytics + Anthropic. Uses httpRequest. Webhook trigger; 5 nodes.

Webhook trigger★★★★☆ complexity5 nodesHTTP Request
AI & RAG Trigger: Webhook Nodes: 5 Complexity: ★★★★☆ Added:

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
{
  "active": true,
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "index": 0,
            "node": "send-to-analytics",
            "type": "main"
          },
          {
            "index": 0,
            "node": "generate-prompt",
            "type": "main"
          }
        ]
      ]
    },
    "generate-prompt": {
      "main": [
        [
          {
            "index": 0,
            "node": "send-to-anthropic",
            "type": "main"
          }
        ]
      ]
    },
    "send-to-anthropic": {
      "main": [
        [
          {
            "index": 0,
            "node": "format-output",
            "type": "main"
          }
        ]
      ]
    }
  },
  "id": "1xE-9lGXWZxsp",
  "name": "Webhook -> Analytics + Anthropic",
  "nodes": [
    {
      "id": "format-output",
      "name": "format-output",
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"message\":{{ $('send-to-anthropic').item.json.content.find((item) => item.type === 'text').text.toJsonString() }}}"
      },
      "position": [
        660,
        300
      ],
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5
    },
    {
      "id": "generate-prompt",
      "name": "generate-prompt",
      "parameters": {
        "language": "pythonNative",
        "mode": "runOnceForEachItem",
        "pythonCode": "def handler(input):\n    if(input[\"type\"] == \"type1\"):\n        return {\n            \"prompt\": f\"Reply as if you were a gangster.\"\n        }\n    if(input[\"type\"] == \"type2\"):\n        return {\n            \"prompt\": f\"Reply as if you were a pirate.\"\n        }\n\n    raise Exception(\"Invalid type\")\n\nreturn handler({\n  \"type\": _('Webhook Trigger').item.json.query.type\n});"
      },
      "position": [
        260,
        300
      ],
      "type": "n8n-nodes-base.code",
      "typeVersion": 2
    },
    {
      "credentials": {
        "httpCustomAuth": {
          "name": "<your credential>"
        }
      },
      "disabled": true,
      "id": "send-to-analytics",
      "name": "send-to-analytics",
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpCustomAuth",
        "jsonBody": "={\n  \"events\": [\n    {\n      \"user_id\": \"{{ $('Webhook Trigger').item.json.headers['cf-connecting-ip'] }}\",\n      \"event_type\": \"workflow_end\",\n      \"event_properties\": {\n        \"workflow_id\": \"{{ $workflow.id }}\"\n      }\n    }\n  ]\n}",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "url": "https://httpbin.org/post"
      },
      "position": [
        260,
        60
      ],
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4
    },
    {
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "id": "send-to-anthropic",
      "name": "send-to-anthropic",
      "parameters": {
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            }
          ]
        },
        "jsonBody": "={\n  \"model\": \"claude-3-haiku-20240307\",\n  \"temperature\": 1,\n  \"max_tokens\": 200,\n  \"system\": [\n    {\n      \"text\": \"{{ $('generate-prompt').item.json.prompt }}\",\n      \"type\": \"text\"\n    }\n  ],\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $('Webhook Trigger').item.json.query.prompt }}\"\n    }\n  ]\n}",
        "method": "POST",
        "nodeCredentialType": "anthropicApi",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "url": "https://api.anthropic.com/v1/messages"
      },
      "position": [
        460,
        300
      ],
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4
    },
    {
      "id": "webhook",
      "name": "Webhook Trigger",
      "parameters": {
        "httpMethod": "GET",
        "path": "path-to-webhook",
        "responseMode": "responseNode"
      },
      "position": [
        60,
        180
      ],
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1
    }
  ],
  "settings": {},
  "tags": [
    {
      "name": "@vahor/n8n-1xE-9lGXWZxsp"
    }
  ]
}

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

Webhook -> Analytics + Anthropic. Uses httpRequest. Webhook trigger; 5 nodes.

Source: https://github.com/Vahor/n8n-kit/blob/d1a11393cec398e5c942980cba335b70669a2ad2/examples/code-http-anthropic/n8n-kit/workflows/my-workflow.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

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

AI & RAG

This workflow automates end-to-end social media publishing powered by Late API. It generates text content with Google Gemini, creates branded visuals with Kie.ai, uploads media to Late, and publishes

HTTP Request
AI & RAG

This workflow is perfect for app developers, SaaS founders, and mobile growth teams who need constant UGC-style video ads without hiring creators or agencies. If you're spending $500+ per creator and

HTTP Request, Google Drive
AI & RAG

AI Background Generation with Nano Banana (Gemini Image). Uses httpRequest, googleDrive. Webhook trigger; 35 nodes.

HTTP Request, Google Drive
AI & RAG

This template is for developers, teams, and automation enthusiasts who want a private, PIN-protected Telegram chatbot that answers questions from their own documents — without relying on external AI A

Postgres, Telegram, HTTP Request +2
AI & RAG

Elevate your digital presence with high-fidelity cinematic video automation. This workflow orchestrates the complex, asynchronous rendering process of OpenAI Sora—transforming static product images or

HTTP Request, N8N Nodes Uploadtourl