Skip to main content
Version: v1.6.37-dev1 🚧

Tutorial 10: Visualize your agent’s actions with Mermaid charts

Overview

This tutorial shows how to quickly visualize your agent's actions in Enterprise h2oGPTe by turning a chat session into a Mermaid flowchart. This method helps both technical and non-technical users understand agent behavior, identify unexpected choices, and share results effectively.

After completing this tutorial, you'll be able to generate visual flowcharts like this one that shows an agent's decision-making process:

Mermaid Diagram

This flowchart shows the agent's workflow, decision points, and actions, making it easy to understand what happened during the interaction.

Objective

  • Quickly understand and explain what your agent did, without reading raw JSON or code.
  • Useful for demos, customer support, and troubleshooting when agents behave unexpectedly.
  • Helps non-technical users and stakeholders visualize agent decisions and flows.

Prerequisites

Step 1: Create a chat with an agent

  1. In the Enterprise h2oGPTe navigation menu, click Chats.
  2. Navigate to + New chat and start a chat with the Agent enabled.
  3. Enter your question in the Ask anything box.
  4. Click Submit. This will start a new chat session with the agent.

Start a new chat

Step 2: Ask follow-up questions

  1. With agents still enabled, ask a follow-up question in the same chat session.
  2. You can ask your agent anything, the key is to keep agents active so their actions are recorded.

Follow-up question

Step 3: Download the chat_conversation JSON file

  1. To begin, click on the LLM Prompt icon.

LLM Prompt button

  1. In the dialog that appears, click on the icon to copy the chat_conversation JSON. Chat conversation JSON

Step 4: Create a flowcharting prompt template

  1. In the Enterprise h2oGPTe navigation menu, click Prompts to manage Prompt Templates.
  2. Click + New prompt template to create a new template with a system prompt for generating a Mermaid chart flowchart. See Create a prompt template for details.
  3. In the Template name box, enter a name for the prompt template.
  4. Paste the following system prompt into the System prompt input box:
🛠️ SYSTEM PROMPT: Mermaid Diagram Generator from Agent Chat History

You are an expert Mermaid Diagram code generator for visualizing agentic interactions. The user will paste a back-and-forth conversation between two agents — a Thinking AI Agent and a Code Executor AI Agent — in JSON-like format under a <conversation> tag.

Your job is to output a Mermaid Diagram flowchart, with the following constraints and instructions:



✅ Mermaid Diagram Rules:
1. Do not use quotation marks (") in node labels.
2. Do not use parentheses (( or )) in node labels.
3. Use <br /> for line breaks inside nodes.
4. Start each node label with an appropriate emoji to convey meaning visually.
5. Use appropriate node styles based on context:

```mermaid
classDef error fill:#ffe6e6,stroke:#ff4d4d,stroke-width:2px,color:#990000
classDef success fill:#e6ffe6,stroke:#00cc66,stroke-width:2px,color:#006600
classDef action fill:#f0f8ff,stroke:#3399ff,stroke-width:2px
classDef decision fill:#fff9e6,stroke:#ffcc66,stroke-width:2px
```



🧠 Your Objective:

Generate Mermaid flowchart code that explains:
• What steps were taken by the agents
• What tools or APIs were used
• What decisions or branches were encountered
• What errors occurred and how they were handled
• What the final outcome was

This diagram should be friendly to **business users** — avoid code-y words and highlight the meaning or goal of each step with emojis and plain language.



✨ Output Format:

```mermaid
flowchart TD
%% Your flowchart nodes and arrows here
%% Include styling at the end

classDef error fill:#ffe6e6,stroke:#ff4d4d,stroke-width:2px,color:#990000
classDef success fill:#e6ffe6,stroke:#00cc66,stroke-width:2px,color:#006600
classDef action fill:#f0f8ff,stroke:#3399ff,stroke-width:2px
classDef decision fill:#fff9e6,stroke:#ffcc66,stroke-width:2px
```

**You must end your response with ONLY the Mermaid code (no explanation, no markdown formatting).**



📥 Input Format Example:
```xml
[
[
"User question...",
"Thinking Agent proposes code..."
],
[
"Execution Agent runs code, gets error",
"Thinking Agent tries alternative approach"
]
]
```
  1. You can adjust the settings as needed, but we recommend keeping the system prompt as shown above for this tutorial.
  2. Click + Create to create the prompt template.

Create prompt template

Step 5: Use the flowchart prompt template

  1. In the Enterprise h2oGPTe navigation menu, click Collections.
  2. Click + New collection. See Create a Collection for details on creating a collection.
  3. Click + Start your first Chat. Start new chat
  4. In the Ask anything box, paste the chat_conversation JSON you copied in Step 3.
  5. Click the Settings icon in the upper-right corner to customize the chat.
  6. In the Prompt template to use tab, select the flowchart prompt template you created in Step 4 from the dropdown menu. Select prompt template
  7. Click Submit. This will submit the JSON to the agent using the selected prompt template.

Step 6: Render and view your Mermaid chart

To render the Mermaid chart, you can use one of the following methods:

  1. Ask the agent to render the Mermaid diagram directly in the chat.
  2. The success rate of this method may vary depending on the agent and prompt.

Mermaid Diagram

tips
  • If the Mermaid output is inaccurate or incomplete, try refining the prompt template or re-running the process.
  • For complex or custom agents, results may vary. Manual review is recommended.
  • If a prompt consistently produces accurate diagrams, consider sharing it with your team.

Feedback