Document QA
This workflow is a system designed to answer questions about the content of a specific document stored in Google Drive. It acts as an assistant that can "read" a file and respond to queries about its information.
Go to template📄 Document QA Workflow
🧩 Overview
The workflow automatically fetches a specified document from Google Drive, processes its contents into plain text, and combines that text with a user’s question to create a prompt. The prompt is sent to an OpenAI language model, which returns an answer that is delivered back to the user through a chat interface. This system streamlines the extraction and answering of information from arbitrary documents, eliminating manual reading and summarization.
⚙️ Main Features
- Retrieves a user‑specified file from Google Drive.
- Converts file data into clean, text‑ready content.
- Dynamically builds a prompt that embeds both the document text and the user’s question.
- Sends the prompt to an OpenAI model to generate a contextual answer.
- Streams the model’s response back to the user in chat form.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Chat Input | Receives the user’s question. | User message text | Question message |
| Google Drive File Manager | Fetches the specified file from Google Drive. | File name or ID, access credentials | Raw file data |
| Parse Data | Transforms raw file data into plain text. | Raw file data | Document text |
| Prompt | Builds a prompt that includes the document text and the user’s question. | Document text, user question | Prompt message |
| OpenAI Model | Generates an answer based on the prompt. | Prompt message | Generated answer text |
| Chat Output | Delivers the answer back to the user. | Generated answer text | Chat message to user |
🧠 Notes
- The workflow requires that the user has permission to access the targeted Google Drive file and that the file type is supported by the Google Drive File Manager component.
- The Parse Data component assumes the input can be rendered as plain text; binary or highly structured files may need additional preprocessing.
- The OpenAI Model component uses the “gpt‑4o‑mini” model by default, but this can be overridden via configuration.
- Conversation history is stored only when the “Store Messages” flag in the Chat Input component is enabled.
- Valid API credentials for both OpenAI and Google Drive must be configured before execution.
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
ChatInput-t1dhv[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Input]
style ChatInput-t1dhv stroke:#a170ff
OpenAIModel-b5y7n[<div><img src="/_astro/openAI.CA91HhVI.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-b5y7n stroke:#a170ff
ChatOutput-eun7o[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-eun7o stroke:#a170ff
GDriveFilesComponent-mgn88[<div><img src="/_astro/google_drive.Cutj2ebY.svg" style="height: 20px !important;width: 20px !important"/></div>Google Drive File Manager]
style GDriveFilesComponent-mgn88 stroke:#a170ff
ParseData-kfvde[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Parse Data]
style ParseData-kfvde stroke:#a170ff
Prompt-qq08j[<div><img src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Prompt2]
style Prompt-qq08j stroke:#a170ff
OpenAIModel-b5y7n -.- ChatOutput-eun7o
linkStyle 0 stroke:#a170ff
GDriveFilesComponent-mgn88 -.- ParseData-kfvde
linkStyle 1 stroke:#a170ff
ParseData-kfvde -.- Prompt-qq08j
linkStyle 2 stroke:#a170ff
ChatInput-t1dhv -.- Prompt-qq08j
linkStyle 3 stroke:#a170ff
Prompt-qq08j -.- OpenAIModel-b5y7n
linkStyle 4 stroke:#a170ff