{
  "name": "Project: Custom Meme Generator",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        0
      ],
      "id": "6d8c5a67-fc4e-401b-9f60-daf9f4e00ba4",
      "name": "When chat message received",
      "webhookId": "b1ed4a6b-bf41-45f3-bc59-b4ba237cce3b"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        176,
        256
      ],
      "id": "5d52cd9c-d696-4201-a5e4-1b9aa4e8f225",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "xHWDVrLvQFklSodD",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"description\": \"Description of the meme\",\n\t\"text\": \"Text for the image\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        384,
        208
      ],
      "id": "b9270b08-7e88-4eac-9b37-e9bbe9fb9ba2",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=You are a meme generator bot. You make memes that are funny and entertaining.\n\nYou only job is to create the meme, and let the image generation to other agents.\n\nThe meme will have a single image, with text overlayed on top of it.\n\nFirst, come up with an idea of a funny meme based on the user input.\n\nGenerate a description of the meme.\n\nThen generate a text, that will be overlayed on top of the image. The text must be a single line, and quite short and punchy.\n\nOutput the content you generated based on the output structure "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        208,
        0
      ],
      "id": "62309d09-b541-497c-aa7c-f01be7ac85e9",
      "name": "Meme Generator"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.output.description }}",
        "options": {
          "systemMessage": "=You are a bot that's part of a system for generating memes. The memes are funny, entertaining and relatable.\n\nThe meme will have a single image, with text overlayed on top of it.\n\nYour job is to create a description for an image of this meme to be generated. \n\nBased on the meme description, generate an instruction for an image generation system to create an image."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        560,
        0
      ],
      "id": "4a31a050-67d9-406c-9c69-ed9b40b86a0a",
      "name": "Prompt Generator"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.stability.ai/v2beta/stable-image/generate/core",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "image/*"
            },
            {
              "name": "Content-Type",
              "value": "multipart/form-data"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.prompt }}"
            },
            {
              "name": "output_format",
              "value": "={{ $json.output_format }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        0
      ],
      "id": "59481543-d528-465f-9972-581ffa533ade",
      "name": "HTTP Request",
      "credentials": {
        "httpBearerAuth": {
          "id": "JOzVnwzcOsyjUpK6",
          "name": "Stability AI Bearer Auth"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "526d6fb0-ec44-4571-939e-8aa431a234d6",
              "name": "model",
              "value": "stable-diffusion-xl-v1",
              "type": "string"
            },
            {
              "id": "3ae69db8-d59a-44c6-9c60-37217c062672",
              "name": "prompt",
              "value": "={{ $json.output }}",
              "type": "string"
            },
            {
              "id": "fd7a9294-f57d-403d-9590-118c08b797a9",
              "name": "output_format",
              "value": "png",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        912,
        0
      ],
      "id": "0c227d3b-8f7e-423a-b9a5-5017ad741912",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "text",
        "text": "={{ $('Meme Generator').item.json.output.text }}",
        "fontSize": 100,
        "fontColor": "#FFFFFF",
        "positionY": 100,
        "lineLength": 30,
        "options": {}
      },
      "type": "n8n-nodes-base.editImage",
      "typeVersion": 1,
      "position": [
        1328,
        0
      ],
      "id": "75b37f76-e5c2-4f2c-894a-2b5a906319d0",
      "name": "Edit Image"
    }
  ],
  "pinData": {},
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Meme Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Meme Generator",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Prompt Generator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Meme Generator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Meme Generator": {
      "main": [
        [
          {
            "node": "Prompt Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Generator": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a0ca0b8b-064c-4d55-b114-f32959898276",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "281c34c03b9c41f054c536eeb966e9e503918cf7f00e3bc32a5ff9cca85ca255"
  },
  "id": "TILyVDvOzGWoZPPh",
  "tags": []
}