No items found.
February 1, 2024
read-time

Document Your Automations in Minutes Using AI

Techniques for using AI to generate documentation for your Zapier, Make, or N8N automation.

With Zapier alone having over 2.2M customers, it can be difficult to find a business that doesn’t use automation in some form or fashion.

Those automations are often built by an expert. Few folks beyond those experts truly understand how the automation works or how to debug it when it breaks. That’s where documentation comes in. A document that acts as a source of truth for what happens, what could break, and how to fix it.

But writing that documentation is a pain in the ass.

It’s usually an after-thought, and it can be so time-consuming that it’s hard to prioritize.

So why not automate it? Using ChatGPT, I found a way to automate the creation of documentation for Zapier and other automation tools.

Here’s a real example output from this process. I told it nothing about the workflow at all, just pasted the workflow’s JSON (which I’ll show you how to do).

Zapier screenshot:

ChatGPT output (I skip over some parts with [...] for brevity):

Zapier Workflow Summary

This Zapier workflow is designed to automate various tasks related to updating and sending invoices for freight, dropship, or pickup orders. The workflow is triggered by a webhook, involves several conditional paths, and integrates with Webhooks by Zapier, Salesforce, Google Sheets, Formatter by Zapier, QuickBooks, and Google Mail. It handles data transformation, delay actions, email notifications, and updates in Salesforce and QuickBooks based on specific conditions.

Workflow Steps Breakdown

Catch Hook in Webhooks by Zapier:
This step starts the workflow by catching a webhook. It waits for a payload from an external source.

Delay (31 minutes):
Delays the workflow for 31 minutes after receiving the webhook data.

Find Record in Salesforce (Invoice Search):
Searches for a specific invoice record in Salesforce. It uses a custom field value from the webhook data to perform the search.

[...]

Determine Invoice/Billing Email:
Runs custom JavaScript code to decide whether to use the order email from the webhook data or the invoice recipient name from Salesforce for billing.

Parallel Paths (Branching Logic):
The workflow diverges into multiple paths based on order type and other criteria.

Path A (Freight Orders):
Filters orders to continue only if they match the freight order type.
Includes a delay action and searches for a specific email message in Google Mail.
Diverges into two further paths:

Path C:
If no relevant email is found, it generates a URL using custom JavaScript and sends an email with an invoice form link.

Path D: If an email with attachments is found, it saves the attachments to Google Drive and labels the email in Google Mail.

Path B (Other Orders):

Filters orders based on specific criteria in the customer memo and invoice ID.
Delays until a specific time based on the output from a previous step.
Sends the invoice using QuickBooks.
Includes a filter to stop if no invoice recipient name is found and notifies the account manager via email if the invoice email account is empty.

[...]

Impressed? I was too. Here's how to do it.

Extracting Raw Workflow Data from Zapier

The key to auto-generating documentation is extracting the raw workflow data in JSON format so your AI tool of choice can understand it.

While Zapier has an export function available for team accounts, it’s cumbersome to use and not available for everyone.

Fortunately, there’s a workaround that blew my mind when I discovered it.  

Zapier is built with Next JS, which always publishes a list of variables that the application needs to render the page to a JSON script with the id “__NEXT_DATA__”. It looks something like this:

<script id="__NEXT_DATA__" type="application/json">

In the case of Zapier, every single step in the workflow, along with all the details about them, are listed in this data. The JSON includes details like what tool the step uses, what action it takes, and what fields are used.

Difficult to parse for us simple humans, ChatGPT, Claude, and other AI chatbots are extremely good at reading, understanding, and summarizing JSON.

To access the workflow’s JSON data:

  1. Open the Zapier workflow, right-click anywhere on the page, and click Inspect Element to open the browser’s dev tools.
  2. In the code section, hit CTRL + F or CMD + F and search for next_data to find the JSON script tag.
  3. Copy the JSON data inside (the easiest way to do this is to right-click the script tag and go to Copy > Copy Outer HTML).

Note: While this data can contain sensitive information, it will not contain any credentials. However, it does contain a couple of details including your Zapier email account and your name. You can remove that before pasting if you’d like.

