See llms.txt for all machine-readable content.

Back to Templates

Answer website chat questions about attached documents with OpenAI

Quick Overview

This workflow hosts a public chat webhook for your website where visitors can upload a PDF, TXT, or Markdown file and ask questions about it, using OpenAI to respond strictly from the document text while keeping the document in conversation memory for follow-up questions.

How it works

  1. Receives a website chat message via a public webhook that supports streaming responses and file uploads.
  2. Checks whether the visitor attached a file and, if so, determines whether it is a PDF or a text/Markdown document.
  3. Extracts text from the uploaded file (or flags it as unreadable/unsupported) and truncates it to the first 20,000 characters.
  4. Stores the extracted document text as hidden messages in the chat conversation memory so the agent can reference it in later turns.
  5. Uses an OpenAI chat model to answer the visitor’s question (or generate a short summary if only a file was sent) based only on the document content, and streams the response back to the chat.

Setup

  1. Add an OpenAI API credential (or replace the chat model node with another supported provider) and select the model you want to use.
  2. Publish the workflow, copy the production chat webhook URL, and embed it in your website chat widget configuration (enable file uploads).
  3. Set the allowed origins on the chat trigger to your website domain(s) to control where the widget can call the webhook from.
  4. If you expect long documents or long chats, adjust the 20,000-character limit and consider switching from in-process memory to a persistent chat memory (for example Postgres or Redis).