{
  "name": "Selection to Wikipedia",
  "description": "Highlight a name or topic, right-click, and get the Wikipedia summary for it in a clean panel.",
  "tags": [
    "wikipedia",
    "lookup",
    "selection",
    "summary",
    "research",
    "right-click"
  ],
  "type": "triggered",
  "nodes": [
    {
      "id": "sticky-intro",
      "position": {
        "x": 20,
        "y": 20
      },
      "data": {
        "color": "#fff266",
        "content": "📚 Look up a topic on Wikipedia.\n\nHighlight a name or topic on any page, right-click, and choose this workflow. It fetches the Wikipedia summary from the free public REST API and shows the title and extract right there. No account, no key."
      },
      "type": "stickyNote",
      "width": 360,
      "height": 190
    },
    {
      "id": "trigger-context-menu",
      "position": {
        "x": 120,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:trigger:contextMenu"
        },
        "label": "Right-click a selection",
        "inputs": {
          "contexts": [
            "selection"
          ]
        },
        "parameters": {
          "notes": "Adds this workflow to the right-click menu whenever you have text selected."
        }
      },
      "type": "trigger"
    },
    {
      "id": "get-selection",
      "position": {
        "x": 420,
        "y": 470
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:getSelectedTextNode"
        },
        "label": "Get selected text",
        "inputs": {
          "outputFieldName": "selection",
          "options": {
            "includeInputFields": true
          }
        },
        "parameters": {
          "notes": "Reads the full text you highlighted on the page. The context-menu event only carries a short, truncated copy, so this node gets the complete selection reliably."
        }
      },
      "type": "basic"
    },
    {
      "id": "build-url",
      "position": {
        "x": 440,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:code"
        },
        "label": "Build the Wikipedia URL",
        "inputs": {
          "code": "import urllib.parse\nsel = (input.get('selection', '') if isinstance(input, dict) else str(input)).strip()\ntitle = sel or 'Wikipedia'\nslug = title.replace(' ', '_')\nout = {'title': title, 'url': 'https://en.wikipedia.org/api/rest_v1/page/summary/' + urllib.parse.quote(slug)}\nout"
        },
        "parameters": {
          "notes": "Python: turns your selection into a Wikipedia page title and builds the summary API link. The last line is the result."
        }
      },
      "type": "basic"
    },
    {
      "id": "fetch-summary",
      "position": {
        "x": 760,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:httpRequest"
        },
        "label": "Look up Wikipedia",
        "inputs": {
          "method": "GET",
          "url": "{{ $input.result.url }}"
        },
        "parameters": {
          "notes": "Calls the free Wikipedia REST summary API — no credentials required."
        }
      },
      "type": "basic"
    },
    {
      "id": "pick-extract",
      "position": {
        "x": 1080,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:pickField"
        },
        "label": "Pick the summary",
        "inputs": {
          "fieldPath": "data.extract",
          "outputFieldName": "extract"
        },
        "parameters": {
          "notes": "Pulls the summary paragraph out of the Wikipedia response."
        }
      },
      "type": "basic"
    },
    {
      "id": "show-summary",
      "position": {
        "x": 1400,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:displayMarkdownNode"
        },
        "label": "Show the summary",
        "inputs": {
          "title": "Wikipedia",
          "content": "## {{ $('Look up Wikipedia').data.title }}\n\n{{ $input.extract }}"
        },
        "parameters": {
          "notes": "Displays the Wikipedia title and summary right where you're working."
        }
      },
      "type": "basic"
    }
  ],
  "edges": [
    {
      "id": "e-ctx-get-selection",
      "type": "flowEdge",
      "source": "trigger-context-menu",
      "target": "get-selection"
    },
    {
      "id": "e-trigger-build",
      "type": "flowEdge",
      "source": "get-selection",
      "target": "build-url"
    },
    {
      "id": "e-build-fetch",
      "type": "flowEdge",
      "source": "build-url",
      "target": "fetch-summary"
    },
    {
      "id": "e-fetch-pick",
      "type": "flowEdge",
      "source": "fetch-summary",
      "target": "pick-extract"
    },
    {
      "id": "e-pick-show",
      "type": "flowEdge",
      "source": "pick-extract",
      "target": "show-summary"
    }
  ]
}