Skip to content

Document

The Document component allows you to manage Microsoft Word files stored in OneDrive or SharePoint. It acts as a bridge to automate tasks like reading document text, updating content, replacing words, adding tables or images, and applying formatting styles. This component helps you build workflows that automatically modify reports, generate templates, or process data within Word documents.

How it Works

This component connects directly to the Microsoft Word API in the cloud. When you use this node, you first identify the specific document you want to work on using its ID or by selecting it from your drive. Once the document is located, the component performs the requested actions based on your inputs. It can read existing content, insert new text or images, replace specific phrases, or update tables. Finally, it returns the results of the operation, indicating success or any errors that occurred.

Connection & Credentials

This component requires configuring a credential in the Nappai panel before interacting with the external service:

  1. Go to the Credentials section in your Nappai panel.
  2. Create a new credential of the type Microsoft Word and fill in the required fields (Client ID, Client Secret, Tenant ID, and Microsoft Word Scope).
  3. In your workflow, select the saved credential in the Credential input field of this node.

Inputs

Mapping Mode

This component has a special mode called “Mapping Mode”. When you enable this mode using the toggle switch, an additional input called “Mapping Data” is activated, and each input field offers you three different ways to provide data:

  • Fixed: You type the value directly into the field.
  • Mapped: You connect the output of another component to use its result as the value.
  • Javascript: You write Javascript code to dynamically calculate the value.

This flexibility allows you to create more dynamic and connected workflows.

Input Fields

  • Operation: Select the type of operation to perform. This is a required field for the component configuration.
  • Selection Mode: Define how the component identifies the content to modify, such as by index or by text.
  • Select Documents: Choose a document from your default OneDrive to work on.
  • Document ID: The unique identifier of the Word document you want to read or edit.
  • Drive ID: The ID of the OneDrive or SharePoint drive where the document is stored. This is optional if you are using the default drive.
  • Document Content: The complete text content that will replace the document content.
  • Paragraph Text: The text to insert as a new paragraph in the document.
  • Text Content: The text content to insert at a specified position within the document.
  • Insert Position: Specify where to insert the content, such as at the start, end, or after a specific text.
  • Search Text: The text you want to search for within the document.
  • Replace Text: The new text that will replace the found search text.
  • Replace Mode: Choose how the replacement is performed, such as matching case or whole words.
  • Table Data: Provide data to create or update tables in the document as a list of rows and columns.
  • Formatting Options: Configure formatting styles like bold, italic, color, font size, and alignment.
  • Image URL: Provide the URL of an image to insert into the document.
  • Image Description: Add an alt text description for the image to improve accessibility.
  • Bulk Text Operations: Define a list of text operations to perform sequentially for bulk processing.
  • Content Format: Select the format of the content to be returned, such as Plain Text, HTML, or Markdown.
  • Paragraph Index: Specify the index number of a paragraph to target specific operations.

Outputs

The component produces a Data output that contains the result of the operation. This output includes details like whether the operation was successful, any updated content, and error messages if something went wrong. You can connect this output to other components to handle errors or process the modified document further.

Output Data Example (JSON)json

{ “success”: true, “document_content”: “The updated document text…”, “updated_paragraphs”: [“Paragraph 1”, “Paragraph 2”], “table_results”: [], “images_processed”: [], “error_message”: null, “operation_count”: 1 }

Connectivity

This component typically connects to other nodes in your workflow to process document content or handle results. After updating a document, you might connect the output to a “Save File” component to store changes or to an “Email” component to share the result. If errors occur, the output can be connected to an error handling node.

Usage Example

Scenario: Updating a Monthly Report

  1. Select Document: Use the Select Documents input to choose the “Monthly_Report.docx” file.
  2. Replace Text: Set Search Text to “Q3 2023” and Replace Text to “Q4 2023” to update the period reference.
  3. Execute: Run the workflow to update the text in the document.
  4. Review: Check the Data output to ensure success is true and view the updated content.

Tips and Best Practices

  • Always verify the Document ID or use Select Documents to ensure you are modifying the correct file.
  • When updating content, consider using Mapping Mode to dynamically insert data from other workflow nodes.
  • For large documents, use Bulk Text Operations to perform multiple changes efficiently.
  • Use Formatting Options to maintain consistency in the appearance of your automated documents.
  • Check the success field in the output to confirm that your edits were applied correctly.

Security Considerations

Ensure that your Microsoft Word credential is configured securely and that you have the appropriate permissions to access and modify the target documents. Avoid storing sensitive data in document content inputs if they might be logged or exposed in workflow outputs.