{
  "name": "StarGraphs",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "98f4dd43-e612-481f-a3e2-14e4479671a7",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1180,
        -220
      ],
      "id": "7905023b-a327-4913-95a7-4d1abfc12edd",
      "name": "Webhook"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        100,
        0
      ],
      "id": "51fd7b0e-4a9b-43db-9141-7a4de0273e83",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Classification",
        "height": 1740,
        "width": 880,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -920
      ],
      "id": "476f9009-8afa-4b65-9db6-f36b4e93cf25",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.text }}",
                    "rightValue": "PERSON",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "e7c155a8-cb2a-44d9-bab7-cc2efb9a5790"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Person"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "670b27d7-9d6b-4d5a-a90d-62c070ab01e4",
                    "leftValue": "={{ $json.text }}",
                    "rightValue": "TITLE",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Title"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f50facc6-8e62-461b-a10f-b163bf1ad75a",
                    "leftValue": "={{ $json.text }}",
                    "rightValue": "SPAM",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Other"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        360,
        -220
      ],
      "id": "a5f913d2-66e2-44d2-b210-95e297fcbb99",
      "name": "Switch"
    },
    {
      "parameters": {
        "content": "# Downloading and combining data\n",
        "height": 1740,
        "width": 1540
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        920,
        -920
      ],
      "id": "bda97b1e-a073-4981-94b2-c640d37bad44",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "17fc6e15-5468-4d4a-957a-439d9316308b",
              "leftValue": "={{ $json.total_results }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1220,
        320
      ],
      "id": "fb011b92-dc91-416f-9734-9fd35b2548cc",
      "name": "If"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "17fc6e15-5468-4d4a-957a-439d9316308b",
              "leftValue": "={{ $json.total_results }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1160,
        -640
      ],
      "id": "955ba8eb-e451-4f56-9368-111d2b78d2de",
      "name": "If1"
    },
    {
      "parameters": {
        "content": "# Content building",
        "height": 1740,
        "width": 1200,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2560,
        -920
      ],
      "id": "c119c672-7ece-427b-a066-13adf92b27f2",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        2920,
        -220
      ],
      "id": "d8008407-8a77-4e0b-aafa-47788c15cc12",
      "name": "Google Gemini Chat Model1",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        2900,
        180
      ],
      "id": "fb3a8885-bccd-4939-927c-b8ae42563283",
      "name": "Google Gemini Chat Model2",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Query analysis",
        "height": 1740,
        "width": 840,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -960,
        -920
      ],
      "id": "364e497d-be68-4f99-8edf-4d9f5afe16e6",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -700,
        -20
      ],
      "id": "9cabc746-5d59-4eb8-b622-8390ed900e96",
      "name": "Google Gemini Chat Model3",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.query }}",
        "messages": {
          "messageValues": [
            {
              "message": "Jeste\u015b analizatorem odpowiedzi. \nMasz sprawdzi\u0107 czy zapytanie u\u017cytkownika nie zawiera b\u0142\u0119d\u00f3w.\nB\u0119dziesz otrzymywa\u0107 informacje o aktorach i tytu\u0142ach film\u00f3w.\nZwracaj uwag\u0119 na poprawno\u015b\u0107, czy nie ma liter\u00f3wek, przekr\u0119conych nazwisk.\nSprawdzaj uwag\u0119 na wielko\u015b\u0107 liter, pami\u0119taj \u017ce maj\u0105 zaczyna\u0107 z wielkich liter, to samo przy tytu\u0142ach film\u00f3w.\nSprawdzaj uwag\u0119 na spacje.\n\nPrzyk\u0142ad dzia\u0142ania:\nstar wars - zwracasz Star Wars\npetro pascal - zwracasz Pedroo Pascal\nStanleyKubrick - zwracasz StanleyKubrick\n\nWA\u017bNE: POMI\u0143 SWOJE KOMENTARZE"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        -820,
        -220
      ],
      "id": "9a1d7f65-ff93-4f30-bb73-14e8c505cada",
      "name": "Improving query content"
    },
    {
      "parameters": {
        "tableId": "infographics",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "id",
              "fieldValue": "={{ $('Webhook').item.json.body.id }}"
            },
            {
              "fieldId": "user_query",
              "fieldValue": "={{ $json.text }}"
            },
            {
              "fieldId": "template_id",
              "fieldValue": "={{ $('Webhook').item.json.body.template_id }}"
            },
            {
              "fieldId": "generation_status",
              "fieldValue": "STARTED"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -340,
        -220
      ],
      "id": "8e59044a-60cc-4e43-b78a-957b723e064c",
      "name": "Saving initial information to the database",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Improving query content').item.json.text }}",
        "messages": {
          "messageValues": [
            {
              "message": "Jeste\u015b klasyfikatorem odpowiedzi. Masz zdecydowa\u0107 czy fraza u\u017cytkownika to: - osoba - zwracasz PERSON - tytu\u0142 filmu - zwracasz s\u0142owo TITLE - je\u015bli nie pasuje do kategorii zwr\u00f3\u0107 s\u0142owo SPAM  Pomi\u0144 zb\u0119dne komentarze."
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        20,
        -220
      ],
      "id": "39efe072-85f8-4889-9ea2-a4c683b5c85a",
      "name": "Classifier"
    },
    {
      "parameters": {
        "url": "=https://api.themoviedb.org/3/search/person?api_key=ba9435622413df35cd8d080b147a1f2b&query={{ $('Improving query content').item.json.text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1000,
        -640
      ],
      "id": "734a8fd9-bd93-4ee1-b49d-6c795a603c01",
      "name": "Person data from TMDB"
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "infographics",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "condition": "eq",
              "keyValue": "={{ $('Webhook').item.json.body.id }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "generation_status",
              "fieldValue": "NOCATEGORY"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        360,
        40
      ],
      "id": "022c92fc-924a-4302-a1e4-27b05c7d92f3",
      "name": "Update status if the query is SPAM",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "infographics",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "condition": "eq",
              "keyValue": "={{ $('Webhook').item.json.body.id }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "generation_status",
              "fieldValue": "=PERSONNOTFOUND"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1160,
        -400
      ],
      "id": "5649d42e-895b-4222-a1a2-4546cf933acf",
      "name": "Update status if person not found",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\n// for (const item of $input.all()) {\n//   item.json.myNewField = 1;\n// }\n\n// return $input.all();\n\nconst results = $input.first().json.results\n\n// Posortuj po popularno\u015bci malej\u0105co\nresults.sort((a, b) => b.popularity - a.popularity);\n\n// Zwr\u00f3\u0107 tylko pierwszy (najbardziej popularny)\nreturn [\n  {\n    json: {\n      item: results[0]\n  }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1440,
        -660
      ],
      "id": "ee0ee74b-0973-4e34-b997-cba89346a0aa",
      "name": "Filtering people by popularity"
    },
    {
      "parameters": {
        "jsCode": "const results1 = $('Filtering people by popularity').first().json.item\nconst results2 = $input.first().json.query\n\n\nconst dataString = JSON.stringify({\n  item1: results1,\n  item2: results2\n});\n\n\nreturn [\n  {\n    json: {\n      item: dataString\n  }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1860,
        -660
      ],
      "id": "4496b268-b119-4802-8938-07f4bc70eb15",
      "name": "Combining person data"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Combining person data').item.json.item }}",
        "messages": {
          "messageValues": [
            {
              "message": "=Wciel sie w do\u015biwadczonego content creatora ze znajomo\u015bci\u0105 HTML.\nOtrzymasz od u\u017cytkownika dane, wed\u0142ug kt\u00f3ych masz zubodwa\u0107 inforgrafik\u0119 w J\u0118ZYKU ANGIESLKIM.\n\n#Szablon z kt\u00f3ego masz skorzysta\u0107 to:\n{{ $json.content }} \n\n#Zasady:\n-Mo\u017cesz zmienia\u0107 tylko pola-za\u015blepki odpowiednio zaznaczone w [[nazwa_pola]].\n-Korzystaj z komponent\u00f3w podanych w szablonie.\n-Mo\u017cesz korzysta\u0107 z Bootstrap Icons.\n-Pomi\u0144 zb\u0119dne uwagi.\n-Nigdy znie zwracaj ```html ``` Te znaki s\u0105 zb\u0119dne. Zwr\u00f3\u0107 tylko kod html.\n-Inforgrafika w sekcji content powinna mie\u0107 conajmniej 14 koponent\u00f3w.\n\n\nPrzyk\u0142ad: [[nazwa_pola]] zamieniasz na WARTO\u015a\u0106\n\n#Wskaz\u00f3wki do doboru tre\u015bci:\n-Wiek\n-Wzrost - ciekawe i zabawne\n-Narodowo\u015b\u0107\n-Pochodzenie\n-Wykszta\u0142cenie\n-J\u0119zyki, kt\u00f3rymi si\u0119 pos\u0142uguje \n-Znak zodiaku\n-Orientacja seksualna\n-Ma\u0142\u017ce\u0144stwa i relacje romantyczne\n-Rodzicielstwo i dzieci (ze zwi\u0105zku, z poza zwi\u0105zku, adoptowane)\n-Pokrewie\u0144stwo z innymi gwiazdami\n-Skandale i kontrowersje\n-Incydenty medialne\n-Wpadki\n-Reakcje aktora/otoczenia na skandale/kontrowersje\n-Status zawodowy\n-Wykszta\u0142cenie aktorskie/szko\u0142y teatralne\n-Pierwsze role/debiut\n-Prze\u0142omowe momenty kariery\n-Mentorzy i wp\u0142ywy\n-Agenci i mened\u017cerowie\n-Wsp\u00f3\u0142praca z konkretnymi re\u017cyserami/studiami\n-Typowe role/amplua\n-Metody aktorskie i przygotowanie do r\u00f3l\n-Pieni\u0105dze i sukces\n-Droga do sukcesu\n-Wynagrodzenia za role (w tym najwy\u017csze i najni\u017csze)\n-Zarobki z innych \u017ar\u00f3de\u0142\n-Maj\u0105tek\n-Rankingi najbogatszych\n-Potencjalne darowizny charytatywne lub zaanga\u017cowanie w filantropi\u0119\n-Tytu\u0142y w kt\u00f3rych gra\u0142\n-Osi\u0105gni\u0119cia zawodowe\n-Lista nagr\u00f3d i nominacji\n-Wygl\u0105d i styl\n-Nietypowe zainteresowania i fobie, a tak\u017ce pasje i ciekawostki\n-Zaanga\u017cowanie spo\u0142eczne i warto\u015bci\n\n#Ikony bootstrap z kt\u00f3rych mo\u017cesz korzysta\u0107:\ncamera\ncamera-video\ncassette\ndisplay\nfilm\nplay\npause\nstop\nrecord\nrecord-circle\nrecord-circle-fill\nvolume-up\nvolume-down\nvolume-mute\nheadset\nspeaker\ntv\nperson\npeople\nchat\nchat-square\nchat-left\nchat-right\nstar\nheart\naward\ntrophy\nflag\ncalendar\nclock\nalarm\nstop-watch\narrow-right\narrow-left\narrow-up\narrow-down\nchevron-right\nchevron-left\nchevron-up\nchevron-down\nplus\nplus-circle\nplus-square\ncheck\ncheck-circle\nx-circle\nmenu\nsearch\nbadge-hd\n\nWA\u017bNE: TRE\u015aCI MA BY\u0106 W J\u0118ZYKU ANGIELSKIM\nWA\u017bNE: NIE POKAZUJEMY OBRAZK\u00d3W Z WIKIMEDIA\nWA\u017bNE: NIE MO\u017bESZ KORZYSTA\u0106 Z IKON bi-ruler bi-film-fill\nWA\u017bNE: URL DO WSZYSTKICH OBRAZK\u00d3W ZAWSZE ZACZYNA SI\u0118 OD https://image.tmdb.org/t/p/w500\nWA\u017bNE: BIERZ POD UWAG\u0118 TYLKO URL PODANE Z JSON JAKO poster_path, je\u015bli nie ma takiego obrazka to nie tw\u00f3rz elementu listy obrazkowej"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        2980,
        -380
      ],
      "id": "46f2e938-d1e0-4b28-857b-74c19100a56d",
      "name": "Construction of template content for person"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "templates",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $('Webhook').item.json.body.template_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        2680,
        -380
      ],
      "id": "138b94d7-4ce3-4ec5-848d-d24aa6ba341f",
      "name": "Download template data for person",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "infographics",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "condition": "eq",
              "keyValue": "={{ $('Webhook').item.json.body.id }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "content",
              "fieldValue": "={{ $json.text }}"
            },
            {
              "fieldId": "generation_status",
              "fieldValue": "READY"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        3420,
        -380
      ],
      "id": "29724faf-b24f-4ebd-9e54-aee14fa50123",
      "name": "Saving the content of the infographic for person",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://api.themoviedb.org/3/search/movie?api_key=ba9435622413df35cd8d080b147a1f2b&query={{ $('Improving query content').item.json.text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1020,
        320
      ],
      "id": "e5d994b4-87d6-425d-8f9c-4a06bae165e6",
      "name": "Movie data from TMDB"
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "infographics",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "condition": "eq",
              "keyValue": "={{ $('Webhook').item.json.body.id }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "generation_status",
              "fieldValue": "=MOVIENOTFOUND"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1220,
        560
      ],
      "id": "e244f2bc-ba96-4914-ba87-dff3f7c5dbfa",
      "name": "Update status if video not found",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\n// for (const item of $input.all()) {\n//   item.json.myNewField = 1;\n// }\n\n// return $input.all();\n\nconst results = $input.first().json.results\n\n// Posortuj po popularno\u015bci malej\u0105co\nresults.sort((a, b) => b.popularity - a.popularity);\n\n// Zwr\u00f3\u0107 tylko pierwszy (najbardziej popularny)\nreturn [\n  {\n    json: {\n      item: results[0]\n  }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1440,
        300
      ],
      "id": "db8d0792-3cc8-4771-beed-fa6a2ef65d2a",
      "name": "Filtering movies by popularity"
    },
    {
      "parameters": {
        "jsCode": "const genre_map = {\n    28: \"Action\",\n    12: \"Adventure\",\n    16: \"Animation\",\n    35: \"Comedy\",\n    80: \"Crime\",\n    99: \"Documentary\",\n    18: \"Drama\",\n    10751: \"Family\",\n    14: \"Fantasy\",\n    36: \"History\",\n    27: \"Horror\",\n    10402: \"Music\",\n    9648: \"Mystery\",\n    10749: \"Romance\",\n    878: \"Science Fiction\",\n    10770: \"TV Movie\",\n    53: \"Thriller\",\n    10752: \"War\",\n    37: \"Western\"\n}\n\nconst movie = $input.first().json.item\n\nmovie.genre_ids = movie.genre_ids.map(id => genre_map[id] || \"\")\n\n\n\nreturn [\n  {\n    json: {\n      item: movie\n  }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1620,
        300
      ],
      "id": "069d5a5d-cf98-4ce7-a543-d0bf752bf0e6",
      "name": "Reading movie genres"
    },
    {
      "parameters": {
        "url": "=https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&explaintext=1&titles={{ $('Improving query content').item.json.text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1820,
        300
      ],
      "id": "7eba0519-ca9a-4187-8ee5-9ee072f8e28c",
      "name": "Movie data from Wik"
    },
    {
      "parameters": {
        "url": "=https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&explaintext=1&titles={{ $('Improving query content').item.json.text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1640,
        -660
      ],
      "id": "9136ef0b-9615-462b-a1cb-ff4a73e29c7f",
      "name": "Person data from Wiki"
    },
    {
      "parameters": {
        "jsCode": "const results1 = $('Filtering movies by popularity').first().json.item\nconst results2 = $input.first().json.query\n\n\nconst dataString = JSON.stringify({\n  item1: results1,\n  item2: results2\n});\n\n\nreturn [\n  {\n    json: {\n      item: dataString\n  }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2040,
        300
      ],
      "id": "2ea43caf-70fe-404e-9ecb-27ff364cfe2f",
      "name": "Combining movie data"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "templates",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $('Webhook').item.json.body.template_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        2680,
        20
      ],
      "id": "899947ce-89a4-482b-b11f-31b8ad9d5151",
      "name": "Download template data for movie",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Combining movie data').item.json.item }}",
        "messages": {
          "messageValues": [
            {
              "message": "=Wciel sie w do\u015biwadczonego content creatora ze znajomo\u015bci\u0105 HTML.\nOtrzymasz od u\u017cytkownika dane, wed\u0142ug kt\u00f3ych masz zubodwa\u0107 inforgrafik\u0119 w J\u0118ZYKU ANGIESLKIM.\n\n#Szablon z kt\u00f3ego masz skorzysta\u0107 to:\n{{ $json.content }} \n\n#Zasady:\n-Mo\u017cesz zmienia\u0107 tylko pola-za\u015blepki odpowiednio zaznaczone w [[nazwa_pola]].\n-Korzystaj z komponent\u00f3w podanych w szablonie.\n-Mo\u017cesz korzysta\u0107 z Bootstrap Icons.\n-Pomi\u0144 zb\u0119dne uwagi.\n-Nigdy znie zwracaj ```html ``` Te znaki s\u0105 zb\u0119dne. Zwr\u00f3\u0107 tylko kod html.\n-Inforgrafika w sekcji content powinna mie\u0107 conajmniej 14 koponent\u00f3w.\n\n\nPrzyk\u0142ad: [[nazwa_pola]] zamieniasz na WARTO\u015a\u0106\n\n#Wskaz\u00f3wki do doboru tre\u015bci:\n-Creditsy Tw\u00f3rcy filmu\n-Sound track\n-Oceny i recenzje \n-Nagrody i nominacje\n-Premiery\n-Fabu\u0142a i inspiracje\n-Motywy przewodnie i symbolika w filmie\n-Lokalizacje i kulisy produkcji \n-Ciekawostki\n-Fun facts\n-Koszty produkcji/Bud\u017cet\n-Wyniki finansowe\n-Zasi\u0119g i wp\u0142yw filmu:\n-Wyniki box office\n-Kultura fanowska, fandomy\n-Adaptacje\n-Viralowe kampanie/trailery/kontrowersyjne plakaty\n-Przeszkody w produkcji / Za kulisami\n-Aspekty prawne i obyczajowe/Kontrowersje kulturowe\n-Odbi\u00f3r spo\u0142eczny i krytyczny\n-Technikalia produkcji\n\n#Ikony bootstrap z kt\u00f3rych mo\u017cesz korzysta\u0107:\ncamera\ncamera-video\ncassette\ndisplay\nfilm\nplay\npause\nstop\nrecord\nrecord-circle\nrecord-circle-fill\nvolume-up\nvolume-down\nvolume-mute\nheadset\nspeaker\ntv\nperson\npeople\nchat\nchat-square\nchat-left\nchat-right\nstar\nheart\naward\ntrophy\nflag\ncalendar\nclock\nalarm\nstop-watch\narrow-right\narrow-left\narrow-up\narrow-down\nchevron-right\nchevron-left\nchevron-up\nchevron-down\nplus\nplus-circle\nplus-square\ncheck\ncheck-circle\nx-circle\nmenu\nsearch\nbadge-hd\n\n\nWA\u017bNE: TRE\u015aCI MA BY\u0106 W J\u0118ZYKU ANGIELSKIM\nWA\u017bNE: JE\u015aLI MASZ MA\u0141O ZDJ\u0118\u0106 NA PRZYK\u0141AD TYLKO JEDNO UNIKAJ U\u017bYWANIA KOMPONENT\u00d3W ZE ZDJ\u0118CIAMI\nWA\u017bNE: NIE POKAZUJEMY OBRAZK\u00d3W Z WIKIMEDIA\nWA\u017bNE: NIE MO\u017bESZ KORZYSTA\u0106 Z IKON bi-ruler bi-film-fill\nWA\u017bNE: URL DO WSZYSTKICH OBRAZK\u00d3W ZAWSZE ZACZYNA SI\u0118 OD https://image.tmdb.org/t/p/w500\nWA\u017bNE: BIERZ POD UWAG\u0118 TYLKO URL PODANE Z JSON JAKO poster_path, je\u015bli nie ma takiego obrazka to nie tw\u00f3rz elementu listy obrazkowej"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        2980,
        20
      ],
      "id": "8d985b4e-0a7a-4669-895a-2ed821fbc451",
      "name": "Construction of template content for movie"
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "infographics",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "condition": "eq",
              "keyValue": "={{ $('Webhook').item.json.body.id }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "content",
              "fieldValue": "={{ $json.text }}"
            },
            {
              "fieldId": "generation_status",
              "fieldValue": "READY"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        3420,
        20
      ],
      "id": "3eab00d4-36b4-439d-93f9-c0e948b04dd4",
      "name": "Saving the content of the infographic for movie",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Improving query content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Person data from TMDB",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Movie data from TMDB",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update status if the query is SPAM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Filtering movies by popularity",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update status if video not found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Filtering people by popularity",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update status if person not found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Construction of template content for person",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Construction of template content for movie",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Improving query content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Improving query content": {
      "main": [
        [
          {
            "node": "Saving initial information to the database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Saving initial information to the database": {
      "main": [
        [
          {
            "node": "Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classifier": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Person data from TMDB": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update status if the query is SPAM": {
      "main": [
        []
      ]
    },
    "Filtering people by popularity": {
      "main": [
        [
          {
            "node": "Person data from Wiki",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combining person data": {
      "main": [
        [
          {
            "node": "Download template data for person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Construction of template content for person": {
      "main": [
        [
          {
            "node": "Saving the content of the infographic for person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download template data for person": {
      "main": [
        [
          {
            "node": "Construction of template content for person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Movie data from TMDB": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filtering movies by popularity": {
      "main": [
        [
          {
            "node": "Reading movie genres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reading movie genres": {
      "main": [
        [
          {
            "node": "Movie data from Wik",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Movie data from Wik": {
      "main": [
        [
          {
            "node": "Combining movie data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Person data from Wiki": {
      "main": [
        [
          {
            "node": "Combining person data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combining movie data": {
      "main": [
        [
          {
            "node": "Download template data for movie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download template data for movie": {
      "main": [
        [
          {
            "node": "Construction of template content for movie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Construction of template content for movie": {
      "main": [
        [
          {
            "node": "Saving the content of the infographic for movie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4f2eae67-b991-4076-a637-4af5abe4ac53",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "wWHs6Go5axATiBkc",
  "tags": []
}