AutomationFlowsAI & RAG › Create an All-in-one Discord Assistant with Gemini, Llama Vision & Flux Images

Create an All-in-one Discord Assistant with Gemini, Llama Vision & Flux Images

ByAslamul Fikri Alfirdausi @asla on n8n.io

This n8n template demonstrates how to build O'Carla, an advanced all-in-one Discord AI assistant. It intelligently handles natural conversations, professional image generation, and visual file analysis within a single server integration.

Webhook trigger★★★★★ complexityAI-powered42 nodesMemory Buffer WindowAgentGoogle Gemini ChatHTTP RequestOpenRouter Chat
AI & RAG Trigger: Webhook Nodes: 42 Complexity: ★★★★★ AI nodes: yes Added:

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

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

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
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d7e0ac70-b502-4f21-9067-1c1bed69e00a",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -352,
        1600
      ],
      "parameters": {
        "path": "b0631bec-9ccc-4eb8-b143-d73609b213c7",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "a9006c4e-2149-4d22-998b-d716e076674b",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        320,
        2608
      ],
      "parameters": {
        "sessionKey": "={{ $('Webhook').item.json.body.userId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "b9226615-6c1c-45d8-ba99-9e581e1ea00b",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        656,
        2432
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.1
    },
    {
      "id": "25a59199-7f7b-4193-a8a3-ea18e13b21df",
      "name": "correctNaming",
      "type": "n8n-nodes-base.code",
      "position": [
        496,
        2432
      ],
      "parameters": {
        "jsCode": "// Hole alle Items\nconst items = $input.all();\n\n// Nehme das erste Item (falls mehrere vorhanden sind)\nconst item = items[0];\n\n// Extrahiere den output\nconst antwort = item.json.output;\n\n// Formatiere die Antwort im richtigen Format f\u00fcr den Discord-Bot\nreturn {\n  json: {\n    answer: antwort\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "eb23be48-2d22-4a29-97e2-2ce0fff6fb54",
      "name": "Discord AI Response Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        224,
        2432
      ],
      "parameters": {
        "text": "==User Mention: <@{{ $json.body.userId }}>\n\nQuestion/Prompt: {{ $json.body.question }} ",
        "options": {
          "systemMessage": "You are a helpful assistant named O'Carla created by Asla Fikri. You answer only based on the user's question or prompt. You are not allowed to reference or mention any YouTube channel, podcast, or unrelated external content such as 'Presting Podcast', unless specifically asked about it. You answer in the same language as the question. Never say that you are created or trained by Google. If the user asks who created you, explain that you were developed by Asla Fikri and refer them to the GitHub (https://github.com/masrigaa) or LinkedIn (https://www.linkedin.com/in/aslamul-fikri-alfirdausi) profiles. Always begin your response with <@{{userId}}> followed immediately by your answer in the same paragraph. Do not insert a line break. You are also capable of generating images. To request an image, the user should start their prompt with 'gambar:'."
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "fd66a558-01e5-4142-97c1-e20a351d32c9",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        96,
        1744
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d02739c7-f540-497a-8e39-681ce6458ecb",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.body.question }}\n",
              "rightValue": "gambar:"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "e8713888-0374-48fb-a2d8-a09051dbfbfd",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        272,
        1728
      ],
      "parameters": {
        "jsCode": "const full = $json.body.question || '';\nconst prompt = full.replace('gambar:', '').trim();\nreturn [{ json: {\n  prompt: prompt,\n  userId: $json.body.userId\n}}];"
      },
      "typeVersion": 2
    },
    {
      "id": "fd370746-1dd9-4334-80eb-c2fcc71a3f5f",
      "name": "Fields - Set Values",
      "type": "n8n-nodes-base.set",
      "position": [
        432,
        1728
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4e04fec4-441e-45f7-acea-0017a4b5c104",
              "name": "model",
              "type": "string",
              "value": "flux"
            },
            {
              "id": "aa80cd68-1c82-4032-b1d7-e098856eec38",
              "name": "width",
              "type": "string",
              "value": "1080"
            },
            {
              "id": "da6d305f-aece-49bd-ae02-52df59915c60",
              "name": "height",
              "type": "string",
              "value": "1920"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "82817b04-d0fb-4608-8a01-223515d8b03f",
      "name": "Code - Clean Json",
      "type": "n8n-nodes-base.code",
      "position": [
        912,
        1728
      ],
      "parameters": {
        "jsCode": "function cleanAndExtractJSON(response) {\n    try {\n        const result = {\n            image_prompt: []\n        };\n\n        const lines = response.split('\\n');\n        let currentPrompt = '';\n\n        for (const line of lines) {\n            if (line.includes('\"prompt\":')) {\n                if (currentPrompt) {\n                    result.image_prompt.push(currentPrompt.trim());\n                }\n                currentPrompt = line.split('\"prompt\":')[1].trim();\n            }\n        }\n\n        if (currentPrompt) {\n            result.image_prompt.push(currentPrompt.trim());\n        }\n\n        return { json: result };\n        \n    } catch (error) {\n        return { \n            json: {\n                image_prompt: []\n            }\n        };\n    }\n}\n\nconst response = $input.first().json.output;\nreturn cleanAndExtractJSON(response);"
      },
      "executeOnce": false,
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "23dda22e-7395-42de-883e-e7e29f845603",
      "name": "Code - Get Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        1728
      ],
      "parameters": {
        "jsCode": "return $input.first().json.image_prompt.map(prompt => ({\n  json: {\n    body: {\n      prompt: prompt,\n  \"image_size\": {\n    \"width\": $('Fields - Set Values').first().json.width,\n    \"height\": $('Fields - Set Values').first().json.height\n  },\n  \"num_inference_steps\": 12,\n  \"guidance_scale\": 3.5,\n  \"num_images\": 1,\n  \"enable_safety_checker\": true,\n}\n    }\n  }\n));"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "08725f72-3dd5-4e66-a865-9f80131899ef",
      "name": "Code - Set Filename",
      "type": "n8n-nodes-base.code",
      "position": [
        1360,
        1728
      ],
      "parameters": {
        "jsCode": "for (let i = 0; i < items.length; i++) {\n  items[i].json.fileName = `images_${(i + 1).toString().padStart(3, '0')}.png`;\n}\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "082b4628-cd88-4310-ad8b-869f68babaa7",
      "name": "AI Agent - Create Image From Prompt",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        592,
        1728
      ],
      "parameters": {
        "text": "={{ $('Webhook').item.json.body.question }}",
        "options": {
          "systemMessage": "=You are an AI image\u2011prompt creation expert. Please create a post using the following JSON format:\nAI Image Generation Prompt Guidelines:\nObjective\nCreate highly realistic, high\u2010quality images\nEnsure the image content faithfully conveys the spirit of the original text\nIntegrate short text (10\u201320 characters) naturally into the image\nMaintain consistency and professionalism\n\nStandard Prompt Structure\n[Main Scene] | [Key Elements] | [Text Integration] | [Lighting & Atmosphere] | [Technical Parameters] | [Style Parameters]\n\nComponent Breakdown\n1. Main Scene (Weight ::8)\nDescribe the primary setting in line with the content.\nExamples:\nTech news: \u201cmodern tech office setting, minimalist workspace\u201d\nEconomy news: \u201cprofessional financial district, corporate environment\u201d\nEducation news: \u201cmodern classroom, advanced learning environment\u201d\n\n2. Key Elements (Weight ::8)\nList the main visual elements required.\nExamples:\n\u201clarge HD display showing text \u2018AI Ethics\u2019 in modern typography\u201d\n\u201cprofessional people in business attire discussing around interactive screen\u201d\n\u201cdetailed infographic elements floating in augmented reality style\u201d\n\n3. Text Integration (Weight ::7)\nHow to display text within the image:\ntext elements | elegant typography, clear readable text, integrated naturally into scene ::7\n\n4. Lighting & Atmosphere (Weight ::7)\nlighting | cinematic dramatic lighting, natural ambient light, professional studio setup ::7\nbackground | depth of field blur, clean professional environment ::6\n\n5. Technical Parameters\nparameters | 8k resolution, hyperrealistic, photorealistic quality, octane render, cinematic composition --ar 16:9\nsettings | sharp focus, high detail, professional photography --s 1000 --q 2\nComplete Examples\nExample\u00a01: AI Ethics News\nprofessional tech conference room | large display showing \"AI Ethics Now\" in modern typography, group of diverse executives in discussion ::8 | clean modern workspace, glass walls, tech atmosphere ::7 | cinematic lighting, natural window light ::7 | 8k resolution, hyperrealistic quality, octane render --ar 16:9 --s 1000 --q 2\nExample\u00a02: Financial Market News\nmodern stock exchange environment | giant LED wall showing \"Market Alert\" in bold typography, professional traders in action ::8 | dynamic financial data visualization, sleek modern interior ::7 | dramatic lighting, blue-tinted atmosphere ::7 | 8k resolution, photorealistic quality --ar 16:9 --s 1000 --q 2\n\nAdditional Parameters\n--chaos [0\u2013100]: Adjust randomness\n--stylize [0\u20131000]: Degree of stylization\n--seed [number]: Ensure consistency across generations\n--niji: Optimized for Asian\u2010style aesthetics\n--v 5.2: Use the latest model version\n\nImportant Notes\nText in Image\nKeep it short and legible\nUse professional fonts\nIntegrate naturally into the scene\n\nComposition\nFollow the rule of thirds\nEnsure a clear focal point\nBalance text and imagery\n\nColor\nMatch a professional tone\nProvide sufficient contrast for readability\nMaintain visual consistency\n\nTechnical Details\nAlways use high resolution (8k)\nEnsure professional lighting\nOptimize for sharpness and detail\n\nCommon Pitfalls to Avoid\nOverly generic prompts\nMissing text\u2010integration guidance\nFailing to specify composition rules\nOmitting key technical parameters\n\nThe structure is:\n{\n  prompt_image {prompt : \"\" , ...}\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "de425608-71ee-4a8b-9bba-caa05d134ff2",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        592,
        1872
      ],
      "parameters": {
        "options": {
          "topK": 40,
          "topP": 1,
          "temperature": 0.5,
          "safetySettings": {
            "values": [
              {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
              }
            ]
          },
          "maxOutputTokens": 65536
        },
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "22d4e7a9-60c9-4708-adb9-f70d4df71fcc",
      "name": "Handle Respons",
      "type": "n8n-nodes-base.code",
      "position": [
        1360,
        1920
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst results = [];\n\nfor (let i = 0; i < items.length; i++) {\n  const item = items[i];\n  \n  // Cek jika HTTP request berhasil\n  if (item.json && item.json.url) {\n    results.push({\n      json: {\n        imageUrl: item.json.url,\n        fileName: item.json.fileName || `image_${i + 1}.png`,\n        success: true\n      }\n    });\n  } else {\n    // Jika gagal, buat URL langsung dari Pollinations\n    const prompt = $('Code - Get Prompt').item.json.body.prompt;\n    const width = $('Fields - Set Values').item.json.width;\n    const height = $('Fields - Set Values').item.json.height;\n    \n    const directUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(prompt)}?width=${width}&height=${height}&model=flux&seed=42&nologo=true`;\n    \n    results.push({\n      json: {\n        imageUrl: directUrl,\n        fileName: `image_${i + 1}.png`,\n        success: true\n      }\n    });\n  }\n}\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "ff1fd475-75be-4d8d-8361-86e5fda817fe",
      "name": "Format Discord Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        2112
      ],
      "parameters": {
        "jsCode": "// Tidak perlu items karena hanya menggunakan first() saja\nconst userId = $('Webhook').first().json.body.userId;\nconst originalQuestion = $('Webhook').first().json.body.question;\n\n// Ambil URL dari response TinyURL\nconst tinyUrl = $input.first().json.data;\n\n// Validasi URL\nconst isValidUrl = tinyUrl && typeof tinyUrl === 'string' && tinyUrl.trim() && \n  (tinyUrl.startsWith('https://tinyurl.com/') || \n   tinyUrl.startsWith('https://image.pollinations.ai/') ||\n   tinyUrl.startsWith('http'));\n\n// Handle jika tidak ada URL yang valid\nif (!isValidUrl) {\n  return [{\n    json: {\n      answer: `<@${userId}> \u274c Maaf, gagal membuat gambar. Silakan coba lagi.`\n    }\n  }];\n}\n\n// Format response untuk Discord\nconst cleanPrompt = originalQuestion.replace('gambar:', '').trim();\nlet response = `<@${userId}> \u2705 **Gambar berhasil dibuat!**\\n\\n`;\nresponse += `\ud83d\udcdd **Prompt:** ${cleanPrompt}\\n\\n`;\nresponse += `\ud83d\uddbc\ufe0f **Hasil:**\\n${tinyUrl.trim()}`;\n\nreturn [{\n  json: {\n    answer: response,\n    imageUrl: tinyUrl.trim(),\n    success: true\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "af928d3b-d7dc-41c7-a0bd-e34bb43a04f4",
      "name": "Respond to Webhook2",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1360,
        2112
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.4
    },
    {
      "id": "bb56fc18-c1e5-4210-bd96-7daf1560e290",
      "name": "Error Handler",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        1920
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst validImages = [];\n\nfor (let item of items) {\n  if (item.json && item.json.url) {\n    validImages.push(item.json);\n  }\n}\n\nif (validImages.length === 0) {\n  return [{\n    json: {\n      error: \"Gagal membuat gambar\",\n      answer: `<@{{ $json.body.userId }}> Maaf, gagal membuat gambar. Silakan coba lagi.`\n    }\n  }];\n}\n\nreturn validImages;"
      },
      "typeVersion": 2
    },
    {
      "id": "b820c3e6-9dbd-460e-8b27-cc90806996c3",
      "name": "Has Atc",
      "type": "n8n-nodes-base.if",
      "position": [
        -128,
        1600
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f8f1f613-041c-4595-8148-397fba229506",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.body.attachments.length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b3d65a7d-9974-41c1-9640-1009a6fffec7",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        288,
        1280
      ],
      "parameters": {
        "jsCode": "const attachment = $input.first().json.body.attachments[0];\nconst isImage = attachment.contentType.startsWith(\"image/\");\n\nreturn [\n  {\n    json: {\n      isImage,\n      url: attachment.url,\n      mime: attachment.content_type,\n      filename: attachment.filename,\n      prompt: $('Webhook').first().json.body.question || (isImage ? \"Jelaskan isi gambar ini.\" : \"Jelaskan isi file ini.\")\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e80df187-ad70-4a6b-beeb-c7f28b29e616",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        976,
        880
      ],
      "parameters": {
        "url": "={{ $json.imageUrl }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b2248c94-b133-470a-825c-5f392a11a730",
      "name": "Create Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        912,
        1920
      ],
      "parameters": {
        "url": "=https://image.pollinations.ai/prompt/ {{ $('Code - Get Prompt').item.json.body.prompt }}",
        "options": {},
        "jsonQuery": "={\n  \"width\": {{ $('Fields - Set Values').item.json.width }},\n  \"height\": {{ $('Fields - Set Values').item.json.height }},\n  \"model\": \"{{ $('Fields - Set Values').item.json.model }}\",\n  \"seed\": 42,\n  \"nologo\": true\n}",
        "sendQuery": true,
        "sendHeaders": true,
        "specifyQuery": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "alwaysOutputData": true,
      "waitBetweenTries": 5000
    },
    {
      "id": "9728e344-51ae-40a2-942c-8e1b34becb38",
      "name": "Change Link To Be Sort",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        912,
        2112
      ],
      "parameters": {
        "url": "https://tinyurl.com/api-create.php",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "=url",
              "value": "={{ $json.imageUrl }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "30d8726a-4fea-4123-9ee4-878b4e4c56ff",
      "name": "Simple Memory1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1136,
        1472
      ],
      "parameters": {
        "sessionKey": "={{ $('Webhook').item.json.body.userId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "412910a7-b745-4a39-80c3-b36527a2e447",
      "name": "Respond to Webhook3",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1472,
        1296
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.1
    },
    {
      "id": "a9d13b7a-e104-42de-ac4a-b9a94942de41",
      "name": "correctNaming1",
      "type": "n8n-nodes-base.code",
      "position": [
        1312,
        1296
      ],
      "parameters": {
        "jsCode": "// Hole alle Items\nconst items = $input.all();\n\n// Nehme das erste Item (falls mehrere vorhanden sind)\nconst item = items[0];\n\n// Extrahiere den output\nconst antwort = $input.first().json.output;\n\n// Formatiere die Antwort im richtigen Format f\u00fcr den Discord-Bot\nreturn {\n  json: {\n    answer: antwort\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "33f4003e-5a2a-42a0-b9e1-58b200f87b93",
      "name": "Discord AI Response Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1040,
        1296
      ],
      "parameters": {
        "text": "==User Mention: <@s{{ $('Webhook').item.json.body.userId }}>\n\nQuestion/Prompt: {{ $json.prompt }}",
        "options": {
          "systemMessage": "You are a helpful assistant named O'Carla created by Asla Fikri. You answer only based on the user's question or prompt. You are not allowed to reference or mention any YouTube channel, podcast, or unrelated external content such as 'Presting Podcast', unless specifically asked about it. You answer in the same language as the question. Never say that you are created or trained by Google. If the user asks who created you, explain that you were developed by Asla Fikri and refer them to the GitHub (https://github.com/masrigaa) or LinkedIn (https://www.linkedin.com/in/aslamul-fikri-alfirdausi) profiles. Always begin your response with <@{{userId}}> followed immediately by your answer in the same paragraph. Do not insert a line break. You are also capable of generating images. To request an image, the user should start their prompt with 'gambar:'."
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "d3cac75b-ebcc-4b6d-b772-1b4037e27067",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        480,
        1280
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7430f045-2a93-4e08-a32d-ab341590c1f8",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isImage }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a9dc7bf1-5a98-45e0-ba23-fcbd0b2089bc",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        672,
        1296
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "788387b7-5902-44bb-a9f3-ebc8243b4da2",
      "name": "correctNaming2",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        1296
      ],
      "parameters": {
        "jsCode": "return [{\n  json: {\n    prompt: `Berikut isi file ${$('Code1').first().json.filename}:\\n\\n${$input.first().json.data}`\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "4ba2a2f3-e2d5-44d3-a72a-3361a49635f0",
      "name": "Simple Memory2",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1280,
        1056
      ],
      "parameters": {
        "sessionKey": "={{ $('Webhook').item.json.body.userId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "3b573011-af31-4060-bb6f-3565f9e794fa",
      "name": "Respond to Webhook4",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1616,
        880
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.1
    },
    {
      "id": "005089cb-bd3c-4970-9ff8-8b6e7c3236a6",
      "name": "correctNaming3",
      "type": "n8n-nodes-base.code",
      "position": [
        1456,
        880
      ],
      "parameters": {
        "jsCode": "// Hole alle Items\nconst items = $input.all();\n\n// Nehme das erste Item (falls mehrere vorhanden sind)\nconst item = items[0];\n\n// Extrahiere den output\nconst antwort = $input.first().json.output;\n\n// Formatiere die Antwort im richtigen Format f\u00fcr den Discord-Bot\nreturn {\n  json: {\n    answer: antwort\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "7984bc92-e20b-4ccc-9ce2-19f609c4d2e6",
      "name": "Discord AI Response Agent2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1184,
        880
      ],
      "parameters": {
        "text": "==User Mention: <@s{{ $('Webhook').item.json.body.userId }}>\n\nQuestion/Prompt: {{ $json.prompt }}",
        "options": {
          "systemMessage": "You are a helpful assistant named O'Carla created by Asla Fikri. You answer only based on the user's question or prompt. You are not allowed to reference or mention any YouTube channel, podcast, or unrelated external content such as 'Presting Podcast', unless specifically asked about it. You answer in the same language as the question. Never say that you are created or trained by Google. If the user asks who created you, explain that you were developed by Asla Fikri and refer them to the GitHub (https://github.com/masrigaa) or LinkedIn (https://www.linkedin.com/in/aslamul-fikri-alfirdausi) profiles. Always begin your response with <@{{userId}}> followed immediately by your answer in the same paragraph. Do not insert a line break. You are also capable of generating images. To request an image, the user should start their prompt with 'gambar:'."
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "7c5b72b3-49dd-4f74-b52b-56db7b509310",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1040,
        1440
      ],
      "parameters": {
        "options": {
          "topK": 40,
          "topP": 1,
          "temperature": 0.5,
          "safetySettings": {
            "values": [
              {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
              }
            ]
          },
          "maxOutputTokens": 65536
        },
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7a5e214d-7dac-4187-9a40-4fa6a36ec67b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        816
      ],
      "parameters": {
        "width": 700,
        "height": 528,
        "content": "### **Try O'Carla!**\nO'Carla is an all-in-one Discord AI assistant. It integrates conversational intelligence, professional image generation, and visual file analysis into your Discord server.\n\n### **How it works**\n1. **Webhook Trigger:** Receives data (text & files) from your Discord bot script via POST request.\n2. **Smart Routing:** Identifies if you want an image (keyword `gambar:`), file analysis (attachments), or just a chat.\n3. **Multi-Model Intelligence:**\n   - **Gemini 2.5:** Used for fast, high-quality general conversation.\n   - **Llama 3.2 (via OpenRouter):** Handles advanced Vision & File analysis.\n   - **Flux (via Pollinations):** Generates realistic images from text prompts.\n4. **Context Memory:** Remembers 50 interactions per user for continuous dialogue.\n\n### **Requirements**\n* Google Gemini API Key.\n* OpenRouter API Key.\n* Discord Bot Production Webhook URL.\n\n### **Need Help?**\nContact via [LinkedIn](https://www.linkedin.com/in/aslamul-fikri-alfirdausi) or [GitHub](https://github.com/masrigaa)."
      },
      "typeVersion": 1
    },
    {
      "id": "6ad8a2cd-d954-4559-8e6c-faae36282154",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        1424
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 460,
        "content": "## **1. Discord Bot Integration**\nThis Webhook listens for events from your **Discord Bot script**. \n- It captures the `userId` to maintain separate memories.\n- It detects `attachments` to trigger the Vision path.\n- It routes messages starting with `gambar:` to the Image Generation path."
      },
      "typeVersion": 1
    },
    {
      "id": "b09c48bc-e59b-45bc-986c-d5085c009161",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        1600
      ],
      "parameters": {
        "color": 7,
        "width": 1032,
        "height": 668,
        "content": "## **2. Professional Image Path**\nUses an AI Agent to \"beautify\" prompts before generating high-res images with Flux. Results are automatically shortened for a clean Discord UI."
      },
      "typeVersion": 1
    },
    {
      "id": "dc61a61a-e786-45ec-948e-81c692d08cd0",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        2304
      ],
      "parameters": {
        "color": 7,
        "width": 696,
        "height": 460,
        "content": "## **3. Intelligence Hub**\n- **Memory Buffer:** Saves the last 50 messages to ensure the AI knows the context of the current conversation.\n- **Model Switching:** Automatically uses **Gemini 2.5** for text or **OpenRouter** models for specialized visual tasks."
      },
      "typeVersion": 1
    },
    {
      "id": "05d47198-6836-4d38-84bf-f8ba4364c772",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        1168
      ],
      "parameters": {
        "color": 7,
        "width": 376,
        "height": 348,
        "content": "## **4. Discord Output**\nFormats and sends the final AI response back to the user with correct mentions and clear formatting."
      },
      "typeVersion": 1
    },
    {
      "id": "2ba2af40-4a80-4b2a-8c64-b81a32a4df60",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        1120
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 332,
        "content": "## **\ud83d\udc41\ufe0f Vision & File Analysis**\nTriggers when an image or file is uploaded.\n- **Image Support:** Uses **Llama 3.2 Vision** to describe content.\n- **File Support:** Downloads and reads text-based files to provide summaries or answers based on the document."
      },
      "typeVersion": 1
    },
    {
      "id": "c1dc8f66-4762-437a-96a1-7b73b63ab1e4",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1184,
        1024
      ],
      "parameters": {
        "model": "meta-llama/llama-3.2-11b-vision-instruct:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6be12d9f-4094-4915-9ee1-e6f48902aae1",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        224,
        2576
      ],
      "parameters": {
        "options": {
          "topK": 40,
          "topP": 1,
          "temperature": 0.5,
          "safetySettings": {
            "values": [
              {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
              },
              {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
              }
            ]
          },
          "maxOutputTokens": 65536
        },
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Discord AI Response Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Fields - Set Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Atc": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Has Atc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Image": {
      "main": [
        [
          {
            "node": "Error Handler",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Discord AI Response Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Handler": {
      "main": [
        [
          {
            "node": "Handle Respons",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "correctNaming2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Discord AI Response Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "correctNaming": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Respons": {
      "main": [
        [
          {
            "node": "Change Link To Be Sort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "Discord AI Response Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory2": {
      "ai_memory": [
        [
          {
            "node": "Discord AI Response Agent2",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "correctNaming1": {
      "main": [
        [
          {
            "node": "Respond to Webhook3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "correctNaming2": {
      "main": [
        [
          {
            "node": "Discord AI Response Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "correctNaming3": {
      "main": [
        [
          {
            "node": "Respond to Webhook4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Clean Json": {
      "main": [
        [
          {
            "node": "Code - Get Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Get Prompt": {
      "main": [
        [
          {
            "node": "Code - Set Filename",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Set Filename": {
      "main": [
        [
          {
            "node": "Create Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fields - Set Values": {
      "main": [
        [
          {
            "node": "AI Agent - Create Image From Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Discord AI Response Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Change Link To Be Sort": {
      "main": [
        [
          {
            "node": "Format Discord Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Discord Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Discord AI Response Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Discord AI Response Agent": {
      "main": [
        [
          {
            "node": "correctNaming",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Create Image From Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Discord AI Response Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Discord AI Response Agent1": {
      "main": [
        [
          {
            "node": "correctNaming1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Discord AI Response Agent2": {
      "main": [
        [
          {
            "node": "correctNaming3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Create Image From Prompt": {
      "main": [
        [
          {
            "node": "Code - Clean Json",
            "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 n8n template demonstrates how to build O'Carla, an advanced all-in-one Discord AI assistant. It intelligently handles natural conversations, professional image generation, and visual file analysis within a single server integration.

Source: https://n8n.io/workflows/12097/ — 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 acts as an AI-powered research assistant that takes a topic from the user, performs multi-step intelligent research, and stores the final report in Notion. It uses advanced search, conte

Memory Buffer Window, Output Parser Structured, Agent +6
AI & RAG

This workflow is for beauty salons who want consistent, high‑quality social media content without writing every post manually. It also suits agencies and automation builders who manage multiple beauty

Telegram, Google Sheets Trigger, Agent +26
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Output Parser Structured, Telegram, N8N Nodes Tesseractjs +14
AI & RAG

Deep Research Report Generation Using Open Router, Google Search, Webhook/Telegram and Notion. Uses telegramTrigger, memoryBufferWindow, outputParserStructured, agent. Event-driven trigger; 38 nodes.

Telegram Trigger, Memory Buffer Window, Output Parser Structured +7
AI & RAG

Jacobo Chatbot V2. Uses agent, memoryBufferWindow, toolThink, httpRequest. Webhook trigger; 37 nodes.

Agent, Memory Buffer Window, Tool Think +4