> ## Documentation Index
> Fetch the complete documentation index at: https://wordsmithai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n

> Ask Wordsmith agents, review, redline and draft documents, and manage tasks from n8n workflows, and start workflows from Wordsmith events.

The Wordsmith nodes for n8n let a workflow send legal work to Wordsmith and use the result in later steps. Files move as n8n binary data, so a contract from Gmail, Google Drive or SharePoint goes straight into a review, and the redline comes straight out.

> [!NOTE]
>
> The package, `@wordsmith-ai/n8n-nodes-wordsmith`, is a community node. Until n8n verifies it, only self-hosted n8n can install it. See [Install the nodes](#install-the-nodes).

## Nodes

The package has three nodes:

* **Wordsmith**: the actions below.
* **Wordsmith Trigger**: starts a workflow the moment something happens in Wordsmith.
* **Wordsmith Polling Trigger**: checks Wordsmith on a schedule, for when instant triggers aren't available.

### Actions

| Resource | Action | What it does |
| - | - | - |
| Agent | **Ask an agent** | Asks an agent a question or gives it an instruction, with optional files, and waits for the answer. |
| Agent | **Get an answer** | Gets a question you asked, with its answer if it is ready. |
| File | **Upload a file** | Stores a binary file in your private Wordsmith space and returns its ID. |
| File | **Get a file** | Gets a Wordsmith file as binary data, with its `web_url`. |
| Document | **Redline a document** | Makes edits to a Word document as tracked changes, from instructions in plain language. |
| Document | **Compare two documents** | Shows the changes between two versions as tracked changes. |
| Document | **Convert a document** | Converts Word to PDF, or PDF to Word. |
| Review | **Review a document** | Reviews contracts against a playbook or your own instructions, or reviews the other side's edits. |
| Review | **Find a review** | Gets a review by its ID, or searches reviews by name. |
| Draft | **Draft a document** | Drafts a document from instructions, or from a blueprint with one field per placeholder. |
| Task | **Create a task** | Creates a task. Assign it to an agent to have the agent start on it, or to a person. |
| Task | **Update a task** | Changes a task's status, assignee, priority, due date, title or description. |
| Task | **Add a comment to a task** | Posts a comment, with optional files. |
| Task | **Attach files to a task** | Adds files to a task's inputs. |
| Task | **Find a task** | Gets a task by its ID or number, such as `#12`, or searches tasks. |
| Job | **Get a job** | Gets a background job's status and result. |

Every input that takes a file takes either a binary field from an earlier node or the ID of a file already in Wordsmith. Every action that produces a file puts it in a binary field (`data` by default) and outputs its `file_id`, `file_name` and `web_url`. Share `web_url` with people: it needs Wordsmith sign-in and does not expire.

### Waiting for long work

Asking an agent, reviewing, redlining, comparing, converting and drafting run in the background. By default the step waits until Wordsmith has finished, for up to **Maximum Wait** (15 minutes). If the work takes longer, the step fails and names the job ID, so a later **Get a job** step can read the result.

To wait without holding the step, turn off **Wait for Result**. The step then returns the job at once. Set **Callback URL** to `{{ $execution.resumeUrl }}` and add a **Wait** node set to **On Webhook Call**: the workflow resumes when Wordsmith calls back.

If n8n retries a step, it sends the same idempotency key, so Wordsmith does not start the work twice.

### Answers

**Ask an agent** outputs:

* `answer`: the answer in Markdown.
* `answer_html`: the same answer as an HTML fragment for an email body.
* `status`: `completed`, or `filtered` when the agent's API intake declined the question. `reason` then says why. Branch on `status` with an **If** node.
* `session_id` and `session_url`: the conversation. Pass `session_id` as **Conversation ID** to continue it.
* `attachments`: files the agent created. Turn on **Download Answer Files** to get them as binary data.

The step fails when the agent could not answer, and shows any partial answer.

### Triggers

| Trigger | Starts when | Output |
| - | - | - |
| **New task** | A task you can see is created. | The task. |
| **Task assigned** | A task is created already assigned, or gets a new assignee, team or agent. Optionally only tasks assigned to you. | The task. |
| **Task status changed** | A task's status changes, by default to completed. | The task, with the old and new status. |
| **Review completed** | A review finishes, wherever it was started. | The review. |
| **Any Wordsmith event** | Any event type you choose, such as `task.*`. | The event. |

**Wordsmith Trigger** registers a [webhook endpoint](https://wordsmithai.mintlify.site/webhook-endpoints.md) when you activate the workflow and removes it when you deactivate it. It checks every request's signature. Your n8n instance must be reachable on a public https URL, and each user can have up to 10 endpoints.

> [!NOTE]
>
> Instant triggers are rolling out. If activating **Wordsmith Trigger** says they aren't on for your organisation, use **Wordsmith Polling Trigger** with **New task**, **Task status changed** or **Review completed**.

**Wordsmith Polling Trigger** reads Wordsmith on the schedule you set. Its first check only records what exists, so turning a workflow on never replays old work. **New task** reads open tasks involving you, ordered by priority, so on a busy account it can miss a task beyond the first 100.

## Install the nodes

On self-hosted n8n, an owner or admin installs the package once:

1. Open **Settings → Community Nodes** and select **Install**.
2. Enter `@wordsmith-ai/n8n-nodes-wordsmith`, tick the box to accept the risks, and select **Install**.

To let an n8n **AI Agent** use the Wordsmith node as a tool, set `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true` in n8n's environment and restart n8n. The node's operations are described for a model, so an agent can ask Wordsmith, review a document or create a task on its own.

## Connect

1. In Wordsmith, open **Settings → API keys** and create an API key for the user the workflows should act as. The key acts with that user's access. For workflows that serve a whole team, create the key as a user who can see that team's work.
2. In n8n, create a **Wordsmith API** credential. Choose your **Region**, Europe or United States, and paste the key.

n8n checks the key when you save the credential. A key limited to some scopes needs the scopes of the actions you use, such as `sessions:write` to ask an agent or `reviews:write` to run a review. **Wordsmith Trigger** also needs `webhooks:read` and `webhooks:write`.

To create a task for an agent, first add **API** as an intake on that agent's configuration page. The **Agent** list in **Create a task** shows only agents with that intake.

## Example: review a contract from an email

1. **Gmail Trigger**: on new email with an attachment, with **Download Attachments** on.
2. **Wordsmith → Review a document**: **Against a Playbook**, your playbook, and **Binary Fields** set to `attachment_0`.
3. **Gmail → Reply**: put `issues_text` and the review's `url` in the body, and attach the `data` binary field, which holds the redline.

## Limits

* An uploaded file can be up to 1 GB. A file from a link can be up to 100 MB.
* A question takes up to 10 files, and a review up to 10 documents.
* **Find a task** and **Find a review** return up to 50 matches unless you turn on **Return All**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.