Note for those using Make or n8n

In Make, you can hold shift, click and drag your mouse to select your workflow, then hit CTRL/CMD + C to copy the JSON.

In n8n, you can do the same thing, but you don’t have to hold shift.

Generating Documentation with AI

Armed with the raw JSON data, we can leverage AI tools like ChatGPT and Claude to analyze it and generate documentation.

ChatGPT (especially with GPT4) is great at parsing this JSON and spitting out usable documentation. With recent updates, it can accept over 100,000 tokens which means it can process quite a bit of text without throwing an error. For reference, the workflow I took a screenshot of came in at only ~13,000 tokens.

You can also try uploading the json as a file if it protests. It’s often capable of reading and understanding files that are longer than the longest possible prompt. In my experience, a .txt file worked and a .json file failed, although reading documents in general fails randomly even under the same conditions so it’s worth trying again.

I’ve personally used GPT4 almost exclusively, but I will shout-out Claude for conveniently making the .json into a .txt file attachment when you paste long strings of text so it doesn’t blow up your text box.

To generate documentation:

  1. Paste the JSON
  2. Prompt the AI to document the workflow step-by-step.
  3. Request markdown formatting for easier reading.
  4. Ask follow-up questions or provide information to fill out the details if needed.
  5. Copy the generated text

Sample prompt:

You are an automation expert who uses Zapier every day. Your job is to write high-quality documentation for people who will be using this automation and maintaining it.

This JSON represents an automation in Zapier. Please provide a paragraph summary of what it does, then a step-by-step breakdown of each step in the workflow and what they do. Use markdown to format your response. For each step, provide the name of the step in bold, then additional information about what it does including variables it references or conditions it checks.

