# Compare the contents of two documents with Power Automate

## Objective <a href="#objective" id="objective"></a>

In this example we’ll be achieving the following objective with a fictional organisation named “10docs Ltd”, a large retailer.&#x20;

> Compare an NDA that a third party has asked us to sign with the standard NDA used by 10docs.  The differences described should enable the 10docs legal team to more quickly assess if a contract should be signed.&#x20;
>
> *Note: This is a tool to help compare legal documents. It can miss things, and it doesn't constitute legal advice, that can only be provided by a qualified legal practitioner.*&#x20;

The differences should be described like this:

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2Fva8ZTId8pXChebfAPYyg%2Fexcel-compare-differences-report%402x.png?alt=media&#x26;token=4678a904-7937-4039-bf1d-db3b5e6306f8" alt=""><figcaption></figcaption></figure>

## Setup <a href="#setup" id="setup"></a>

Power Automate is a growing platform, with an enormous number of first and third party connectors. Tendocs works with them all. To keep it simple, this example uses the following connectors:

1. SharePoint for Document storage
2. Tendocs for comparing the documents&#x20;
3. Tendocs for creating the document summarising the differences

**If you need any help along the way, feel free to reach out to the** [**support**](https://cal.com/tendocs) **team.**

### Assets <a href="#assets" id="assets"></a>

So you can test this yourself, exactly as described here, you can download copies of the sample documents used. Then, to get started, all you need is a SharePoint site with a Document Library where you can upload them.

1. [Standard-NDA-Third-Party Sample](https://assets.tendocs.com/website-assets/samples/Standard-NDA-Third-Party.docx).
2. [Standard-NDA-10Docs Sample](https://assets.tendocs.com/website-assets/samples/Standard-NDA-10Docs.docx).
3. [Compare-Documents-Report-Template](https://assets.tendocs.com/website-assets/samples/Compare-Documents-Report-Template.xlsx)

### Preparing the basics <a href="#preparing-the-basics-images-and-documents" id="preparing-the-basics-images-and-documents"></a>

1. Create a new Document Library in a SharePoint Team Site. This is where 10docs will store their version of contracts (like an NDA).&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FObyT7QcDzi7Yo7Dbk4mY%2Fstandard-10docs-contract%402x.png?alt=media&#x26;token=546c5130-57f6-4db6-8397-1eade4d0a6fd" alt=""><figcaption><p>Document Library for 10docs Contracts</p></figcaption></figure>

2. Create another Document Library in a SharePoint Team Site. This is where 10docs will store the contracts they are asked to sign by third parties.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FZKy68B53w39a2ETO0D6y%2Fthird-party-contracts%402x.png?alt=media&#x26;token=f6b332b5-e443-455b-b62a-02369f8cb447" alt=""><figcaption><p>Document Library for Third Party Contracts</p></figcaption></figure>

### Create the Flow

3. Then go to the Power Automate home page.
4. Create a new Flow “Instant Cloud Flow”, and then complete as follows.

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FeovsNkCAzKp5NjYwLnMQ%2Fcontract-differences-flow%402x.png?alt=media&#x26;token=35a7ae1b-760b-4ae1-828c-46115f60beaa" alt=""><figcaption></figcaption></figure>

3. Add the "Get File Contents" action to retrieve the standard 10docs NDA contract.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2Fnnc7czmJD9mHTuPWh320%2Fget-10docs-nda%402x.png?alt=media&#x26;token=b6602143-c181-4f0f-ac42-23480b51d945" alt=""><figcaption><p>Get the File Contents of the 10docs NDA</p></figcaption></figure>

3. Add the "Get File Contents" action to retrieve the standard NDA contract provided by the third party.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FvyoE9bmBMagwJI9UQ9m5%2Fget-third-party-contract%402x.png?alt=media&#x26;token=19aa2908-d270-496e-bd3a-3e85c6c1ffef" alt=""><figcaption><p>Get the file contents of the Third Party NDA</p></figcaption></figure>

4. Now add the Tendocs Compare Documents action, and add the file contents to the action. You can prime the AI for specific scenarios by choosing a profession, in this case "Lawyer".&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2Fa5IMnzHnUNNJ8XEDf0og%2Ftendocs-compare-documents%402x.png?alt=media&#x26;token=b9767778-bf94-4a6b-94f4-5c0d7e77a2d9" alt=""><figcaption><p>Tendocs compare document action</p></figcaption></figure>

5. There are various ways to take advantage of the results of the Compare Documents action. this tutorial will use an excel based template you can download.&#x20;
6. To use the template we need to simplify the more detailed results by using a select action, configured as below to convert the results into a flat array.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FZuiDTClZOKUnivwoNKWK%2Fselect-high-level-differences%402x.png?alt=media&#x26;token=de99d31e-1ed0-4720-9e10-6670720e1e4f" alt=""><figcaption><p>Select the differences into a flat array</p></figcaption></figure>

7. Using the "Get File Contents" action, get the provided Difference Results template from a SharePoint Document Library.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2Fi3bhwWGAUbivuySXQvdm%2Fget-differences-template%402x.png?alt=media&#x26;token=4f03042e-f7bd-4a5b-9141-aaa2392d32fd" alt=""><figcaption><p>Get Differences Template</p></figcaption></figure>

8. Using the Tendocs "Create Document from Template" action, configured as follows.

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FPtcKKwpwJTuc4Kjmn8Gx%2Fget-document-from-template%402x.png?alt=media&#x26;token=96c58596-611a-45ab-b1b2-fa350ae97604" alt=""><figcaption></figcaption></figure>

9. Finally we need to save the output from the "Create Document from Template" action into a SharePoint library.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2FhtsTba1Ty4rqYsIEMmNd%2Fsave-template-contents-compare-differences%402x.png?alt=media&#x26;token=1bba22c6-1703-42f3-ac34-3ea16cbaefbb" alt=""><figcaption></figcaption></figure>

## The Final Result

The final result is an Excel file containing a summary of the differences between the documents.&#x20;

<figure><img src="https://4289764834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtKuT9a0u5GQxFZOgOhPe%2Fuploads%2F3kkRTFqvOP42ZCC41kld%2Fexcel-compare-differences-report%402x.png?alt=media&#x26;token=1bf0a353-cc8a-4979-abac-bd1ce4ca595d" alt=""><figcaption></figcaption></figure>

This is just a start, and you can add additional features to do things like:

1. Automatically send the document to the legal team where any of the differences have an importance above a certain level.&#x20;
2. It doesn't only work for legal contract, but any sort of document. So it can also help where you are working on multiple versions of a document, and simply want to know what is different between them.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.tendocs.com/how-to/compare-the-contents-of-two-documents-with-power-automate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
