Skip to content

Extract a brand's name, logo and colors from a website ​

What you get: A workflow that turns a website URL into one JSON object: brand name, logo URL, primary and accent color, font and tagline.

Needs: OpenAI API key and Playwright Chromium · Time: 15 minutes · Nodes: 6

A Text Input holds the URL (https://example.com as shipped). Web Browse opens it in headless Chromium, waits for the network to go quiet, and extracts the title, text, meta tags, images and a screenshot. A Prompt Template puts the title, the description, Open Graph image and theme-color meta tags, the first 10 images and the first 4,000 characters of text into an extraction prompt. An LLM Call answers it, an Output Parser checks the JSON, and the Output returns it. It needs an OpenAI key as shipped and Chromium for Playwright on the API host. Read what the model really sees before you rely on colors and fonts.

Steps ​

  1. Download branding-extract-flow.json, or take it from the samples folder on GitHub.

  2. In the studio's workflow editor, import the file (see import and export).

  3. Install Chromium for Playwright on the API host once: pnpm exec playwright install chromium from the repo root (Playwright itself comes with the workflow engine). Or point PDF_CHROMIUM_EXECUTABLE_PATH at a Chromium you already have.

  4. Open the LLM node and pick a stored secret with your OpenAI API key under API Key Secret (or set OPENAI_API_KEY on the API server), or switch the provider. Save. Without a key the LLM node fails with Provider openai requires an API key via secretRef or OPENAI_API_KEY.

  5. Run it. A user_prompt sent with the run replaces the Text Input's URL, so you can try other sites without editing the workflow. Put an API key from Settings → Account → API Keys in L2M_API_KEY:

    bash
    curl -X POST http://localhost:4000/api/workflows/wf-branding-extract-flow/execute \
      -H "Authorization: Bearer $L2M_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"user_prompt": "https://www.wikipedia.org"}'
  6. Open the run: Parse JSON holds the object, and the Output returns it as a JSON string in result.

How it works ​

Diagram of the Brand Extraction (Web Browse) workflowRuns Brand URL, then Fetch Brand Site, then Extract Branding, then LLM, then Parse JSON, then Output.Brand URL (text_input)Brand URLtext_inputFetch Brand Site (web_browse)Fetch Brand Siteweb_browseExtract Branding (prompt_template)Extract Brandingprompt_templateLLM (llm_call)LLMllm_callParse JSON (output_parser)Parse JSONoutput_parserOutput (output)Outputoutput
Solid arrows are the order the steps run in. Dashed lines attach a chat model, memory, tools or workers to an agent; the agent uses them while it runs.
NodeTypeRole
Brand URLtext_inputStep in the run
Fetch Brand Siteweb_browseStep in the run
Extract Brandingprompt_templateStep in the run
LLMllm_callStep in the run
Parse JSONoutput_parserStep in the run
OutputoutputStep in the run

6 node types. Each type links to its config fields in the node reference.

Web Browse: pages that need JavaScript ​

A plain HTTP request gets the HTML a server sends. Many sites build the page in the browser, so that HTML is nearly empty. Web Browse loads the page in headless Chromium through Playwright, runs its scripts and reads the result. The sample waits for networkidle, allows 45 seconds, and uses a 1440 x 900 viewport. Besides the nested brandSite object, it puts url, title, text, html, screenshot, meta, links and images at the top level for the next node. Each call starts and closes its own browser, so keep it to low-volume flows.

Without Chromium the run fails at this node. We pointed PDF_CHROMIUM_EXECUTABLE_PATH at a missing file to check: Fetch Brand Site failed with browserType.launch: Failed to launch chromium because executable doesn't exist at ..., the later nodes were skipped, and the run ended with an error.

What a run does ​

We ran it with Chromium installed and no model key. On https://example.com the browse step took about 0.9 seconds and returned the title Example Domain, the page text and a screenshot, with no images and no Open Graph tags. On https://www.wikipedia.org it took about 1.5 seconds and found an og:image, a description and a list of image URLs, the Wikipedia logo first. The prompt then held the title, the description, the og:image URL, an empty theme color (the page sets none), the images and the first 4,000 of 4,077 characters of text.

  • With the echo provider, the model only repeats the prompt, so there is nothing real to parse. The parser picked up the image list from the echoed prompt (see below), and the Output returned that list.
  • With a scripted stand-in model that answers with one JSON object (the page title as brand, the og:image URL as the logo, empty colors and font), the parser accepted it on the first try, and the Output returned {"brand":"Wikipedia","primaryLogoUrl":"https://upload.wikimedia.org/...","primaryColor":"",...} as result.

The stand-in shows the plumbing. How well a real model fills in each field depends on the model and the page.

What the model really sees ​

The prompt gives the model the page title, three meta tags (description, og:image, theme-color), up to 10 image URLs and up to 4,000 characters of visible text. It does not send the screenshot, the HTML or any CSS, so the model never sees a color or a font on the page. The prompt says so, and asks for a color or font only when the data states it, such as a theme-color meta tag, and an empty string otherwise. Expect empty colors on many sites. The brand name, the logo URL and the tagline come from real page data and are the reliable part.

The template reads meta tags with {{ meta["og:image"] }}: a simple path such as meta.og:image cannot hold a colon, and would render empty. It trims lists with {{ images.slice(0, 10) }} and {{ text.slice(0, 4000) }}. The browse node keeps the screenshot in the run so you can check the page yourself; set screenshot: false if you do not need it.

Parsing and the final output ​

The Parse JSON node runs in json_schema mode with lenient parsing: it reads the first JSON value it finds in the reply. The schema requires brand and primaryLogoUrl. If the value fails the check, the node asks the same model up to 2 more times to fix it, then fails. The checks apply only when the value is an object: an array passes as it is. That is how the echo run passed with the image list. A real model that follows the prompt returns one object, but if it adds a list before the object, the parser takes the list. Check parserTrace on the node when the result looks wrong.

The Output node's response template is {{parsed}}, so the run returns the object as a JSON string in result.

Outbound URL checks ​

The URL can come from whoever calls the workflow, so it is checked. Web Browse refuses file: URLs, and every request the page makes, including redirects and images, goes through L2M's outbound URL checks: cloud metadata addresses and link-local ranges are always refused. Private ranges and localhost are allowed by default. Set OUTBOUND_DENY_PRIVATE=true if callers must not reach your internal network through this node. Page text is untrusted input: a page can carry instructions aimed at the model, so do not give this workflow tools that act on what a page says.

Make it yours ​

  • Take the URL from a webhook: replace the Text Input with a Webhook Input; the browse node's URL template is already {{user_prompt}}.
  • Set screenshot: false on the browse node: the prompt does not use it, and it adds a large base64 image to every run.
  • Feed the JSON to a report: the PDF report with charts recipe builds an HTML page and a PDF, and can take colors from here.
  • Swap OpenAI for another provider on the LLM node.

Make it safer ​

These controls are optional; the recipe runs without them.

  • Turn on OUTBOUND_DENY_PRIVATE and list the internal hosts you do want in OUTBOUND_ALLOWLIST: see outbound URL checks.
  • Cap model spend with a budget.
  • Read prompt injection before you add tools to any workflow that reads web pages.

Further reading ​

This website (not the L2M product) uses Google Analytics, only after you accept cookies. Cookie settings