I created my workflow with the help of Grok3 AI. I learned a lot along the way. Grok coded and I tested and reported any errors that appeared. The idea was to use AI to reorganize some of my texts into posts on my WordPress blog and eventually generate these posts with the help of a few keywords. to create a featured image on Pexel and place it in the post. And of course, we did it so that nothing was paid. Just so you know that I’m not a programmer and that this is my first attempt at making something like this. So if I can do it, everyone can. { "name": "Generate Free WordPress Post with Form and OpenRouter", "nodes": [ { "parameters": { "path": "create-post", "formTitle": "Create WordPress Post", "formDescription": "Enter the data to generate or rewrite a WordPress post", "formFields": { "values": [ {"fieldLabel": "Keywords (comma-separated)", "requiredField": true}, {"fieldLabel": "Number of Chapters", "fieldType": "dropdown", "fieldOptions": {"values": [{"option": "1"}, {"option": "2"}, {"option": "3"}, {"option": "4"}, {"option": "5"}]}, "requiredField": true}, {"fieldLabel": "Maximum Word Count", "fieldType": "number", "requiredField": true}, {"fieldLabel": "Original Text", "fieldType": "textArea", "requiredField": false, "description": "Enter the text you want the AI to rewrite into a blog post. If empty, AI will generate a new article."} ] }, "responseMode": "responseNode" }, "id": "form-trigger-1", "name": "Form Trigger", "type": "n8n-nodes-base.formTrigger", "typeVersion": 2, "position": [400, 400] }, { "parameters": { "assignments": { "assignments": [ {"name": "wordpress_url", "type": "string", "value": "https://your-wordpress-site.com/"}, {"name": "keywords", "type": "string", "value": "={{ $json['Keywords (comma-separated)'] }}"}, {"name": "chapters", "type": "number", "value": "={{ $json['Number of Chapters'] }}"}, {"name": "words", "type": "number", "value": "={{ $json['Maximum Word Count'] }}"}, {"name": "original_text", "type": "string", "value": "={{ $json['Original Text'] }}"} ] } }, "id": "set-1", "name": "Settings", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [600, 400] }, { "parameters": { "modelId": "google/gemini-2.0-pro-exp-02-05:free", "baseUrl": "https://openrouter.ai/api/v1", "messages": { "values": [ { "content": "={{ $json.original_text ? \"Rewrite this text into an SEO-friendly article IN SERBIAN. Return ONLY clean HTML code without any additional text, comments, explanations, or prefixes/suffixes outside HTML tags. The article should have \" + $json.chapters + \" chapters, totaling up to \" + $json.words + \" words, with an introduction (~60 words), chapters with logical flow, and a conclusion (~60 words). Use <h2> for subheadings, <b> for bold, <i> for italic, and <ul><li> for lists. Text: '\" + $json.original_text + \"'\" : \"Write an SEO-friendly article IN SERBIAN about \" + $json.keywords + \". Return ONLY clean HTML code without any additional text, comments, explanations, or prefixes/suffixes outside HTML tags. The article should have \" + $json.chapters + \" chapters, totaling up to \" + $json.words + \" words, with an introduction (~60 words), chapters with logical flow, and a conclusion (~60 words). Use <h2> for subheadings, <b> for bold, <i> for italic, and <ul><li> for lists.\" }}" } ] }, "options": {"maxTokens": 2048} }, "id": "openrouter-1", "name": "Generate Article", "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 1, "position": [800, 400], "credentials": { "openAiApi": {"id": "YOUR-OPENROUTER-API-KEY", "name": "OpenRouter API"} } }, { "parameters": { "jsCode": "const input = $node['Generate Article'].json.message.content;\n\n// Extract only HTML between the first < and last > tags\nconst htmlMatch = input.match(/<[^>]+>.*<\\/[^>]+>/s);\n\nreturn {\n json: {\n message: {\n content: htmlMatch ? htmlMatch[0] : input\n }\n }\n};" }, "id": "clean-html-1", "name": "Clean HTML", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [900, 400] }, { "parameters": { "modelId": "google/gemini-2.0-pro-exp-02-05:free", "baseUrl": "https://openrouter.ai/api/v1", "messages": { "values": [ {"content": "=Return ONLY the title IN SERBIAN, without any additional text, commas at the beginning or end, maximum 60 characters for an article about {{ $json.keywords }} based on this text: {{ $json.message.content }}"} ] }, "options": {"maxTokens": 60} }, "id": "openrouter-2", "name": "Generate Title", "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 1, "position": [1000, 400], "credentials": { "openAiApi": {"id": "YOUR-OPENROUTER-API-KEY", "name": "OpenRouter API"} } }, { "parameters": { "title": "={{ $node['Generate Title'].json.message.content }}", "additionalFields": { "content": "={{ $node['Clean HTML'].json.message.content }}", "status": "draft" } }, "id": "wordpress-1", "name": "Create Post", "type": "n8n-nodes-base.wordpress", "typeVersion": 1, "position": [1200, 400], "credentials": { "wordpressApi": {"id": "YOUR-WORDPRESS-API-KEY", "name": "WordPress API"} } }, { "parameters": { "method": "GET", "url": "=https://api.pexels.com/v1/search?query={{ $json.keywords }}%20spiritual%20mystical&per_page=1", "sendHeaders": true, "headerParameters": { "parameters": [ {"name": "Authorization", "value": "YOUR-PEXELS-API-KEY"} ] } }, "id": "pexels-1", "name": "Get Image from Pexels", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1400, 400] }, { "parameters": { "method": "GET", "url": "={{ $node['Get Image from Pexels'].json.photos[0].src.large }}", "responseFormat": "binary", "options": {} }, "id": "download-image-1", "name": "Download Image", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1500, 400] }, { "parameters": { "method": "POST", "url": "={{ $node['Settings'].json.wordpress_url }}/wp-json/wp/v2/media", "authentication": "predefinedCredentialType", "nodeCredentialType": "wordpressApi", "sendHeaders": true, "headerParameters": { "parameters": [ {"name": "Content-Disposition", "value": "attachment; filename=\"cover-{{ $node['Create Post'].json.id }}.jpg\""} ] }, "sendBody": true, "contentType": "binaryData", "inputDataFieldName": "data", "options": { "retryOnFail": true, "retryCount": 5, "retryDelay": 5000 } }, "id": "upload-1", "name": "Upload Image", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1600, 400], "credentials": { "wordpressApi": {"id": "YOUR-WORDPRESS-API-KEY", "name": "WordPress API"} } }, { "parameters": { "method": "POST", "url": "={{ $node['Settings'].json.wordpress_url }}/wp-json/wp/v2/posts/{{ $node['Create Post'].json.id }}", "authentication": "predefinedCredentialType", "nodeCredentialType": "wordpressApi", "sendQuery": true, "queryParameters": { "parameters": [ {"name": "featured_media", "value": "={{ $node['Upload Image'].json.id }}"} ] } }, "id": "set-image-1", "name": "Set Featured Image", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1800, 400], "credentials": { "wordpressApi": {"id": "YOUR-WORDPRESS-API-KEY", "name": "WordPress API"} } }, { "parameters": { "assignments": { "assignments": [ {"name": "title", "type": "string", "value": "={{ $node['Generate Title'].json.message.content }}"} ] } }, "id": "set-title-1", "name": "Set Title", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [1900, 400] }, { "parameters": { "respondWith": "json", "responseBody": "{\"formSubmittedText\": \"The article '{{$json.title}}' has been successfully created as a draft!\"}" }, "id": "respond-1", "name": "Respond Success", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1, "position": [2000, 400] } ], "connections": { "Form Trigger": { "main": [ [{"node": "Settings", "type": "main", "index": 0}] ] }, "Settings": { "main": [ [{"node": "Generate Article", "type": "main", "index": 0}] ] }, "Generate Article": { "main": [ [{"node": "Clean HTML", "type": "main", "index": 0}] ] }, "Clean HTML": { "main": [ [{"node": "Generate Title", "type": "main", "index": 0}] ] }, "Generate Title": { "main": [ [{"node": "Create Post", "type": "main", "index": 0}] ] }, "Create Post": { "main": [ [{"node": "Get Image from Pexels", "type": "main", "index": 0}] ] }, "Get Image from Pexels": { "main": [ [{"node": "Download Image", "type": "main", "index": 0}] ] }, "Download Image": { "main": [ [{"node": "Upload Image", "type": "main", "index": 0}] ] }, "Upload Image": { "main": [ [{"node": "Set Featured Image", "type": "main", "index": 0}] ] }, "Set Featured Image": { "main": [ [{"node": "Set Title", "type": "main", "index": 0}] ] }, "Set Title": { "main": [ [{"node": "Respond Success", "type": "main", "index": 0}] ] } }, "active": false, "settings": {}, "id": "new-workflow-id" }