New Tool Radar

AI Agents & Automation

How to Connect a JavaScript Web Page to a Langflow Flow

Connect a JavaScript web page to a Langflow flow so visitors can chat with it from the page.

Schematic with three steps: Gather the flow connection details; Add a chat box that calls the; Test three questions on the live page.

A Langflow flow does not have to stay inside the Langflow editor: the RAG tutorial shows chatting with a flow from a JavaScript application, sending the visitor’s message to the flow and showing the reply on the page. Gather the flow details first, then write a small page that posts each message to the flow and renders the answer. Keep the flow’s API details on your server side where they belong, not in public page code.

What you need

  • A Langflow flow that already answers in the Playground
  • The flow id and the Langflow server address
  • A plain web page you can add a script to

Step 1: Gather the flow connection details

Note the flow id, the Langflow server address and which endpoint runs the flow. Test the flow in the Playground first, so you know what a good answer looks like.

Step 2: Add a chat box that calls the flow

On the web page, add a message box and a send button that posts the visitor’s message to the flow and shows the returned reply in the page. Send one message at a time and wait for the reply before accepting the next.

Step 3: Test three questions on the live page

Open the page and ask three questions with known answers from the flow’s data. Confirm each reply matches the Playground answer. If the page shows nothing, check the flow id and server address first.

Worked example: synthetic web chat test

The table below is a synthetic example. It shows the expected result of the web chat; no page was built.

Question Reply shown? Matches Playground?
Opening hours question Yes Yes
Pricing question Yes Yes
Off-topic question Yes, refused Yes

Expected result (UNTESTED). all three questions get replies on the page, and each reply matches the Playground answer. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • The page is only a front end; the flow itself still runs on your Langflow server, which must stay reachable.
  • Do not put API keys or credentials in public page code; keep them server side.
  • One message at a time is the safe pattern while testing, so a slow reply cannot stack up unanswered questions.

Sources

See all