{ "id": "12", "name": "Find a New Book", "nodes": [ { "name": "On clicking 'execute'", "type": "n8n-nodes-base.manualTrigger", "position": [ 40, 140 ], "parameters": {}, "typeVersion": 1, "id": "node-6118be04" }, { "name": "Every Friday at 11:00 AM", "type": "n8n-nodes-base.cron", "position": [ 20, 330 ], "parameters": { "triggerTimes": { "item": [ { "hour": 11, "mode": "everyWeek", "weekday": "5" } ] } }, "typeVersion": 1, "id": "node-7bf1d212" }, { "name": "Set Subject", "type": "n8n-nodes-base.set", "position": [ 220, 330 ], "parameters": { "values": { "string": [ { "name": "subject", "value": "juvenile_literature" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1, "id": "node-7b5fe406" }, { "name": "Retrieve Book Count", "type": "n8n-nodes-base.httpRequest", "position": [ 420, 330 ], "parameters": { "url": "{{ $env.BASE_URL }}", "options": {}, "queryParametersUi": { "parameter": [ { "name": "limit", "value": "0" } ] } }, "typeVersion": 1, "id": "node-1d24eca6" }, { "name": "Check Book Count", "type": "n8n-nodes-base.if", "position": [ 620, 330 ], "parameters": { "conditions": { "number": [ { "value1": "={{$node[\"Retrieve Book Count\"].json[\"work_count\"]}}", "operation": "larger" } ] } }, "typeVersion": 1, "id": "node-f64f04c1" }, { "name": "Select Random Book", "type": "n8n-nodes-base.function", "position": [ 820, 330 ], "parameters": { "functionCode": "var retrieve_book = 0;\nvar book_count = items[0].json.work_count;\n\nretrieve_book = Math.floor(Math.random() * book_count) + 1\n\nitems[0].json.retrieve_book = retrieve_book;\nreturn items;" }, "typeVersion": 1, "id": "node-56af2128" }, { "name": "Retrieve Detailed Book Info", "type": "n8n-nodes-base.httpRequest", "position": [ 1260, 330 ], "parameters": { "url": "{{ $env.BASE_URL }}", "options": {}, "queryParametersUi": { "parameter": [ { "name": "limit", "value": "1" } ] } }, "typeVersion": 1, "id": "node-e027c8cb" }, { "name": "Retrieve Basic Book Info", "type": "n8n-nodes-base.httpRequest", "position": [ 1040, 330 ], "parameters": { "url": "{{ $env.BASE_URL }}", "options": {}, "queryParametersUi": { "parameter": [ { "name": "limit", "value": "1" }, { "name": "offset", "value": "={{$json[\"retrieve_book\"]}}" }, { "name": "detail", "value": "true" } ] } }, "typeVersion": 1, "id": "node-64732383" }, { "name": "Book Recommendation", "type": "n8n-nodes-base.set", "position": [ 1830, 330 ], "parameters": { "values": { "string": [ { "name": "msgSubject", "value": "=Book Recommendation: {{$node[\"Create Author String\"].json[\"title\"]}}" }, { "name": "msgBody", "value": "=

{{$node[\"Create Author String\"].json[\"title\"]}}

\n

By {{$node[\"Create Author String\"].json[\"authors\"]}}
\n{{$node[\"Create Author String\"].json[\"description\"]}}

" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1, "id": "node-f24b03de" }, { "name": "Filtered Book Info", "type": "n8n-nodes-base.set", "position": [ 1460, 330 ], "parameters": { "values": { "string": [ { "name": "authors", "value": "={{$node[\"Retrieve Basic Book Info\"].json[\"works\"][0][\"authors\"]}}" }, { "name": "title", "value": "={{$node[\"Retrieve Basic Book Info\"].json[\"works\"][0][\"title\"]}}" }, { "name": "description", "value": "={{$node[\"Retrieve Detailed Book Info\"].json[\"description\"][\"value\"]}}" }, { "name": "URL", "value": "=https://openlibrary.org{{$node[\"Retrieve Basic Book Info\"].json[\"works\"][0][\"key\"]}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1, "id": "node-1f8772f9" }, { "name": "Create Author String", "type": "n8n-nodes-base.function", "position": [ 1630, 330 ], "parameters": { "functionCode": "var arrAuthors = items[0].json.authors;\n\nvar arrNames = arrAuthors.map(function(author) {\n return \"\" + author['name'] + \"\";\n});\n\nvar names = arrNames.join(\", \");\n\nitems[0].json.authors = names;\n\nreturn items;" }, "typeVersion": 1, "id": "node-7cb1b096" }, { "name": "Send No Book Email", "type": "n8n-nodes-base.emailSend", "position": [ 830, 520 ], "parameters": { "html": "=

Unfortunately, there are no books available for the subject of {{$node[\"Check Book Count\"].json[\"name\"]}}. Please update your n8n workflow with a different subject.

\n\n

A list of all available subjects can be found at the Open Library.

", "options": {}, "subject": "=Book not found in {{$node[\"Check Book Count\"].json[\"name\"]}}", "toEmail": "john.doe@example.com", "fromEmail": "john.doe@example.com" }, "credentials": { "smtp": "Gmail Creds" }, "typeVersion": 1, "id": "node-199641ce" }, { "name": "Send Book Email", "type": "n8n-nodes-base.emailSend", "position": [ 2030, 330 ], "parameters": { "html": "={{$node[\"Book Recommendation\"].json[\"msgBody\"]}}", "options": {}, "subject": "={{$node[\"Book Recommendation\"].json[\"msgSubject\"]}}", "toEmail": "john.doe@example.com", "fromEmail": "john.doe@example.com" }, "credentials": { "smtp": "Gmail Creds" }, "typeVersion": 1, "id": "node-f48e0602" }, { "id": "error-2b32e087", "name": "Error Handler", "type": "n8n-nodes-base.stopAndError", "typeVersion": 1, "position": [ 1000, 400 ], "parameters": { "message": "Workflow execution error", "options": {} } } ], "active": false, "settings": { "executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3 }, "connections": {}, "meta": { "instanceId": "workflow-e2e805e4", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:48.628072", "updatedAt": "2025-09-29T07:07:48.628083", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production" }, "tags": [ "automation", "n8n", "production-ready", "excellent", "optimized" ], "description": "Production-ready workflow: Find a New Book. This workflow has been optimized for production use with comprehensive error handling, security, and documentation." }