Word
NappAI has two components for working with Word documents stored in Microsoft 365. In the editor you find them in the Microsoft group with these names:
- Document works with a document’s content: it reads it, inserts paragraphs or text, finds and replaces words, shows its structure and applies formatting.
- Management handles the files: it searches for documents in a folder, looks up their details, creates them (also from a template), copies them and deletes them.
Both work with documents in .docx format.
When to use it
- You want to generate a contract or a proposal from a Word template, filling in the client’s name and the terms.
- An AI agent needs to read a Word document to answer questions about it.
- You need to update a date, a price or a name that appears several times in a document.
- You want to find every Word document in a folder to process them.
- Before changing a document, you want to save a copy in another folder.
Document
Configuration
You need a Microsoft Word credential, which connects by signing in with your Microsoft account. When you create it you choose the access level: with Read Only you can only read; to change documents, choose Full Access. See Credentials.
| Field | What it does |
|---|---|
| Credential (required) | The Microsoft Word credential used to access your documents. |
| Operation (required) | What the component does. See the Document operations table. By default, Get Document Content. |
| Selection Mode | How you point to the document: By Selector (you pick it in your OneDrive) or By Manual Entry (you type its identifier). By default, By Selector. |
| Select Documents (required) | The document you work with, picked in your OneDrive. With By Selector. |
| Document ID (required) | The document’s identifier. You get it with Management and the Search Documents operation. With By Manual Entry. |
| Drive ID | The identifier of the OneDrive drive or the SharePoint library where the document is. Empty, your OneDrive is used. With By Manual Entry. |
| Content Format | How the content is returned: plain_text, html, markdown or structured (split into paragraphs). By default, plain_text. Only in Get Document Content. |
| Paragraph Text | The text of the new paragraph. Only in Insert Paragraph. |
| Text Content | The text added inside an existing paragraph. Only in Insert Text. |
| Insert Position | Where it is inserted. In Insert Paragraph: Start (at the beginning of the document), End (at the end), Before Paragraph or After Paragraph (before or after a specific paragraph); by default, End. In Insert Text: Before Paragraph (at the start of the paragraph) or After Paragraph (at the end of the paragraph). |
| Paragraph Index | The number of the reference paragraph, counting from 0 for the first one. It appears when Insert Position is Before Paragraph or After Paragraph. |
| Search Text | The text to find. In Search Text and Replace Text. In Apply Formatting, the text the formatting is applied to; empty, it is applied to the whole document. |
| Replace Text | The text that replaces the one found. Only in Replace Text. |
| Replace Mode | How it is replaced: first_occurrence (only the first match), all_occurrences (all of them), case_sensitive (all of them, matching upper and lower case) or whole_words_only (only whole words). By default, all_occurrences. Only in Replace Text. |
| Formatting Options | The formatting applied: bold (true or false), italic (true or false), color (for example #FF0000) and font_size (size in points). Only in Apply Formatting. |
Document operations
| Operation | What it does |
|---|---|
Get Document Content | Returns the document’s text in the chosen format, with the number of characters and words. |
Insert Paragraph | Adds a new paragraph at the beginning, at the end or next to a specific paragraph. |
Insert Text | Adds text at the start or the end of an existing paragraph. |
Search Text | Finds a text and returns where it appears and how many times. |
Replace Text | Replaces one text with another and returns how many changes it made. |
Get Document Structure | Returns the document’s paragraphs, tables and images, with each paragraph’s number. It helps you know which Paragraph Index to use. |
Apply Formatting | Applies bold, italics, colour or font size to a text or to the whole document. |
Document output
The Data output returns a single item with the result: the extracted text, the matches found, the document’s structure or the confirmation of the change made. If an operation fails, the output contains an item with the error message instead of stopping the flow.
Management
Configuration
It uses the same Microsoft Word credential. To create, copy or delete documents you need Full Access.
| Field | What it does |
|---|---|
| Credential (required) | The Microsoft Word credential used to access your documents. |
| Operation (required) | What the component does. See the Management operations table. By default, Search Documents. |
| Mode | Simple shows only the essential fields; Advanced adds Search Query, Template Data and New Document Name. By default, Simple. In Search Documents, Copy Document and Create Document. |
| Selection Mode | How you point to folders and documents: By Selector (you pick them in your OneDrive) or By Manual Entry (you type their paths and identifiers in Folder Path, Target Folder Path, Document ID and Drive ID). By default, By Selector. |
| Select Folder Path (required) | The folder where you search or where the document is created. In Search Documents and Create Document. |
| Select Documents (required) | The document you work with. In Delete Document, Get Document Info and Copy Document. |
| Select Target Folder Path (required) | The folder where the copy is saved. Only in Copy Document. |
| Document Name (required) | The new document’s name. If it does not end in .docx, it is added. Only in Create Document. |
| Search Query | Text searched for in the documents’ name or content. Empty, the Word documents in the folder are returned. Only with Mode set to Advanced, in Search Documents. |
| Shallow Search | When on, only the given folder is searched; when off, its subfolders too. Off by default. Only in Search Documents. |
| Documents Count | The maximum number of documents returned. By default, 50. Only in Search Documents. |
| Template Data | To create the document from a template. Give template_path, the path of the template in your OneDrive, and replacements, the template’s placeholders and the text that replaces them, for example {{client}} with Ribera Construction. Empty, a blank document is created. Only with Mode set to Advanced, in Create Document. |
| New Document Name | The name of the copy. Empty, the original name with (copy) is used. Only with Mode set to Advanced, in Copy Document. |
Management operations
| Operation | What it does |
|---|---|
Search Documents | Searches for Word documents in a folder and returns their name, identifier, link, size and modification date. |
Delete Document | Deletes a document. |
Get Document Info | Returns a document’s details: size, access and download links, dates, who created it and who last modified it. |
Copy Document | Copies a document to another folder. |
Create Document | Creates a new document, blank or from a template. |
Management output
The Data output returns one item for each document found, or a single item with the result: the document created or copied with its identifier and link, its details or the confirmation of the deletion. If an operation fails, the output contains an item with the error message instead of stopping the flow.
Both components can be connected to an Agent as a tool, so the agent decides when to read, edit or create documents. See Tool Mode.
Example
An advisory firm wants to prepare each new client’s engagement letter automatically from its template.
- In OneDrive, the template
/Templates/Engagement letter.docxcontains placeholders such as{{client}}and{{date}}. - Add Management with the
Create Documentoperation, the firm’s Microsoft Word credential and Mode set toAdvanced. - In Select Folder Path, pick the
Clientsfolder; in Document Name, the client’s name followed byEngagement letter; and in Template Data, the template’s path and the values for{{client}}and{{date}}. - If you want to highlight the client’s name, connect the result to Document with the
Apply Formattingoperation, the name in Search Text andboldin Formatting Options.
Good practices
- Before using
Insert ParagraphorInsert Textnext to a specific paragraph, look up its number withGet Document Structure. - Before replacing text in an important document, make a copy with
Copy Document. Delete Documentdoes not ask for confirmation.