{
  "name": "Answer a Notion questions queue in place using You.com research",
  "tags": [],
  "nodes": [
    {
      "id": "14bffe39-57ae-4716-9089-31042921d546",
      "name": "When a Question Is Added",
      "type": "n8n-nodes-base.notionTrigger",
      "position": [
        48,
        736
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "REPLACE_WITH_QUESTIONS_DATABASE_ID"
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d634b4ac-7c6e-4bb1-9817-ef27e8355438",
      "name": "If Row Needs Research",
      "type": "n8n-nodes-base.if",
      "position": [
        288,
        736
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cond-question",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json['Question'] }}",
              "rightValue": ""
            },
            {
              "id": "cond-status",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['Status'] }}",
              "rightValue": "To Research"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "03b9b4aa-a1c6-40a3-a334-45c8f1e59233",
      "name": "Research the Question",
      "type": "@youdotcom-oss/n8n-nodes-youdotcom.youDotCom",
      "onError": "continueErrorOutput",
      "position": [
        768,
        720
      ],
      "parameters": {
        "input": "={{ $('When a Question Is Added').item.json['Question'] }}",
        "operation": "research"
      },
      "credentials": {
        "youDotComApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "09ce5e4c-dcad-4675-8a36-1b8cf0baec63",
      "name": "Write Answer and Mark Answered",
      "type": "n8n-nodes-base.notion",
      "position": [
        1296,
        704
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('When a Question Is Added').item.json.id }}"
        },
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Answer|rich_text",
              "textContent": "={{ ($('Research the Question').item.json.output?.content ?? 'No answer was returned.').toString().slice(0, 1900) }}"
            },
            {
              "key": "Sources|rich_text",
              "textContent": "={{ (($('Research the Question').item.json.output?.sources ?? []).map((s, i) => (i + 1) + '. ' + (s.title || s.url) + ' - ' + s.url).join('\\n') || 'No sources were returned.').slice(0, 1900) }}"
            },
            {
              "key": "Status|select",
              "selectValue": "Answered"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "442678e8-f0a8-4461-af61-be8a093e65ea",
      "name": "Log the Research Failure",
      "type": "n8n-nodes-base.notion",
      "position": [
        1296,
        912
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('When a Question Is Added').item.json.id }}"
        },
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Answer|rich_text",
              "textContent": "={{ 'Research did not complete: ' + ($json.error?.message ?? $json.error ?? 'unknown error') + '. The row was left as To Research so you can retry it.' }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "64b945c9-0ad2-488a-a6c6-97086d321f00",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        416
      ],
      "parameters": {
        "width": 728,
        "height": 668,
        "content": "## Answer a Notion questions queue in place using You.com research\n\n### How it works\n\n1. A Notion trigger picks up each new row added to your questions database.\n2. A guard skips any row with an empty question or a status that is not `To Research`.\n3. The You.com research operation answers the question and returns a cited Markdown write-up with a source list.\n4. A Notion update writes the answer and sources back into the same row and flips its status to `Answered`.\n\n### Setup steps\n\n- [ ] Install the You.com community node `@youdotcom-oss/n8n-nodes-youdotcom` (self-hosted n8n only).\n- [ ] Add You.com and Notion credentials and select them on their nodes.\n- [ ] Point `When a Question Is Added` at a Notion database with `Question` (title), `Status` (select), `Answer` (text), and `Sources` (text).\n- [ ] Add `To Research` and `Answered` as options on the `Status` select.\n\n### Customization\nRaise the depth on `Research the Question` from `standard` to `deep` or `exhaustive`, or swap the Notion trigger for a Schedule trigger that queries `Status = To Research` to run on n8n Cloud."
      },
      "typeVersion": 1
    },
    {
      "id": "cf56d67a-c1ef-457c-b887-3dd1e3822f22",
      "name": "Section Intake",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        560
      ],
      "parameters": {
        "color": 7,
        "width": 568,
        "height": 384,
        "content": "## Intake and guard\n\nA Notion trigger fires on each new question row, and the guard drops empty or not-ready rows before spending a research call."
      },
      "typeVersion": 1
    },
    {
      "id": "5e622028-06c2-43cd-80eb-aa609375fabd",
      "name": "Section Research",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        544
      ],
      "parameters": {
        "color": 7,
        "width": 428,
        "height": 368,
        "content": "## Research the question\n\nYou.com researches the question and returns a cited Markdown answer plus a source list in a single call."
      },
      "typeVersion": 1
    },
    {
      "id": "10a15ddb-6578-46ab-807e-411b50b3a232",
      "name": "Section Answer",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        480
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 620,
        "content": "## Answer in place\n\nThe same row gets the answer and sources written back and its status flips to `Answered`. A failed lookup logs a note and leaves the row as `To Research` so you can retry it."
      },
      "typeVersion": 1
    },
    {
      "id": "6a6497f0-21c5-42ec-b6ac-68e9646732ec",
      "name": "Warning self-hosted",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        992
      ],
      "parameters": {
        "color": 3,
        "width": 716,
        "height": 150,
        "content": "## Self-hosted only\n\nThe You.com node is a community node, so this runs on self-hosted n8n. On n8n Cloud, use the HTTP Request plus Schedule trigger variant described in the README."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "If Row Needs Research": {
      "main": [
        [
          {
            "node": "Research the Question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research the Question": {
      "main": [
        [
          {
            "node": "Write Answer and Mark Answered",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log the Research Failure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When a Question Is Added": {
      "main": [
        [
          {
            "node": "If Row Needs Research",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}