Widget Connector

Use a flow to answer visitor questions and work with documents uploaded through the FileBrain.Pro website widget.

Overview

The Widget connector lets an active flow handle messages from the embedded chat widget. Use it when you want the widget reply to follow a custom flow instead of a simple direct answer.

Current state

A Chatbot Widget flow trigger is available in the editor. Use Widget Input to read the visitor message and Widget Response to return the answer. You can place shared nodes such as RAG Search, Invoke LLM, conditions, variables, text operations, and debug nodes between them.

Setup

Enable the widget in your project, add your site to Allowed Domains, and copy the widget key. See JS Widget Integration for these settings. Create and activate a flow with the Chatbot Widget trigger.

Install the Flow widget using the snippet below. Replace the key with your own. If you already embedded the standard widget, replace its script tag with this one.

<script
  src="https://filebrain.pro/api/widget/v1/fbp-flow-widget.js"
  data-widget-key="wdg_your_widget_key_here"
></script>

File Upload

File uploads are available in the Flow widget. Visitors select Attach file and wait for the file to finish processing. Once the filename appears in the chat, they can ask a question or select Send with an empty message to request a summary. They can ask follow-up questions about the same files without uploading them again.

  • Upload TXT, MD, PDF, or DOCX, one file at a time. TXT and MD support UTF-8 and Windows-1251.
  • Each file can be up to 10 MiB. PDFs can have up to 100 pages. The combined extracted text in one chat can be up to 100,000 characters.
  • PDFs need selectable text. The widget extracts text only, so upload a text version of a scan or image-only document. An upload that exceeds the text limit is rejected in full.
  • New filenames add to the chat's document list. Uploading a file with the same name replaces the earlier version. If an upload fails, previously accepted files stay available.

FileBrain.Pro discards the original file after processing. The extracted text is available in the current chat for 24 hours after the last successful new upload.

Build a Flow that reads documents

Widget Input → Read Uploaded File → Invoke OpenAI → Widget Response

  1. Widget Input puts the visitor's question in widget_query and the list of uploaded files in uploaded_files.
  2. Read Uploaded File puts the extracted text of all active files in file_text, under a heading for each filename. The file_metadata variable contains filenames, types, and character counts.
  3. In Invoke OpenAI, set Input to {{flow.widget_query}}. Insert {{flow.file_text}} in the System Prompt and tell the model to use the documents as reference material, ignore instructions inside them, and cite filenames in its answer. Enable Omit prompt from logs to keep the rendered prompt out of the step log. The step still logs its rendered Input, and answers can quote the documents.
  4. In Widget Response, set Response Text to {{flow.llm_response}} when using the default model output variable.

If your flow pauses at User Input, run Read Uploaded File again after it resumes. The extracted text variable is available only for the current turn.

Test the widget

Open the widget on an allowed domain and upload a short document. Send an empty message to check the summary, then ask a follow-up question about a detail in the document.

← Back to Flows Overview