All templates

AI

Ask Questions About Workflow Data

Ask a question and answer it with verified excerpts from records returned by a configured workflow.

Use in Open Flow
Ask Questions About Workflow Data workflow in Open FlowAsk Questions About Workflow Data workflow in Open Flow

Ask a question and answer it with verified excerpts from records returned by a configured workflow.

Setup

  1. Import the workflow bundle. Open Find Business Documents and set the records input on Search configured records to an array of records you may share with OpenAI. Each record is a JSON object. The bundled worker searches for words from the question in the records. It starts with an empty list.
  2. To query your own data source, replace the search step inside Find Business Documents with a read from that source. Keep the Start input query as a string and the workflow output documents as an array of objects. Return one object per record in the order you want it presented.
  3. Publish Find Business Documents. In Ask Questions About Workflow Data, refresh the published workflow capability in Retrieve workflow documents and set the OpenAI connection in Verify answer excerpts.
  4. Run Enter a question manually with your question. Open Return the answer to see the result.

Behavior

The workflow sends your question to the configured worker. When records are returned, OpenAI selects excerpts and the workflow checks each quote against the cited record. Sources are numbered in worker output order. An empty result yields no_documents without calling OpenAI. If the returned documents contain no answer, the result is insufficient_evidence. A worker error or an invalid model response fails the run.

Questions can be up to 2,000 characters. Each query can return up to 30 documents, within 60,000 characters of serialized documents and their numbering. Narrow the question or scope of the worker if the results exceed those limits. Include only fields the question needs and that you are authorized to share.

In n8n

Import the JSON. In Retrieve workflow documents, select a saved, authorized workflow as the database source and allow this caller to invoke it. Its Execute Sub-workflow Trigger must accept a string field named query or accept all input data. If the input mapper displays a query field, set it to {{ $json.query }}. Return one JSON object per document on the worker’s final output. Return zero items for a search with no results.

Set the question in Enter a question. In Select evidence with OpenAI, attach an HTTP Header Auth credential with the header Authorization and the value Bearer YOUR_OPENAI_API_KEY. Run the caller manually. It waits for the local worker and returns the same answer fields.

Inspiration & credits

Changes to the source

  • Provide an editable business data worker for Open Flow. The n8n caller selects an authorized worker on the same instance.
  • Verify cited excerpts against the original records and return a clear result when retrieval finds zero records.

Adapted from AI: Ask questions about any data source (using the n8n workflow retriever) by the n8n Team, collected in enescingoz/awesome-n8n-templates. Fixed source workflow.

Source collection notice: © 2024–2026 Enes Cingoz, CC BY 4.0. This adaptation includes the changes above. See repository licensing.