Looping over rows in Google Sheets, 3 times a day 1 row out of thousands of rows

Describe the problem/error/question

I have a Google Sheet with thousands of rows of keywords. I want to create a blog post three times a day using 1 row of keywords each time. How do I loop over the rows in the Google Sheet?

What is the error message (if any)?

Up until now, my workflow always chooses “row 1”.

Please share your workflow

{
“nodes”: [
{
“parameters”: {
“documentId”: {
“__rl”: true,
“value”: “1rXgpo-nuVAQ6qr4I6xwwsAYbKAlF_F6O0ranI7ODx54”,
“mode”: “list”,
“cachedResultName”: “fog”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1rXgpo-nuVAQ6qr4I6xwwsAYbKAlF_F6O0ranI7ODx54/edit?usp=drivesdk
},
“sheetName”: {
“__rl”: true,
“value”: “gid=0”,
“mode”: “list”,
“cachedResultName”: “Blad1”,
“cachedResultUrl”: “https://docs.google.com/spreadsheets/d/1rXgpo-nuVAQ6qr4I6xwwsAYbKAlF_F6O0ranI7ODx54/edit#gid=0
},
“options”: {}
},
“id”: “d3fc9ed5-9ddc-480d-9fa8-f0a66bb69520”,
“name”: “Get context”,
“type”: “n8n-nodes-base.googleSheets”,
“position”: [
620,
500
],
“typeVersion”: 4.5,
“credentials”: {
“googleSheetsOAuth2Api”: {
“id”: “Y2gRa3xCElWQbjnb”,
“name”: “Google Sheets account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “3e8d2523-66aa-46fe-adcc-39dc78b9161e”,
“name”: “prompt”,
“type”: “string”,
“value”: “={{ $json.PROMPT }}”
}
]
},
“options”: {}
},
“id”: “27a1aaf2-435f-4fcc-b7be-f88f2e51a6c7”,
“name”: “Set context”,
“type”: “n8n-nodes-base.set”,
“position”: [
840,
500
],
“typeVersion”: 3.4
},
{
“parameters”: {
“modelId”: {
“__rl”: true,
“value”: “=gpt-4o”,
“mode”: “id”
},
“messages”: {
“values”: [
{
“content”: “=an SEO-friendly article on these topics:\n{{ $json.prompt }}\n\nInstructions:\n- In the introduction, introduce the topic that will be covered in more detail in the rest of the text\n- The introduction should be about 60 words\n- The conclusion should be about 60 words\n- Use the conclusion to summarize everything said in the article and offer a conclusion to the reader\n- Write a maximum of 2-3 chapters.\n- Chapters should follow a logical flow and not repeat the same ideas.\n- Chapters should be related to each other and not isolated blocks of text. The text should flow and follow a linear logic.\n- Do not start chapters with "Chapter 1", "Chapter 2", "Chapter 3" … write only the chapter title\n- For the text, use HTML for formatting, but limit yourself to bold, italics, paragraphs and lists.\n- Do not put the output between ```html but only the text\n- Do not use markdown for formatting.\n- Go deeper into the topic you are talking about, don’t just throw superficial information out there\n- I only want HTML format in output”
}
]
},
“options”: {
“maxTokens”: 2048
}
},
“id”: “b3b30328-0dfe-4471-9195-d411e737df5e”,
“name”: “Generate article”,
“type”: “@n8n/n8n-nodes-langchain.openAi”,
“position”: [
1080,
500
],
“typeVersion”: 1.8,
“credentials”: {
“openAiApi”: {
“id”: “0Zl7FoMoLusyVzm7”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“updates”: [
“message”
],
“additionalFields”: {}
},
“type”: “n8n-nodes-base.telegramTrigger”,
“typeVersion”: 1.2,
“position”: [
380,
500
],
“id”: “e777e5d4-f537-45bf-97a2-f81261e171f6”,
“name”: “Telegram Trigger”,
“webhookId”: “c18a80c9-5f5a-4770-b57a-a5010f27debd”,
“credentials”: {
“telegramApi”: {
“id”: “LDmrRaZwd1mlixpx”,
“name”: “Telegram account”
}
}
}
],
“connections”: {
“Get context”: {
“main”: [
[
{
“node”: “Set context”,
“type”: “main”,
“index”: 0
}
]
]
},
“Set context”: {
“main”: [
[
{
“node”: “Generate article”,
“type”: “main”,
“index”: 0
}
]
]
},
“Generate article”: {
“main”: [

]
},
“Telegram Trigger”: {
“main”: [
[
{
“node”: “Get context”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateId”: “3085”,
“templateCredsSetupCompleted”: true,
“instanceId”: “04b09582af7d168c9220ac7117783f5fb8a5b06e79337aacaed145c9342f0aa2”
}
}

I’m new to n8n, any advice welcome!

1 Like

Hi @R4FKEN

Your workflow didnt render. Here’s a gif on how to embed your workflow in this chat.

To answer your question… I like to use a date field in the google sheet and test if today is equal to the date in the google sheets field. You can also use hours in a filter. Give me a min, and i’ll give you a sample workflow.

:heart:If this response helped you, please click the heart to show that it is useful

pasteworkflow

1 Like

@R4FKEN

Here’s a workflow that will bring in only one row at a time, and update the sheet when the blog has been sent. Run it once an hour and it should work for you.

The google sheet for this example looks like this.

:heart:If this helped you, please click the heart to show that it is useful
:white_check_mark:If this solved your issue, mark it as the solution to help the community

If you dont want to use dates and times, you can generate a random number, and send a random blog out.

2 Likes

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