If there are any paths or filters which change the flow of the automation, describe the different possible paths the automation could take rather than a linear format. Also describe the steps that those paths take (don't summarize).

Don't summarize. Don’t skip any steps. I want a lengthy, detailed output for each step.

JSON Workflow:

[Paste JSON]

The prompt matters. I played around with a few versions, removing individual paragraphs and phrases to see how the output differed. Telling it what NOT to do was actually very helpful—it tended to over-summarize important details. This prompt created an output nearly double the length (and usefulness) of some of my early attempts at the prompt.

How do you know your prompt can be better? If you ask follow-up questions about the data, you will quickly realize just how good AI is at figuring out what a workflow does by reading JSON. It will often readily provide more detail about each step if prompted.  

One caveat: if your workflow is only a few steps long, this prompt may result in more detail than you want about each step. I suggest a simplified prompt for smaller workflows that encourages brevity.

Following up is simple–you can say things like:

  • Step #2 is wrong, it actually does xyz.
  • What are potential ways that this automation can fail?
  • The webhook is triggered by Salesforce. Try again and add that detail.
  • Do it again for this workflow: [paste JSON]
  • You’re summarizing too many important details. For example, on step 2 you don’t mention what the variable is used for. Try again please.

The finishing touches

For some workflows, you may want to expand on the information provided by AI to make the documentation complete. One great way to do this is to record a video with you talking through the automation’s key details.

It usually takes just a few minutes, and you can provide this as part of the documentation.

In tools like Loom, you can also copy the transcript and paste it into an AI chatbot to help it understand the workflow. You can even send both the transcript and the JSON to the chatbot and ask it to fill in more details based on what you said.

Documentation is often skipped because it’s slow and tedious, but given how easy it is to outsourcing this work to chatbots there’s really no reason to skip documentation any more. Combine this with a simple system for storing and updating documentation, and you’ll be ahead of most people!

Want to improve your workflows?
Join 2,000+ others who get the 10% better newsletter in their inbox every two weeks
One more step: check your inbox to verify your email!
Oops! Something went wrong while submitting the form.
Written by
Giovanni Segar
Share article
Written by
Aron Korenblit
Share article
Related posts
February 29, 2024
How to find and use hidden APIs to automate processes
10% better
February 15, 2024
Airtable vs Asana for project management: a guide for nerds
10% better
Airtable
January 31, 2024
Document Your Automations in Minutes Using AI
10% better

Automate all the things

A weekly no-code automation delivered to your inbox (with thoughts on no-code every now and then)
Subscribe
Feb 01, 2024 by Giovanni Segar

Document Your Automations in Minutes Using AI

With Zapier alone having over 2.2M customers, it can be difficult to find a business that doesn’t use automation in some form or fashion.

Those automations are often built by an expert. Few folks beyond those experts truly understand how the automation works or how to debug it when it breaks. That’s where documentation comes in. A document that acts as a source of truth for what happens, what could break, and how to fix it.

But writing that documentation is a pain in the ass.

It’s usually an after-thought, and it can be so time-consuming that it’s hard to prioritize.

So why not automate it? Using ChatGPT, I found a way to automate the creation of documentation for Zapier and other automation tools.

Here’s a real example output from this process. I told it nothing about the workflow at all, just pasted the workflow’s JSON (which I’ll show you how to do).

Zapier screenshot:

ChatGPT output (I skip over some parts with [...] for brevity):

Zapier Workflow Summary

This Zapier workflow is designed to automate various tasks related to updating and sending invoices for freight, dropship, or pickup orders. The workflow is triggered by a webhook, involves several conditional paths, and integrates with Webhooks by Zapier, Salesforce, Google Sheets, Formatter by Zapier, QuickBooks, and Google Mail. It handles data transformation, delay actions, email notifications, and updates in Salesforce and QuickBooks based on specific conditions.

Workflow Steps Breakdown

Catch Hook in Webhooks by Zapier:
This step starts the workflow by catching a webhook. It waits for a payload from an external source.

Delay (31 minutes):
Delays the workflow for 31 minutes after receiving the webhook data.

Find Record in Salesforce (Invoice Search):
Searches for a specific invoice record in Salesforce. It uses a custom field value from the webhook data to perform the search.

[...]

Determine Invoice/Billing Email:
Runs custom JavaScript code to decide whether to use the order email from the webhook data or the invoice recipient name from Salesforce for billing.

Parallel Paths (Branching Logic):
The workflow diverges into multiple paths based on order type and other criteria.

Path A (Freight Orders):
Filters orders to continue only if they match the freight order type.
Includes a delay action and searches for a specific email message in Google Mail.
Diverges into two further paths:

Path C:
If no relevant email is found, it generates a URL using custom JavaScript and sends an email with an invoice form link.

Path D: If an email with attachments is found, it saves the attachments to Google Drive and labels the email in Google Mail.

Path B (Other Orders):

Filters orders based on specific criteria in the customer memo and invoice ID.
Delays until a specific time based on the output from a previous step.
Sends the invoice using QuickBooks.
Includes a filter to stop if no invoice recipient name is found and notifies the account manager via email if the invoice email account is empty.

[...]

Impressed? I was too. Here's how to do it.

Extracting Raw Workflow Data from Zapier

The key to auto-generating documentation is extracting the raw workflow data in JSON format so your AI tool of choice can understand it.

While Zapier has an export function available for team accounts, it’s cumbersome to use and not available for everyone.

Fortunately, there’s a workaround that blew my mind when I discovered it.  

Zapier is built with Next JS, which always publishes a list of variables that the application needs to render the page to a JSON script with the id “__NEXT_DATA__”. It looks something like this:

<script id="__NEXT_DATA__" type="application/json">

In the case of Zapier, every single step in the workflow, along with all the details about them, are listed in this data. The JSON includes details like what tool the step uses, what action it takes, and what fields are used.

Difficult to parse for us simple humans, ChatGPT, Claude, and other AI chatbots are extremely good at reading, understanding, and summarizing JSON.

To access the workflow’s JSON data:

  1. Open the Zapier workflow, right-click anywhere on the page, and click Inspect Element to open the browser’s dev tools.
  2. In the code section, hit CTRL + F or CMD + F and search for next_data to find the JSON script tag.
  3. Copy the JSON data inside (the easiest way to do this is to right-click the script tag and go to Copy > Copy Outer HTML).

Note: While this data can contain sensitive information, it will not contain any credentials. However, it does contain a couple of details including your Zapier email account and your name. You can remove that before pasting if you’d like.

Note for those using Make or n8n

In Make, you can hold shift, click and drag your mouse to select your workflow, then hit CTRL/CMD + C to copy the JSON.

In n8n, you can do the same thing, but you don’t have to hold shift.

Generating Documentation with AI

Armed with the raw JSON data, we can leverage AI tools like ChatGPT and Claude to analyze it and generate documentation.

ChatGPT (especially with GPT4) is great at parsing this JSON and spitting out usable documentation. With recent updates, it can accept over 100,000 tokens which means it can process quite a bit of text without throwing an error. For reference, the workflow I took a screenshot of came in at only ~13,000 tokens.

You can also try uploading the json as a file if it protests. It’s often capable of reading and understanding files that are longer than the longest possible prompt. In my experience, a .txt file worked and a .json file failed, although reading documents in general fails randomly even under the same conditions so it’s worth trying again.

I’ve personally used GPT4 almost exclusively, but I will shout-out Claude for conveniently making the .json into a .txt file attachment when you paste long strings of text so it doesn’t blow up your text box.

To generate documentation:

  1. Paste the JSON
  2. Prompt the AI to document the workflow step-by-step.
  3. Request markdown formatting for easier reading.
  4. Ask follow-up questions or provide information to fill out the details if needed.
  5. Copy the generated text

Sample prompt:

You are an automation expert who uses Zapier every day. Your job is to write high-quality documentation for people who will be using this automation and maintaining it.

This JSON represents an automation in Zapier. Please provide a paragraph summary of what it does, then a step-by-step breakdown of each step in the workflow and what they do. Use markdown to format your response. For each step, provide the name of the step in bold, then additional information about what it does including variables it references or conditions it checks.

If there are any paths or filters which change the flow of the automation, describe the different possible paths the automation could take rather than a linear format. Also describe the steps that those paths take (don't summarize).

Don't summarize. Don’t skip any steps. I want a lengthy, detailed output for each step.

JSON Workflow:

[Paste JSON]

The prompt matters. I played around with a few versions, removing individual paragraphs and phrases to see how the output differed. Telling it what NOT to do was actually very helpful—it tended to over-summarize important details. This prompt created an output nearly double the length (and usefulness) of some of my early attempts at the prompt.

How do you know your prompt can be better? If you ask follow-up questions about the data, you will quickly realize just how good AI is at figuring out what a workflow does by reading JSON. It will often readily provide more detail about each step if prompted.  

One caveat: if your workflow is only a few steps long, this prompt may result in more detail than you want about each step. I suggest a simplified prompt for smaller workflows that encourages brevity.

Following up is simple–you can say things like:

  • Step #2 is wrong, it actually does xyz.
  • What are potential ways that this automation can fail?
  • The webhook is triggered by Salesforce. Try again and add that detail.
  • Do it again for this workflow: [paste JSON]
  • You’re summarizing too many important details. For example, on step 2 you don’t mention what the variable is used for. Try again please.

The finishing touches

For some workflows, you may want to expand on the information provided by AI to make the documentation complete. One great way to do this is to record a video with you talking through the automation’s key details.

It usually takes just a few minutes, and you can provide this as part of the documentation.

In tools like Loom, you can also copy the transcript and paste it into an AI chatbot to help it understand the workflow. You can even send both the transcript and the JSON to the chatbot and ask it to fill in more details based on what you said.

Documentation is often skipped because it’s slow and tedious, but given how easy it is to outsourcing this work to chatbots there’s really no reason to skip documentation any more. Combine this with a simple system for storing and updating documentation, and you’ll be ahead of most people!

Automate All the Things
3K+
Subscribers
88
Issues
Enjoying the post? Get it in your inbox every Thursday
Last step: confirm your email!
Oops! Something went wrong while submitting the form.

Related streams

See all streams
No items found.