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
- Receives a website chat message via a public webhook that supports streaming responses and file uploads.
- Checks whether the visitor attached a file and, if so, determines whether it is a PDF or a text/Markdown document.
- Extracts text from the uploaded file (or flags it as unreadable/unsupported) and truncates it to the first 20,000 characters.
- Stores the extracted document text as hidden messages in the chat conversation memory so the agent can reference it in later turns.
- 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
- Add an OpenAI API credential (or replace the chat model node with another supported provider) and select the model you want to use.
- Publish the workflow, copy the production chat webhook URL, and embed it in your website chat widget configuration (enable file uploads).
- Set the allowed origins on the chat trigger to your website domain(s) to control where the widget can call the webhook from.
- 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).