Fetching only 1 row instead of all from Google Sheets in the results

Describe the problem/error/question

Hi, there!
So I’m trying to build a flow that will

  • Read an google docs file and read keyword inserted
  • Create a blog post with: title, text and link
  • Update the sheet with written blog posts
  • Insert the post in wordpress.

So far so good, however it is failing at one point.
In the Write a blog node, I’m asking the chatgpt to:

You must try to use minimum 3 related keywords in the article “{{ $json.Keyword }}” and include their links “{{ $json.Url }}” as markdown internal links in the article"

So basicly, what I want is to go in the google sheet document (written blogpost) and get all the keywords we have previously written and all the articles we have previously written and include them in the new article. So basicly build internal links.

However, the problem is: It is only including the first keyword written in the google sheet which we fetch from “Written articles”. Instead of going through the list of all keywords written and all internal links, it is just including the 1 keyword and link to that article and I know it should be including more.

Any advice?

Please share your workflow

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Mec ,
thanks for getting in touch and for using n8n!

The problem that I see is that in the “Write a blog” Node you will receive an array of objects with a title and a keyword each. Then since you (correctly) set the “Execute Once” option, only the first object in the array is used, and thus it is using only the contained Keywork (which is just one).

I tried to re-organize the first part of your workflow like this:

  • First of all, I write the new title using the Node “Write a blog title1”. This is also executed once, so if two new keywords are added to the Google Sheet within one minute, only the first one will be used.
  • Then I retrieve the full list of keywords and their respective Urls (Node “Google Sheets”). You could do something similar with the “Written” sheet if you want to link to the articles.
  • The “Items Lists” allow me to re-organize the data coming from Google Sheets and produce an output that will be easily used in the following node:
[
  {
    "Keyword": [
      "agile",
      "discovery",
      "planning",
      "growth"
    ],
    "Url": [
      "https://website.com/blog/agile",
      "https://website.com/blog/discovery",
      "https://website.com/blog/planning",
      "https://website.com/blog/growth"
    ]
  }
]
  • In this way in the “Write a blog1” Node, you will find that in Keyword and Url we are inserting an array of keywords and their URLs (instead of just one): Include the answers as part of the article. You must try to use minimum 3 related keywords in the article ""agile", "discovery", "planning", "growth"" and include their links ""https://website.com/blog/agile", "https://website.com/blog/discovery", "https://website.com/blog/planning", "https://website.com/blog/growth"" as markdown internal links in the article"

Let me know if this helps
Best

4 Likes

@giulioandreini

Thank you so much! This solved my issue!
Fantastic support and awesome community!

1 Like

Glad to hear that @Mec :slight_smile:

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