Library / AI Agents & Assistants
AI Agents & Assistants
Answer website chat questions about attached documents with OpenAI
When a chat message arrives, it runs an AI agent with OpenAI / ChatGPT.
What it does
## Answer questions about a document your visitor attaches A chat on your website where the visitor attaches a PDF, a .txt or a .md file and asks about it. The agent answers from the document only, quotes it, and remembers it for the rest of the conversation. A file sent without a question gets a short summary. ### Requirements - An n8n instance the visitor's browser can reach on a public URL. Tested on n8n 2.45.7. - An OpenAI API key, or credentials for any other chat model n8n supports. ### Set up 1. Open Chat model and add your OpenAI credential, or swap in any chat model. 2. Open When chat message received, put your site in Allowed Origins, then publish the workflow and copy the production URL that ends in /chat. 3. Paste this in your page, with your URL: html import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.1.0/dist/cdn/n8n-chat.js'; createChat({ webhookUrl: 'YOUR_PRODUCTION_URL', allowFileUploads: true }); That widget is @aparte/n8n-chat (MIT): the visitor drops, pastes or picks a file, and finds the conversation again after a reload. n8n's own widget (@n8n/chat) works with this workflow too, with the same allowFileUploads: true.
The steps
- When chat message received
- Settings
- A file attached?
- Which kind of file?
- Read the PDF
- Read the text
- The document
- Unsupported file
- Keep it in the conversation
- Back to the message
- Answer
- Chat model
- Conversation memory
Similar automations
AI Agents & AssistantsAnswer Weather Questions with OpenAI and Open-Meteo6 stepsAI Agents & AssistantsAnswer Hacker News Questions with an OpenAI Agent Tool9 stepsAI Agents & AssistantsTurn Email Questions into SQL with Ollama and Claude23 stepsAI Agents & AssistantsAnswer Questions with an OpenAI Agent and SearchApi5 steps