{
  "id": "pHuWdTQCyMMPFqdV",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Generate Captions from Autocomplete Ideas using Dumpling AI + GPT-4o",
  "tags": [],
  "nodes": [
    {
      "id": "6beee45f-5f13-4dff-b560-ed1da4df5479",
      "name": "Run Every Day at 12 PM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1180,
        -120
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 12
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "795fe08c-bcb3-4563-a49c-527c09dc52a9",
      "name": "Get Search Keywords from Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -940,
        -120
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NkLQ4ZZ3qSv8HybYuKyW2BgViUij68ux4_SnoBphmWE/edit#gid=645811013",
          "cachedResultName": "Sheet2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NkLQ4ZZ3qSv8HybYuKyW2BgViUij68ux4_SnoBphmWE/edit?usp=drivesdk",
          "cachedResultName": "Google places"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "b85f5817-7b6d-4c18-8d30-7a9927ad22b2",
      "name": "Fetch Autocomplete Suggestions (Dumpling AI)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -720,
        -120
      ],
      "parameters": {
        "url": "https://app.dumplingai.com/api/v1/get-autocomplete",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"query\": \"{{ $json.Keywords }}\",\n  \"country\": \"US\",\n  \"language\": \"en\"\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "199fad98-e64a-4da1-8cdc-9ac86fe0e418",
      "name": "Format Suggestions into Array",
      "type": "n8n-nodes-base.set",
      "position": [
        -500,
        -120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "44db444a-283b-4576-85ae-d964cf761324",
              "name": "suggestions",
              "type": "array",
              "value": "={{ $json.suggestions }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "00a81bf6-91a8-4f72-9bdf-723b0b122d68",
      "name": "Loop Through Each Autocomplete Suggestion",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -280,
        -120
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "suggestions"
      },
      "typeVersion": 1
    },
    {
      "id": "8f6dcb3e-dc41-4ce8-a521-2826329efe79",
      "name": "Generate Caption from Suggestion (GPT-4o)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -60,
        -120
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are a creative content writer for social media. Write a short, engaging, and relevant caption based on the search phrase below. The tone should be friendly and inspiring, and the caption should be optimized to grab attention on platforms like Instagram, LinkedIn, or Twitter.\n\n\nMake sure the caption:\n- Feels human and conversational\n- Includes a subtle hook or curiosity element\n- Stays under 280 characters\n- Does not repeat the phrase verbatim\n\nRespond with just the caption, nothing else.\n"
            },
            {
              "content": "=Search phrase: \"{{ $json.value }}\""
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "e3483193-439c-4261-8791-82a18259efcf",
      "name": "Save Keyword & Generated Caption to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        300,
        -120
      ],
      "parameters": {
        "columns": {
          "value": {
            "Caption": "={{ $json.message.content }}",
            "Keyword": "={{ $('Loop Through Each Autocomplete Suggestion').item.json.value }}"
          },
          "schema": [
            {
              "id": "Keyword",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Caption",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Caption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NkLQ4ZZ3qSv8HybYuKyW2BgViUij68ux4_SnoBphmWE/edit#gid=1972422557",
          "cachedResultName": "content"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1NkLQ4ZZ3qSv8HybYuKyW2BgViUij68ux4_SnoBphmWE/edit?usp=drivesdk",
          "cachedResultName": "Google places"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "9b7c800e-112e-45ae-bc2a-a5fc0ad7c2ed",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1220,
        -360
      ],
      "parameters": {
        "width": 1020,
        "height": 200,
        "content": "### \u2728 Auto-Generate Social Captions from Trending Google Autocomplete\n\nThis workflow uses a search term from Google Sheets and fetches trending autocomplete suggestions using Dumpling AI\u2019s `/get-autocomplete` endpoint. Each suggestion is looped and processed by GPT-4o to generate a short social media caption. The keyword and caption pair is saved to another sheet for content reuse.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d7f0397d-853a-48c7-ac92-c4cdeb410548",
  "connections": {
    "Run Every Day at 12 PM": {
      "main": [
        [
          {
            "node": "Get Search Keywords from Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Suggestions into Array": {
      "main": [
        [
          {
            "node": "Loop Through Each Autocomplete Suggestion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Search Keywords from Google Sheet": {
      "main": [
        [
          {
            "node": "Fetch Autocomplete Suggestions (Dumpling AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Caption from Suggestion (GPT-4o)": {
      "main": [
        [
          {
            "node": "Save Keyword & Generated Caption to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Through Each Autocomplete Suggestion": {
      "main": [
        [
          {
            "node": "Generate Caption from Suggestion (GPT-4o)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Autocomplete Suggestions (Dumpling AI)": {
      "main": [
        [
          {
            "node": "Format Suggestions into Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}