AutomationFlowsAI & RAG › Create Structured Ebooks with Google Gemini

Create Structured Ebooks with Google Gemini

Original n8n title: Create Structured Ebooks in Minutes with Google Gemini Flash 2.0 to Google Docs

ByRanjan Dailata @ranjancse on n8n.io

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Event trigger★★★★☆ complexityAI-powered18 nodesGoogle Gemini ChatGoogle DocsChain LlmOutput Parser Structured
AI & RAG Trigger: Event Nodes: 18 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #5707 — we link there as the canonical source.

This workflow follows the Chainllm → Google Gemini Chat recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "CWailec0QgZyOq0o",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Create Structured Ebooks in Minutes with Google Gemini Flash 2.0 & n8n",
  "tags": [
    {
      "id": "Kujft2FOjmOVQAmJ",
      "name": "Engineering",
      "createdAt": "2025-04-09T01:31:00.558Z",
      "updatedAt": "2025-04-09T01:31:00.558Z"
    },
    {
      "id": "ZOwtAMLepQaGW76t",
      "name": "Building Blocks",
      "createdAt": "2025-04-13T15:23:40.462Z",
      "updatedAt": "2025-04-13T15:23:40.462Z"
    },
    {
      "id": "ddPkw7Hg5dZhQu2w",
      "name": "AI",
      "createdAt": "2025-04-13T05:38:08.053Z",
      "updatedAt": "2025-04-13T05:38:08.053Z"
    }
  ],
  "nodes": [
    {
      "id": "df2148b6-7fd7-4fcc-8baf-00e26ebf8636",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -720,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2d694214-e2d5-4543-ba6c-426cfc3264e8",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        360,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "2042e63d-16b2-4e8f-84f6-1c44d7dca305",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        940,
        240
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-exp"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "89614229-1d3b-4141-bf4f-94f47495eb6f",
      "name": "Create a Google Doc",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1320,
        20
      ],
      "parameters": {
        "title": "={{ $('Set the title, objective').item.json.title }}",
        "folderId": "default"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "3efc81bf-54c1-4c4a-bbe6-1ddf25741c90",
      "name": "Update Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1540,
        20
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $('Generate Detailed Chapter Content').item.json.text }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ $json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9cc68c5a-fcc3-4a59-93a7-08b30cc43d44",
      "name": "Set the Input Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -500,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "52ddafbb-536f-45d6-9697-7ddf5b9b3869",
              "name": "Title",
              "type": "string",
              "value": "Provide me n8n beginners guide with chapters and high-level steps"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7db4b80c-8d13-411d-b573-023ef8c0084d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        -320
      ],
      "parameters": {
        "content": "## Step 1\n\nSet the input field with the \"Title\""
      },
      "typeVersion": 1
    },
    {
      "id": "0375c56d-28a5-412a-a43c-2997c67996d9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -320
      ],
      "parameters": {
        "content": "## Step 2\n\nSet the Google Gemini Credentials as part of the LLM data extraction"
      },
      "typeVersion": 1
    },
    {
      "id": "e2d81a63-d19d-4798-aa01-42019c16437f",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -400
      ],
      "parameters": {
        "color": 6,
        "width": 540,
        "height": 240,
        "content": "## Ebook creation with Google Gemini\n\nEbook creation with Google Gemini. Export the clean data to Google Document."
      },
      "typeVersion": 1
    },
    {
      "id": "ccce17dd-e3b9-422a-ac1c-b0f63b1b3e71",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -320
      ],
      "parameters": {
        "content": "## Step 3\n\nSet the Google Document Credentials for the data export"
      },
      "typeVersion": 1
    },
    {
      "id": "b03780c2-465d-4bda-9d75-fd15eadabbe9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        -140
      ],
      "parameters": {
        "color": 5,
        "width": 1060,
        "height": 520,
        "content": "## Ebook Detailed Chapter Creation"
      },
      "typeVersion": 1
    },
    {
      "id": "16e734e6-ff86-4de5-93e0-e9b325842d97",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -140
      ],
      "parameters": {
        "color": 3,
        "width": 540,
        "height": 120,
        "content": "## LLM Usages\n\nGoogle Gemini -> Gemini 2.0 Flash Exp Model"
      },
      "typeVersion": 1
    },
    {
      "id": "b6f9f400-b2b6-409a-bfa5-28dfd1fcf437",
      "name": "Ebook Thought Creation",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -320,
        0
      ],
      "parameters": {
        "text": "={{ $json.Title }}\n\nMake sure to output as JSON",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 1.7
    },
    {
      "id": "7707ed9a-464b-4403-b698-829700a20aed",
      "name": "Google Gemini Chat Model for Ebook thought creation",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -320,
        220
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-exp"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f1e452ee-9885-4669-8885-b3229b43f9d4",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -140,
        220
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"$schema\": \"http://json-schema.org/schema#\",\n  \"title\": \"Guide Schema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"type\": {\n      \"type\": \"string\"\n    },\n    \"version\": {\n      \"type\": \"string\"\n    },\n    \"metadata\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"title\": { \"type\": \"string\" },\n        \"description\": { \"type\": \"string\" },\n        \"audience\": { \"type\": \"string\" },\n        \"author\": { \"type\": \"string\" },\n        \"category\": { \"type\": \"string\" }\n      },\n      \"required\": [\"title\", \"description\", \"audience\", \"author\", \"category\"]\n    },\n    \"structure\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"chapters\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"object\",\n            \"properties\": {\n              \"chapterNumber\": { \"type\": \"integer\" },\n              \"title\": { \"type\": \"string\" },\n              \"objectives\": {\n                \"type\": \"array\",\n                \"items\": { \"type\": \"string\" }\n              }\n            },\n            \"required\": [\"chapterNumber\", \"title\", \"objectives\"]\n          }\n        }\n      },\n      \"required\": [\"chapters\"]\n    }\n  },\n  \"required\": [\"type\", \"version\", \"metadata\", \"structure\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "b395751d-45b6-436e-91f2-8770f26d7121",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        40,
        0
      ],
      "parameters": {
        "jsCode": "return $input.first().json.output.structure.chapters"
      },
      "typeVersion": 2
    },
    {
      "id": "df04f758-2f53-404c-aa0d-d402d9fffdb1",
      "name": "Generate Detailed Chapter Content",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        920,
        20
      ],
      "parameters": {
        "text": "=Provide a detailed chapter explanation for the following\n\nTitle : {{ $json.title }}\nObjective : \n{{ $json.objectives }}\n",
        "batching": {},
        "promptType": "define"
      },
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 1.7
    },
    {
      "id": "36c8e15a-e32c-4312-a8b6-d3c7bdce4d89",
      "name": "Set the title, objective",
      "type": "n8n-nodes-base.set",
      "position": [
        700,
        20
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "39e1aa01-fca1-4226-9b21-85bd4c2c5d5a",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "21b8a776-9c14-41c4-8a54-7b8f67002842",
              "name": "objectives",
              "type": "string",
              "value": "={{ $json.objectives.toJsonString() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a8149ce8-c87b-4515-9427-620420d55fd5",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Set the title, objective",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Docs": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a Google Doc": {
      "main": [
        [
          {
            "node": "Update Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set the Input Fields": {
      "main": [
        [
          {
            "node": "Ebook Thought Creation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ebook Thought Creation": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Detailed Chapter Content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set the title, objective": {
      "main": [
        [
          {
            "node": "Generate Detailed Chapter Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Ebook Thought Creation",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Generate Detailed Chapter Content": {
      "main": [
        [
          {
            "node": "Create a Google Doc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set the Input Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model for Ebook thought creation": {
      "ai_languageModel": [
        [
          {
            "node": "Ebook Thought Creation",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Source: https://n8n.io/workflows/5707/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This n8n template automates complaint mining from unstructured text sources and turns raw user feedback into clear, actionable insights. It uses AI to identify recurring complaints, pain points, and t

Output Parser Structured, Chain Llm, Google Gemini Chat +5
AI & RAG

Content - Newsletter Agent. Uses formTrigger, chainLlm, outputParserStructured, httpRequest. Event-driven trigger; 91 nodes.

Form Trigger, Chain Llm, Output Parser Structured +8
AI & RAG

Content - Newsletter Agent. Uses formTrigger, chainLlm, outputParserStructured, httpRequest. Event-driven trigger; 87 nodes.

Form Trigger, Chain Llm, Output Parser Structured +7
AI & RAG

This template attempts to replicate OpenAI's DeepResearch feature which, at time of writing, is only available to their pro subscribers.

Output Parser Structured, OpenAI Chat, Form Trigger +8
AI & RAG

The best content automation template in the market is now even better—with “deep research” on time-sensitive topics\! Unlike most n8n content automation templates that are mainly for “demo purposes,”

OpenAI, HTTP Request, XML +11