# AI Document Assistant (`devninja/ai-document-assistant`) Actor

This actor analyzes uploaded documents using AI to extract and process information. It helps businesses quickly get answers from their documents and automate decision-making.

- **URL**: https://apify.com/devninja/ai-document-assistant.md
- **Developed by:** [Devinja](https://apify.com/devninja) (community)
- **Categories:** AI, Automation, Agents
- **Stats:** 17 total users, 0 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## AI Document Assistant

AI Document Assistant is a powerful tool that helps businesses quickly extract key information from documents and get accurate answers to their questions. Upload documents like PDFs, Word files, or text formats, and leverage AI to unlock insights and improve decision-making.

### Key Benefits

- **Simplify Document Analysis:** Automatically process a variety of document types without manual reading.  
- **Accelerate Decision-Making:** Get clear, AI-generated answers to important questions about your documents.  
- **Improve Efficiency:** Save time by automating data extraction and question answering workflows.  
- **Scalable Solution:** Designed to support businesses of any size, handling documents up to 100MB.  
- **Flexible Integration:** Optional notifications allow seamless connection with your existing systems.

### How It Helps Your Business

Upload your documents and receive fast, reliable insights to support operations such as compliance checks, contract reviews, market research, or customer support. AI-powered analysis reduces human effort and minimizes errors, enabling your team to focus on high-value tasks.

### Getting Started

Simply upload your document and specify the questions you want answered. The AI Document Assistant will handle the rest — extracting relevant information and delivering clear, concise answers tailored to your needs.

### Security and Reliability

Your documents are processed securely with strict validation and cleanup to protect your data. The system is built to deliver consistent, dependable results while safeguarding sensitive information.

# Actor input Schema

## `upload_file` (type: `string`):

Upload a document file (single doc or ZIP)
## `file_url` (type: `string`):

Direct URL to document file - takes priority over uploaded file if provided
## `questions` (type: `array`):

Enter questions as JSON array: ["What is this about?", "Who wrote this?"]
## `answer_webhook` (type: `string`):

URL to submit answer results after processing completes (optional)
## `webhook_token` (type: `string`):

Bearer token for webhook authentication (optional but recommended if using webhook). Can be any custom string (e.g., 'my-secret-token-123').
## `webhook_method` (type: `string`):

HTTP method to use for webhook submission

## Actor input object example

```json
{
  "upload_file": "https://api.apify.com/v2/key-value-stores/uRftOpOPqvG64w57q/records/BitLocker-recovery-without-recovery-keys-2.0.pdf",
  "file_url": "https://api.apify.com/v2/key-value-stores/uRftOpOPqvG64w57q/records/BitLocker-recovery-without-recovery-keys-2.0.pdf",
  "questions": [
    "What is the main purpose of this document?",
    "What are the key findings or conclusions?",
    "Who is the target audience?"
  ],
  "answer_webhook": "https://your-api.com/webhook/answers",
  "webhook_method": "POST"
}
````

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "questions": [
        "What is the main purpose of this document?",
        "What are the key findings or conclusions?",
        "Who is the target audience?"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("devninja/ai-document-assistant").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "questions": [
        "What is the main purpose of this document?",
        "What are the key findings or conclusions?",
        "Who is the target audience?",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("devninja/ai-document-assistant").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "questions": [
    "What is the main purpose of this document?",
    "What are the key findings or conclusions?",
    "Who is the target audience?"
  ]
}' |
apify call devninja/ai-document-assistant --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=devninja/ai-document-assistant",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "AI Document Assistant",
        "description": "This actor analyzes uploaded documents using AI to extract and process information. It helps businesses quickly get answers from their documents and automate decision-making.",
        "version": "0.0",
        "x-build-id": "AqOBmqcdLefJDXWdh"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/devninja~ai-document-assistant/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-devninja-ai-document-assistant",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/devninja~ai-document-assistant/runs": {
            "post": {
                "operationId": "runs-sync-devninja-ai-document-assistant",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/devninja~ai-document-assistant/run-sync": {
            "post": {
                "operationId": "run-sync-devninja-ai-document-assistant",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "questions"
                ],
                "properties": {
                    "upload_file": {
                        "title": "Document File (.csv, .docx, .md, .pdf, .ppt, .pptx, .txt)",
                        "type": "string",
                        "description": "Upload a document file (single doc or ZIP)",
                        "default": "https://api.apify.com/v2/key-value-stores/uRftOpOPqvG64w57q/records/BitLocker-recovery-without-recovery-keys-2.0.pdf"
                    },
                    "file_url": {
                        "title": "Document URL (Optional)",
                        "type": "string",
                        "description": "Direct URL to document file - takes priority over uploaded file if provided",
                        "default": "https://api.apify.com/v2/key-value-stores/uRftOpOPqvG64w57q/records/BitLocker-recovery-without-recovery-keys-2.0.pdf"
                    },
                    "questions": {
                        "title": "Questions",
                        "minItems": 1,
                        "maxItems": 20,
                        "type": "array",
                        "description": "Enter questions as JSON array: [\"What is this about?\", \"Who wrote this?\"]"
                    },
                    "answer_webhook": {
                        "title": "Webhook URL For Answers",
                        "type": "string",
                        "description": "URL to submit answer results after processing completes (optional)",
                        "default": ""
                    },
                    "webhook_token": {
                        "title": "Webhook Authentication Token",
                        "type": "string",
                        "description": "Bearer token for webhook authentication (optional but recommended if using webhook). Can be any custom string (e.g., 'my-secret-token-123')."
                    },
                    "webhook_method": {
                        "title": "Webhook HTTP Method",
                        "enum": [
                            "POST",
                            "PUT"
                        ],
                        "type": "string",
                        "description": "HTTP method to use for webhook submission",
                        "default": "POST"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
