{
  "name": "Email-based book recommendations with Ollama LLM and OpenLibrary API",
  "nodes": [
    {
      "id": "9840af8c-b582-4659-ae3b-869500193074",
      "name": "Ollama Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -132,
        280
      ]
    },
    {
      "id": "61b127d3-bb32-4eee-a239-c259430e9139",
      "name": "Email Trigger – Book Request",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        -440,
        60
      ]
    },
    {
      "id": "cc2e4acc-e8dc-4789-9142-1bc08977add5",
      "name": "Analyze Email with Ollama",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -220,
        60
      ]
    },
    {
      "id": "37386ba5-319e-40da-bf42-c8d2fbb0a48a",
      "name": "Create Book Search Query",
      "type": "n8n-nodes-base.set",
      "position": [
        156,
        60
      ]
    },
    {
      "id": "0c9dc4d4-c775-4ae6-bd5c-dddb0ca175ab",
      "name": "Call Book Search API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        376,
        60
      ]
    },
    {
      "id": "39dc690f-f68b-4f5d-87e0-44eb12cbb5f4",
      "name": "Check API Response",
      "type": "n8n-nodes-base.if",
      "position": [
        596,
        60
      ]
    },
    {
      "id": "727a94bd-9c95-44b6-85f7-86ee36fcda7f",
      "name": "Handle No Book Found",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        816,
        160
      ]
    },
    {
      "id": "d164e6f0-b684-4467-a4e8-0aae75878663",
      "name": "Check Book Name",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        -40
      ]
    },
    {
      "id": "efa8a98b-cd03-41ac-93f0-c1f856cff17f",
      "name": "Extract Book Summary",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1036,
        -40
      ]
    },
    {
      "id": "96c40040-623c-45df-ae94-b2813ffd5668",
      "name": "Wait for Summary Response",
      "type": "n8n-nodes-base.wait",
      "position": [
        1256,
        -40
      ]
    },
    {
      "id": "786470f7-9056-46c3-83d0-48bbf98133a5",
      "name": "Retrieve Book Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1476,
        -40
      ]
    },
    {
      "id": "641c0ba1-ccad-4462-9499-b4a28dfd0975",
      "name": "Format Book Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1696,
        -40
      ]
    },
    {
      "id": "79d33736-4931-4f7e-8ac0-07980cc8fcb9",
      "name": "Enhance Data with Code",
      "type": "n8n-nodes-base.code",
      "position": [
        1916,
        -40
      ]
    },
    {
      "id": "e19dbc55-a1c5-4070-b2ae-2f4582fe14c8",
      "name": "Generate Email Content",
      "type": "n8n-nodes-base.set",
      "position": [
        2136,
        -40
      ]
    },
    {
      "id": "c178bfca-5ee9-40d5-a0da-1b3fb0f7e5b8",
      "name": "Send Recommendation Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2356,
        -40
      ]
    },
    {
      "id": "fe5af873-7969-436c-8eaf-efed81c83665",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        -900
      ],
      "parameters": {
        "width": 600,
        "height": 360,
        "content": "## Overview: \n\nThis workflow triggers on book request emails, uses Ollama LLM to extract intent, queries a Book Search API for data (title, summary, details), handles no-book cases, formats and enhanc"
      }
    },
    {
      "id": "afa604fa-0086-4327-998b-7b720694fc42",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -880
      ],
      "parameters": {
        "width": 660,
        "height": 320,
        "content": "## How to Run:\n\n1. Ensure the email trigger is connected to a valid inbox (IMAP/Gmail).\n2. Verify the Ollama node is running with the correct model.\n3. Set valid credentials for the book search API.\n4"
      }
    },
    {
      "id": "afdc2813-f8ef-4311-bb5b-dbdd2784dfca",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -340
      ],
      "parameters": {
        "width": 540,
        "height": 860,
        "content": "## Email Input Processing\n\nTriggers on new book request emails and uses Ollama LLM to extract user intent."
      }
    },
    {
      "id": "c0a2dc78-18a6-48f8-9599-74e4d5e7c27e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1680,
        -380
      ],
      "parameters": {
        "width": 880,
        "height": 860,
        "content": "## Output Generation\n\nFormats data, refines it with code, creates a personalized email, and sends it to the user."
      }
    },
    {
      "id": "7a49c987-d940-4e65-ab52-b024d838a55c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -340
      ],
      "parameters": {
        "width": 580,
        "height": 860,
        "content": "## Book Data Retrieval\n\nGenerates a search query, fetches book data (title, summary, details) via API, and validates the response."
      }
    },
    {
      "id": "86d479fa-002c-4e2f-8239-e3ba21d3989b",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1000,
        -380
      ],
      "parameters": {
        "width": 620,
        "height": 860,
        "content": "## Data Preparation\n\nExtracts summary, ensures data readiness, and gathers additional book details."
      }
    }
  ],
  "connections": {
    "Ollama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Email with Ollama",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check Book Name": {
      "main": [
        [
          {
            "node": "Extract Book Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Book Data": {
      "main": [
        [
          {
            "node": "Enhance Data with Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check API Response": {
      "main": [
        [
          {
            "node": "Check Book Name",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle No Book Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Book Search API": {
      "main": [
        [
          {
            "node": "Check API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Book Summary": {
      "main": [
        [
          {
            "node": "Wait for Summary Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Book Details": {
      "main": [
        [
          {
            "node": "Format Book Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enhance Data with Code": {
      "main": [
        [
          {
            "node": "Generate Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Email Content": {
      "main": [
        [
          {
            "node": "Send Recommendation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Book Search Query": {
      "main": [
        [
          {
            "node": "Call Book Search API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Email with Ollama": {
      "main": [
        [
          {
            "node": "Create Book Search Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Summary Response": {
      "main": [
        [
          {
            "node": "Retrieve Book Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Trigger – Book Request": {
      "main": [
        [
          {
            "node": "Analyze Email with Ollama",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}