# Mermaid: Turn a Purchase Approval Policy into a Flowchart with ChatGPT

> Have ChatGPT write a purchase approval flowchart in Mermaid, fix the syntax error in the Mermaid Live Editor and export SVG and PNG. Free lesson.

Source: https://learn.ynteractive.com/content/mermaid-chatgpt-purchase-approval-flowchart-tutorial · Updated 2026-11-24 · Free from Stepthrough (https://learn.ynteractive.com)

## Practice it step by step

[Start the free practice](https://learn.ynteractive.com/modules/mermaid-purchase-approval-flowchart)

You do every step yourself in a practice copy of Mermaid. It checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, about 9 minutes, and nothing touches your real accounts. [Open full screen](https://learn.ynteractive.com/modules/mermaid-purchase-approval-flowchart)

Free · Live now · [Business Automations](https://learn.ynteractive.com/content/course/business-automations) · Mermaid · ChatGPT · ~9 min · 17 steps · Beginner

Updated November 24, 2026. Built against the tool’s current screens and checked step by step. [How we check this lesson](https://learn.ynteractive.com/content/about#how-we-check)

Approval rules written as a paragraph get skimmed, so the same question keeps coming back: who signs this? A flowchart answers it at a glance, but drawing one box by box takes an hour and is painful to update. Mermaid draws the chart from a few lines of text, so [ChatGPT](https://learn.ynteractive.com/courses/chatgpt-for-everyday-work) can write it and you can change it by editing one line. In this free lesson on real Mermaid Live Editor screens, the operations director at a made-up veterinary group asks ChatGPT for the chart, checks it against the policy, fixes a real syntax error and downloads an SVG and a PNG. 17 steps, about nine minutes, no account needed.

## At a glance

| Question | Answer |
| --- | --- |
| What you build | Nobody reads the paragraph about who approves a purchase. Have ChatGPT write the process as Mermaid code, paste it into the free Mermaid Live Editor, fix the syntax error AI-written charts often hit, and download an SVG and a PNG for the handbook. |
| Tools | Mermaid |
| Time | About 9 minutes, 17 steps in 4 parts |
| Level | Beginner, no coding needed |
| Cost | Free |
| Ways to learn it | [Practice it step by step](https://learn.ynteractive.com/modules/mermaid-purchase-approval-flowchart) |

### The 4 parts, in short

1. Get a first draft from ChatGPT: Ask ChatGPT for Mermaid code, Copy ChatGPT's code.
2. Check it in the Mermaid Live Editor: Open the Mermaid Live Editor, Replace the sample with ChatGPT's code, Check the chart against the policy, Turn it sideways, and 1 more step.
3. Break it, read the error, fix it: Find the owner step, Add the amount to the label, Read the syntax error, Fix it with quotes.
4. Title it and export: Go back to the top, Add a title, Open Actions, Download the SVG, and 2 more steps.

**Start here first:** [How to Do OCR in n8n: Read Receipt Photos into Google Sheets with AI](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets) (module 1 of Business Automations)

**In the course:** Part 9 · n8n Automation Toolkit (Module 169 of the [full course](https://learn.ynteractive.com/content/course))

**Part of:** [AI for Operations Teams](https://learn.ynteractive.com/content/paths/ai-for-operations) (step 44 of 44)

**Part of:** [AI Apps Worth Knowing](https://learn.ynteractive.com/content/paths/partner-tools-ai-apps) (step 181 of 182). Next up: [PixelDojo Marketing Studio: Turn One Product into a Holiday Video Ad](https://learn.ynteractive.com/content/pixeldojo-marketing-studio-holiday-video-ad-tutorial)

## The business case: one page that answers "who signs this?"

Picture Dana, operations director at Brightwater Veterinary Group, a made-up group of four clinics. The purchase rules are a paragraph in the [staff handbook](https://learn.ynteractive.com/content/glossary#employee-handbook): the clinic manager approves under $500, Dana also approves from $500 to $5,000, and the owner signs anything over $5,000. People skim it, then email Dana, and orders for supplies and equipment wait.

A flowchart on one page fixes that. With Mermaid, the chart is text. ChatGPT writes the first draft in seconds, Dana checks it against the policy in the Mermaid Live Editor, and when a limit changes she edits one line and exports again.

## Who this is for, and what you need

Operations managers, office managers, HR and finance staff who document approvals, [onboarding](https://learn.ynteractive.com/content/glossary) steps or any other process. The practice runs in your browser with no account. To do it for real you need ChatGPT (or another [AI assistant](https://learn.ynteractive.com/content/glossary#ai-assistant)) and a browser: the Mermaid Live Editor at mermaid.live needed no account for anything in this lesson. Mermaid itself is open source.

## The prompt we sent to ChatGPT

Write a Mermaid flowchart for our purchase approval process at a group of four veterinary clinics. A staff member fills in a purchase request. Under $500, the clinic manager approves it. From $500 to $5,000, the clinic manager approves it and then the operations director (Dana) approves it. Over $5,000, the owner also has to approve it. If anyone rejects the request, the requester is told why and can revise and resubmit. Once it is approved, the office manager places the order and logs it in the purchase log. Return only the Mermaid code.

ChatGPT returned 41 lines starting with flowchart TD. In our chat it drew the chart straight away, and the menu on the chart had Show source and Copy as code. Its draft matched our policy on every path. Yours may not, so check each one.

## How to read Mermaid flowchart code

- flowchart TD draws top-down. flowchart LR draws left to right.
- A[Text] is a step in a box. D{Text?} is a decision in a diamond. A([Text]) is a rounded start or end.
- A --> B draws an arrow. A -->|Yes| B puts a label on it.
- classDef and class lines set colours for groups of boxes.
- A block of three dashes, title: and your text, then three dashes, above the first line, adds a title.

## The syntax error you are most likely to meet

We changed one label to Owner reviews request (over $5,000). The chart went pale and the editor showed Syntax error: Parse error on line 18, with a pointer under the label. Mermaid uses round brackets for node shapes, so a bare bracket inside a label breaks the chart. The fix is to put the whole label in double quotes: I["Owner reviews request (over $5,000)"]. If code pasted from an AI assistant fails to draw, find the line number in the error and quote that label first.

## What this saves you

- About an hour of dragging boxes and arrows for the first chart.
- Nearly all of the redraw time on every later change: edit one line, export again.
- The back-and-forth emails asking who approves what.
- What it does not do: it does not know your policy. Follow every path on the chart against the written rule before you publish it.

## How this lesson was built

Every practice screen is a capture of the real Mermaid Live Editor at mermaid.live, taken on 24 November 2026 in Chrome with no account. The prompt is the one we sent to ChatGPT that day in a temporary chat, and the code is what it returned, unchanged; ChatGPT's own screens are not shown. The syntax error, the fix, the title and both downloads happened as shown: the SVG was about 200 KB and the PNG was 6,673 pixels wide. The editor's AI Repair button asked for a free account, and we did not use it. Brightwater Veterinary Group and its policy are made up.

## Links

- [Mermaid Live Editor](https://mermaid.live/edit): the free editor used in this lesson. No account needed.
- [Mermaid docs: Flowcharts syntax](https://mermaid.js.org/syntax/flowchart.html): node shapes, arrows, labels, direction and classDef styling.
- [Mermaid docs: Diagram syntax and frontmatter](https://mermaid.js.org/intro/syntax-reference.html): the title block between rows of three dashes.
- [Mermaid docs: Tutorials](https://mermaid.js.org/ecosystem/tutorials.html): more tutorials, including Mermaid with OpenAI.

## Try it yourself, free

Reading the steps is a start. Doing them is how it sticks. The interactive module walks you through every click in a practice copy of Mermaid, checks each step, and never touches your real accounts.

[Start “Mermaid: Turn a Purchase Approval Policy into a Flowchart with ChatGPT”](https://learn.ynteractive.com/modules/mermaid-purchase-approval-flowchart)

## Step by step: Mermaid: Turn a Purchase Approval Policy into a Flowchart with ChatGPT

All 17 steps of the interactive module, in order. In the module you watch each one, then do it yourself in a practice copy that checks your work.

### 1. Get a first draft from ChatGPT

1. **Ask ChatGPT for Mermaid code.** You are Dana, operations director at **Brightwater Veterinary Group**, a made-up group of four clinics. The purchase rules are a paragraph in the staff handbook, so people email you to ask who signs what, and orders stall. A flowchart on one page would answer them. Describe the process to ChatGPT in plain sentences and end with **Return only the Mermaid code**. Click the message to send it.
   Your purchase rules are a paragraph nobody reads, so people keep asking who signs what. Describe the process to ChatGPT and ask for Mermaid code.
2. **Copy ChatGPT's code.** ChatGPT wrote 41 lines of Mermaid, a way to describe a diagram as text. In our chat it drew the chart straight away; the **...** menu on the chart has **Show source** and **Copy as code**. The first line, **flowchart TD**, means top-down. Square brackets are steps, curly brackets are decisions, and the text between **|** bars is the label on an arrow. Click the code to copy it.
   ChatGPT answered with Mermaid code: a diagram written as text. Square brackets are steps. Curly brackets are decisions.

### 2. Check it in the Mermaid Live Editor

3. **Open the Mermaid Live Editor.** Go to **mermaid.live**. It is free and needs no account. On our first visit a box offered a different product, Mermaid Flow. Click **Stay in mermaid.live**.
   Go to mermaid dot live. It is free and needs no account. If a box offers Mermaid Flow, click Stay in mermaid dot live.
4. **Replace the sample with ChatGPT's code.** The editor opens with a sample flowchart: code on the left under **Code**, the drawing on the right. Click in the code, select all of it, and paste the code from ChatGPT over it.
   The code is on the left and the drawing is on the right.
   ```text
   flowchart TD
       A([Start]) --> B[Staff member submits purchase request]
       B --> C[Clinic manager reviews request]
       C --> D{Clinic manager approves?}
   
       D -->|No| R[Notify requester with reason for rejection]
       D -->|Yes| E{Purchase amount?}
   
       E -->|Under $500| K[Purchase approved]
       E -->|$500 to $5,000| F[Operations director Dana reviews request]
       E -->|Over $5,000| F
   
       F --> G{Dana approves?}
       G -->|No| R
       G -->|Yes| H{Amount over $5,000?}
   
       H -->|No| K
       H -->|Yes| I[Owner reviews request]
   
       I --> J{Owner approves?}
       J -->|No| R
       J -->|Yes| K
   
       R --> S{Requester wants to revise?}
       S -->|Yes| T[Revise purchase request]
       T --> B
       S -->|No| U([Request closed])
   
       K --> L[Office manager places order]
       L --> M[Office manager records order in purchase log]
       M --> N([Purchase process complete])
   
       classDef approved fill:#dcfce7,stroke:#16a34a,color:#14532d
       classDef rejected fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
       classDef decision fill:#fef3c7,stroke:#d97706,color:#78350f
       classDef process fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
   
       class K,N approved
       class R,U rejected
       class D,E,G,H,J,S decision
       class B,C,F,I,T,L,M process
   ```
5. **Check the chart against the policy.** The chart redraws as soon as you paste. Now do the part ChatGPT cannot: follow each path against the handbook. **Under $500** goes straight to **Purchase approved**. **$500 to $5,000** and **Over $5,000** both go to Dana. Only amounts over $5,000 go on to the owner. Every **No** leads to **Notify requester**. Ours matched; yours may not. Click the chart.
   The chart draws itself. Now follow each path against your policy. Under five hundred, the manager alone. Over five thousand, the owner too. Every No goes back to the requester.
6. **Turn it sideways.** Top-down, this chart is tall and too small to read on a handbook page or a slide. The first line sets the direction. Change **flowchart TD** to **flowchart LR**, left to right.
   Top-down, the chart is too tall to read. Change the first line to flowchart L R, for left to right.
7. **Fit the chart to the screen.** The chart now runs left to right, but it is cut off at the right edge, because the preview kept its old zoom. Click **Reset view**, the first button at the top right of the preview.
   The chart is cut off, because the preview kept its old zoom.

### 3. Break it, read the error, fix it

8. **Find the owner step.** The whole chart fits. One box could be clearer: **Owner reviews request** does not say when the owner is needed. Scroll the code to line 18, **H -->|Yes| I[Owner reviews request]**. Click the code.
   The whole chart fits. One box could be clearer. Owner reviews request does not say when.
9. **Add the amount to the label.** Add the amount in brackets, the way you would in a document. Change line 18 so the label reads **Owner reviews request (over $5,000)**.
   Add the amount in brackets, the way you would in a document.
10. **Read the syntax error.** The chart went pale and a **Syntax error** box appeared: **Parse error on line 18**, with a row of dashes ending in **^** under the label. Mermaid uses round brackets for node shapes, so a bare **(** inside a label confuses it. This is the error you are most likely to meet with AI-written charts. The **AI Repair** button asks you to create an account; you do not need it. Click the error.
    The chart went pale, and a syntax error points at line eighteen. Mermaid uses round brackets for shapes, so a bracket inside a label confuses it.
11. **Fix it with quotes.** The fix: put the whole label in double quotes. Inside quotes, Mermaid treats brackets, commas and dollar signs as plain text. Change line 18 so the label is **"Owner reviews request (over $5,000)"**, inside the square brackets.
    The fix is to put the whole label in double quotes. Inside quotes, Mermaid treats brackets as plain text.

### 4. Title it and export

12. **Go back to the top.** The error is gone and the chart is back, with the amount on the owner box. If a paste from ChatGPT ever fails, look for the line number in the error and quote that label. Now give the chart a title. Scroll the code back to line 1 and click before **flowchart LR**.
    The error is gone, and the owner box shows the amount. Now give the chart a title.
13. **Add a title.** A title goes in a small block above the first line: three dashes, **title:** and your text, then three dashes. Add it above **flowchart LR**.
    A title goes in a small block above the first line, between two rows of three dashes.
14. **Open Actions.** The title **Purchase approval, Brightwater Veterinary Group** now sits above the chart. Time to get it out of the editor. Click **Actions** at the bottom left.
    The title sits above the chart. Now get it out of the editor.
15. **Download the SVG.** **Actions** has **PNG**, **SVG** and **MMD** download buttons, **Copy Image** and **Copy Markdown**. SVG stays sharp at any size, so it is the one for the handbook and for printing. Click **SVG**.
    S V G stays sharp at any size, so it is the one for the handbook and for printing.
16. **Download the PNG.** Ours saved as **mermaid-diagram-2026-11-24-100729.svg**, about 200 KB. Slides, email and chat take a picture more easily, so get the PNG too. **PNG size** is on **Auto**. Click **PNG**. The **MMD** button saves the code itself, which is what you keep for next time.
    Slides, email and chat take a picture more easily. The M M D button saves the code itself, for next time.
17. **Open the picture and check it.** This is the downloaded file, **mermaid-diagram-2026-11-24-100732.png**, opened in the browser: 6,673 pixels wide, with the title, the three amount paths and the rejection loop. Read it once more against the handbook before it goes in. When the policy changes, edit one line of the code and export again. Click the chart.
    This is the downloaded picture. Read it once more against the handbook. When the policy changes, edit one line and export again.

## Frequently asked questions

**What is Mermaid?**

Mermaid is an open-source tool that draws diagrams, such as flowcharts, from a few lines of text. You write A --> B and it draws two boxes and an arrow. Because the diagram is text, an AI assistant can write it and you can change it by editing a line.

**Can ChatGPT make a flowchart?**

Yes. Describe the process in plain sentences and ask for Mermaid code. In our test ChatGPT returned 41 lines of Mermaid and drew the chart in the chat. Paste the code into the Mermaid Live Editor to check it, change it and export it.

**Is the Mermaid Live Editor free?**

Everything in this lesson was free with no account at mermaid.live: pasting code, editing, and downloading PNG and SVG files. The AI Repair button asked us to create a free account, and we did not need it.

**Why does my Mermaid chart show a syntax error?**

The most common cause with AI-written charts is a round bracket or other symbol inside a label. Find the line number in the error message and put that label in double quotes, for example I["Owner reviews request (over $5,000)"].

**How do I export a Mermaid diagram as PNG or SVG?**

In the Mermaid Live Editor, open Actions at the bottom left and click PNG or SVG. SVG stays sharp at any size, so it suits documents and printing. PNG is easier for slides, email and chat. The MMD button saves the code itself.

**Was this lesson made in the real tool?**

Yes. Every screen is a capture of the real Mermaid Live Editor from 24 November 2026, and the code is what ChatGPT returned for the prompt shown. Buttons and labels may move as the editor changes.

[Start this module free](https://learn.ynteractive.com/modules/mermaid-purchase-approval-flowchart)

- Previous in Business Automations: [Slidev: Build a Quarterly Business Review Deck in 20 Minutes](https://learn.ynteractive.com/content/slidev-quarterly-business-review-deck-tutorial)

## More in Business Automations

- [How to Do OCR in n8n: Read Receipt Photos into Google Sheets with AI](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets): Drop a photo of a receipt into an n8n chat. An AI agent reads it, pulls out the date, vendor and amount, picks a category, and adds a row to Google Sheets.
- [n8n AI Email Responder: Draft Gmail Replies Automatically](https://learn.ynteractive.com/content/ai-email-responder-gmail-drafts-n8n): Build an n8n agent that watches your Gmail, reads each new customer email, and writes a reply as a draft in the same thread, ready for you to check and send.
- [How to Make an n8n Workflow That Emails Each Tech Their Jobs from Sheets](https://learn.ynteractive.com/content/n8n-daily-job-alerts-google-sheets-gmail): Every morning at 7, n8n reads a plumbing company's jobs sheet, skips anything not assigned yet, and emails each job to the tech it's assigned to — customer, address…
- [Gmail AI Triage: Auto-Label Every Email and Draft Replies](https://learn.ynteractive.com/content/gmail-ai-triage-labels-drafts-n8n): Build an n8n workflow that reads each new email, sorts it as a lead, a client or an invoice with a Text Classifier, adds the matching Gmail label, and drafts a reply to…
- [How to Use n8n to Build AI Agents: A Support Agent That Answers from Your Docs](https://learn.ynteractive.com/content/support-agent-answers-from-your-docs-n8n): Turn an n8n chat agent into a support agent that answers only from your policies in a Google Doc, refuses what it should, and hands off to a person by email.
- [Chatbase: Answer Customer FAQs with an AI Agent](https://learn.ynteractive.com/content/chatbase-ai-agent-answer-customer-faqs): A business case for a small firm that answers the same customer questions every week: build a Chatbase AI agent on your FAQ in the real app, make it say when it does…

[All 61 modules in Business Automations](https://learn.ynteractive.com/content/course/business-automations)

## Terms in this lesson

Plain-English definitions, each with an example from a free lesson.

[Employee handbook](https://learn.ynteractive.com/content/glossary#employee-handbook) · [Employee onboarding](https://learn.ynteractive.com/content/glossary) · [AI assistant](https://learn.ynteractive.com/content/glossary#ai-assistant) · [Approval workflow](https://learn.ynteractive.com/content/glossary#approval-workflow) · [Prompt](https://learn.ynteractive.com/content/glossary/prompt) · [Temporary Chat](https://learn.ynteractive.com/content/glossary#temporary-chat)

[The full AI glossary](https://learn.ynteractive.com/content/glossary)

## Browse related tutorials

[Business Automations (61)](https://learn.ynteractive.com/content/course/business-automations)

**Get the badge / embed this lesson**
