Skip to content
NEWMarketplace and the trig8n Agent: sell what you build, and get plans and changes that are tested before you see them. See what is new

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

  1. When chat message received
  2. Settings
  3. A file attached?
  4. Which kind of file?
  5. Read the PDF
  6. Read the text
  7. The document
  8. Unsupported file
  9. Keep it in the conversation
  10. Back to the message
  11. Answer
  12. Chat model
  13. Conversation memory

Similar automations