[Question] Field name modification and format update

Describe the problem/error/question

I’d like to modify the node “Limit4” output results from the workflow below.

Current Output: There are 3 items, and each item contains: [title, content, date, url].

Desired Output:

  1. Consolidate all items into a single object like this: [title1, content1, date1, url1, title2, content2, date2, url2, title3, content3, date3, url3]

  2. For the content field:

content1: summarize to a maximum of 120 words

content2 and content3: summarize to a maximum of 60 words each

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

{
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -1264,
        3088
      ],
      "id": "090675f4-e964-4ce1-a1f3-5b2d0ed0a710",
      "name": "Loop Over Items1"
    },
    {
      "parameters": {
        "fieldToSplitOut": "rss",
        "options": {}
      },
      "id": "05263c11-1044-487c-8a03-e00d46bbb119",
      "name": "Split Out2",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1472,
        3088
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e9f27ceb-c5f2-4997-8cb1-67576a7bb337",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "4c4f9417-40f2-4fb0-9976-d09f5984680f",
              "name": "content",
              "type": "string",
              "value": "={{ $json['content:encodedSnippet'] ?? $json.contentSnippet}}"
            },
            {
              "id": "e1986bac-054e-4240-ba50-536dbcd27337",
              "name": "date",
              "type": "string",
              "value": "={{ $json.isoDate}}"
            },
            {
              "id": "e2f2d2ba-c837-445c-901a-76a7ffa9f19e",
              "name": "url",
              "value": "={{ $json.link }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "9c4c10e9-090b-4bbd-b721-6a9c3f9f8724",
      "name": "Normalize Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        -1040,
        2992
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "id": "b916faff-2946-4e25-8a3f-d01eb629b940",
      "name": "Get Articles Daily2",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1904,
        3088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b8c00469-890b-4b5b-8e2e-2ad9ec2d0815",
              "name": "rss",
              "type": "array",
              "value": "=[\n  \"https://www.engadget.com/rss.xml\",\n  \"https://feeds.arstechnica.com/arstechnica/index\",\n  \"https://www.theverge.com/rss/index.xml\",\n  \"https://www.wired.com/feed/rss\",\n  \"https://www.technologyreview.com/topnews.rss\",\n  \"https://techcrunch.com/feed/\"\n]\n"
            }
          ]
        },
        "options": {}
      },
      "id": "6b01fd40-4443-4a32-89a5-775753df1e63",
      "name": "Set Tech News RSS Feeds2",
      "type": "n8n-nodes-base.set",
      "position": [
        -1696,
        3088
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "url": "={{ $json.rss }}",
        "options": {
          "ignoreSSL": false
        }
      },
      "id": "dd7966fa-a569-4101-b42e-018c54d0a1fb",
      "name": "Read RSS News Feeds2",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        -1040,
        3136
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "content": "### Edit this:",
        "height": 240,
        "width": 220,
        "color": 3
      },
      "id": "12903e64-874d-4c55-8239-346c1a0d7723",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1744,
        3024
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -832,
        3136
      ],
      "id": "d7ccc1cb-af1d-4d4e-97fd-c74325672483",
      "name": "Limit3",
      "disabled": true
    },
    {
      "parameters": {
        "maxItems": 3
      },
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -624,
        2992
      ],
      "id": "404c9f92-7151-4894-a140-87bf5f026570",
      "name": "Limit4"
    },
    {
      "parameters": {
        "sortFieldsUi": {
          "sortField": [
            {
              "fieldName": "date",
              "order": "descending"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.sort",
      "typeVersion": 1,
      "position": [
        -816,
        2992
      ],
      "id": "aa0871e3-9d5f-4546-9164-47b63ef62524",
      "name": "Sort"
    }
  ],
  "connections": {
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Normalize Fields2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Read RSS News Feeds2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out2": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Fields2": {
      "main": [
        [
          {
            "node": "Sort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Articles Daily2": {
      "main": [
        [
          {
            "node": "Set Tech News RSS Feeds2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Tech News RSS Feeds2": {
      "main": [
        [
          {
            "node": "Split Out2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read RSS News Feeds2": {
      "main": [
        [
          {
            "node": "Limit3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit3": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit4": {
      "main": [
        []
      ]
    },
    "Sort": {
      "main": [
        [
          {
            "node": "Limit4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "53b4bb593178651bbdac72d7b42a136e37fc332f9d9fc4f5f318f92eaed7e7ca"
  }
}


Share the output returned by the last node

Information on your n8n setup

  • n8n version: Version 1.107.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Self Host Docker on my notebook
  • Operating system: Win11

See if this satisfies your requirement for the new data structure

And this should also do the summarization:

Thanks so much @jabbson ! I’ve learned how to use prompts to control the JSON format.

Sorry, due to certain limitations, I can only use Google Gemini.

I have a few questions:

  1. Should we use a node “AI Agent (with Gemini model)” to replace ChatGPT’s Message a model?

If so, how should it be configured?

  1. or alternatively, what’s the best way to perform AI summarization tasks?"
  2. I’ also would like to use AI to generate a small image for each of the 3 posts. Image resolution: 375x500px. Should I use Google’s node ‘Generate image with Gemini’? If so, where should I place it in the workflow?
  3. Alternatively, what’s the best way to generate images for each post?

Thanks

Here you go, with Gemini:

Unfortunately the generate image gemini node doesn’t support setting the resolution unlike the node from open ai. I am sure this should be possible via API request though. or you could just crop it with Edit Image node.

you can add a set node after the message a model

you can’t, a JSON is a text, an image is a binary,
depending on what you are trying to do, this may or may not be necessary.
if you really need to embed images into json, you could try to convert images to base64 strings and embed them into json, but that would bloat the JSON structure A LOT.

What are you planning to do with JSON and images at the end of your workflow?

i see, based on the docs for templater, the image needs to be provided as url. What you have are images themself. So in order to use them in the templater you need to first upload them to a storage from where it will be referenced by the templater when compiling your document.

before doing further work, first check if you can use google drive links in templater. Take one and attempt to use it to build a simple doc. POC so to say

Probably it happens because image is a paid module

Thanks @jabbson

Yes, I also contacted the official Docxtemplater support team, and they confirmed that the paid version is required to use the image feature.

We’ve decided to make a trade-off and not use the automatic image placement in PowerPoint.

I have one more question:

I would like to filter and select only news related to AI and space. May I know where I can add the prompt message for this? Or do we need to add a new AI agent node to handle it?

Thanks in advance.

I would suggest adding a new node for just this, and as to where - that depends on where you want to filter for it. It would probably make most sense to filter it as early as possible in the process, so the rest of nodes won’t need to process extra information. At most the node would go right after the loop, as a first node in the done branch.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.