# 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, 66.7% runs succeeded, 3 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $5.10 / 1,000 actor runs

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# 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(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).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": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,devninja/ai-document-assistant"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/1zcjkO8dWZyZJeUDQ/builds/AqOBmqcdLefJDXWdh/openapi.json
