# Generate AI-powered contracts with OpenAI and Gmail: n8n workflow

> Started by another system calling it, and works across Gmail and Google Sheets. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/generate-ai-powered-contracts-with-openai-and-gmail (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Documents and files](https://millionrounds.com/workflows?category=Documents+and+files#library)

# Generate AI-powered contracts with OpenAI and Gmail

Started by another system calling it, and works across Gmail and Google Sheets. It hands the judgement calls to OpenAI. 26 steps, 3 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgenerate-ai-powered-contracts-with-openai-and-gmail)

**26 steps** Large: read it before trusting it with anything live

**3** Branches: places the flow splits

**1** Loop or waits

**2** Services it connects to

## The flow

Starts it 2 Model 2 Logic 16 Service 6

The steps in the order they run, from what starts it.

- 1 **Contract Request Webhook** Webhook *Starts it*
- 2 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 3 **Validate Contract Request** If *Logic*
- 4 **AI Contract Advisor** Agent *Model*
- 5 **Prepare Contract Data** Set *Logic*
- 6 **Invalid Request Response** Set *Logic*
- 7 **Parse AI Contract Response** Code *Logic*
- 8 **Route by Contract Type** Switch *Logic*
- 9 **Respond to Webhook** Respond To Webhook *Starts it*
- 10 **Convert Markdown to HTML** Markdown *Logic*
- 11 **NDA Template Base** Set *Logic*
- 12 **Service Agreement Base** Set *Logic*
- 13 **Employment Contract Base** Set *Logic*
- 14 **Generic Contract Base** Set *Logic*
- 15 **Prepare Signature Request** Code *Logic*
- 16 **Merge Template Data** Merge *Logic*
- 17 **Send to E-Signature Service** Http Request *Service*
- 18 **Send Signing Request Email** Gmail *Service*
- 19 **Wait for Signature Webhook** Wait *Logic*
- 20 **Process Signature Result** Code *Logic*
- 21 **Check Signature Status** If *Logic*
- 22 **Log Completed Contract** Google Sheets *Service*
- 23 **Log Expired or Pending** Google Sheets *Service*
- 24 **Send Completion Email** Gmail *Service*
- 25 **Send Reminder or Expiry Email** Gmail *Service*
- 26 **Merge Final Results** Merge *Logic*

## How it's built

- **Starts on:** Another system calling it
- **Steps:** 26, with 3 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Google Sheets
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Gmail and Google Sheets accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 26 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 26 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgenerate-ai-powered-contracts-with-openai-and-gmail)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)

## Workflows like it

Also documents and files, with the same services where possible, closest in size first.

- [**Archive HR and legal documents with UploadToURL** 26 steps · Airtable, Gmail](https://millionrounds.com/workflow/archive-hr-and-legal-documents-with-uploadtourl)
- [**Extract text from Google Drive files to Google Sheets** 25 steps · Google Docs, Google Drive](https://millionrounds.com/workflow/extract-text-from-google-drive-files-to-google-sheets)
- [**Translate documents to multiple languages with Google Drive** 27 steps · Gmail, Google Drive](https://millionrounds.com/workflow/translate-documents-to-multiple-languages-with-google-drive)
- [**Automate document ingestion & RAG system with Google Drive** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/automate-document-ingestion-and-rag-system-with-google-drive)
- [**Find weak local Google Business profiles with Bright Data** 24 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/find-weak-local-google-business-profiles-with-bright-data)
- [**Generate business requirement documents with Google Workspace** 28 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/generate-business-requirement-documents-with-google-workspac)
