---
title: 用 AI Agent 幫客戶寫 Power Automate Flow, 從 80 個 Action 到 17 個
description: 用 AI Agent + MCP 開發 Power Automate flow 的實戰經驗。Dictionary lookup pattern 取代 Switch, 80 個 action 變 17 個。Agent 自己跑完 deploy-test-debug loop, 不用開 Power Automate designer。
image: https://learn.flowstudio.app/hubfs/blog-featured-images/cover-dictionary-pattern.png
---

[Skip to content](https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw#main-content)

[![Flow Studio](https://learn.flowstudio.app/hs-fs/hubfs/flow-studio-transparency.png?width=90&height=90&name=flow-studio-transparency.png)](https://flowstudio.app)

- [FlowStudio App](https://learn.flowstudio.app/)
  
  Show submenu for FlowStudio App 
  
    - [Getting Started](https://learn.flowstudio.app/getting-started)
    - [Full Text Search](https://learn.flowstudio.app/full-text-search)
    - [Flow Diagram](https://learn.flowstudio.app/flow-diagram)
    - [Clipboard & Library](https://learn.flowstudio.app/clipboard)
    - [Restore a Flow](https://learn.flowstudio.app/restore-power-automate)
    - [Migrate and Deploy](https://learn.flowstudio.app/migrate-flows)
    - [Bulk Export Flows](https://learn.flowstudio.app/bulk-export-flows)
    - [More Info for IT](https://learn.flowstudio.app/more-info-for-it)
- [MCP](https://learn.flowstudio.app/mcp-getting-started)
  
  Show submenu for MCP 
  
    - [Getting Started](https://learn.flowstudio.app/mcp-getting-started)
    - [Which Agent to Use](https://learn.flowstudio.app/mcp-which-agent-power-automate)
    - [Connect Without Admin Consent](https://learn.flowstudio.app/mcp-browser-key)
    - [Build Flows with AI](https://learn.flowstudio.app/build-power-automate-flows-with-ai-agents)
    - [Vibe Code Flows](https://learn.flowstudio.app/vibe-code-power-automate)
    - [Power Automate in VS Code](https://learn.flowstudio.app/power-automate-ide)
    - [Debug Flows](https://learn.flowstudio.app/mcp-debug)
    - [MCP Tools Reference](https://learn.flowstudio.app/mcp-tools)
    - [Copilot Agent Skills](https://learn.flowstudio.app/mcp-copilot-skills)
    - [Compare with Microsoft MCP](https://learn.flowstudio.app/compare/flowstudio-mcp-vs-microsoft-power-automate-mcp)
    - [Pricing & Plans](https://learn.flowstudio.app/mcp-pricing)
    - [Manage Tenant Plan](https://learn.flowstudio.app/mcp-tenant-plan-admin)
- [FlowStudio AI](https://learn.flowstudio.app/flowstudio-ai)
- [Teams](https://learn.flowstudio.app/flowstudio-for-teams)
  
  Show submenu for Teams 
  
    - [Manage Workspace](https://learn.flowstudio.app/teams-workspace)
    - [Adding Permissions](https://learn.flowstudio.app/teams-add-permission)
    - [Flow Monitoring](https://learn.flowstudio.app/teams-monitoring)
    - [Flow Report](https://learn.flowstudio.app/teams-report)
- [Blog](https://learn.flowstudio.app/blog)
- [FAQ](https://learn.flowstudio.app/faq)
- [Personal Data](https://learn.flowstudio.app/personal-data)

Open main navigation

Close main navigation

- [FlowStudio App](https://learn.flowstudio.app/)
  
  Show submenu for FlowStudio App 
  
    - [Getting Started](https://learn.flowstudio.app/getting-started)
    - [Full Text Search](https://learn.flowstudio.app/full-text-search)
    - [Flow Diagram](https://learn.flowstudio.app/flow-diagram)
    - [Clipboard & Library](https://learn.flowstudio.app/clipboard)
    - [Restore a Flow](https://learn.flowstudio.app/restore-power-automate)
    - [Migrate and Deploy](https://learn.flowstudio.app/migrate-flows)
    - [Bulk Export Flows](https://learn.flowstudio.app/bulk-export-flows)
    - [More Info for IT](https://learn.flowstudio.app/more-info-for-it)
- [MCP](https://learn.flowstudio.app/mcp-getting-started)
  
  Show submenu for MCP 
  
    - [Getting Started](https://learn.flowstudio.app/mcp-getting-started)
    - [Which Agent to Use](https://learn.flowstudio.app/mcp-which-agent-power-automate)
    - [Connect Without Admin Consent](https://learn.flowstudio.app/mcp-browser-key)
    - [Build Flows with AI](https://learn.flowstudio.app/build-power-automate-flows-with-ai-agents)
    - [Vibe Code Flows](https://learn.flowstudio.app/vibe-code-power-automate)
    - [Power Automate in VS Code](https://learn.flowstudio.app/power-automate-ide)
    - [Debug Flows](https://learn.flowstudio.app/mcp-debug)
    - [MCP Tools Reference](https://learn.flowstudio.app/mcp-tools)
    - [Copilot Agent Skills](https://learn.flowstudio.app/mcp-copilot-skills)
    - [Compare with Microsoft MCP](https://learn.flowstudio.app/compare/flowstudio-mcp-vs-microsoft-power-automate-mcp)
    - [Pricing & Plans](https://learn.flowstudio.app/mcp-pricing)
    - [Manage Tenant Plan](https://learn.flowstudio.app/mcp-tenant-plan-admin)
- [FlowStudio AI](https://learn.flowstudio.app/flowstudio-ai)
- [Teams](https://learn.flowstudio.app/flowstudio-for-teams)
  
  Show submenu for Teams 
  
    - [Manage Workspace](https://learn.flowstudio.app/teams-workspace)
    - [Adding Permissions](https://learn.flowstudio.app/teams-add-permission)
    - [Flow Monitoring](https://learn.flowstudio.app/teams-monitoring)
    - [Flow Report](https://learn.flowstudio.app/teams-report)
- [Blog](https://learn.flowstudio.app/blog)
- [FAQ](https://learn.flowstudio.app/faq)
- [Personal Data](https://learn.flowstudio.app/personal-data)

 Contact Us

 Mar 16, 2026, 11:49:19 PM

# 用 AI Agent 幫客戶寫 Power Automate Flow, 從 80 個 Action 到 17 個

![Picture of Catherine Han](https://learn.flowstudio.app/hs-fs/hubfs/catherine-circle.jpg?width=50&name=catherine-circle.jpg) [Catherine Han](https://learn.flowstudio.app/zh-hant/blog/author/catherine-han)

Share: [facebook-f icon](http://www.facebook.com/share.php?u=https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw) [linkedin-in icon](http://www.linkedin.com/shareArticle?mini=true&url=https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw) [Twitter icon](https://twitter.com/intent/tweet?url=https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw) [pinterest-p icon](http://pinterest.com/pin/create/link/?url=https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw) [envelope icon](mailto:?body=https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw)

分享這兩天用 AI Agent + MCP 幫客戶開發 Power Automate 的經驗。

## 客戶需求

客戶要做一個文件處理的自動化 - 有人上傳 Word 報告到 SharePoint list，Power Automate 自動把它轉 PDF、存到對應的 document library、發 Teams message、寄 email。不同的文件類型要存到不同的地方、發到不同的 channel。

客戶本來有一套在用的，3 種文件類型，用 Switch 分流。我要幫他們做一個新的給另一個團隊用，這次有 6 種文件類型。

我就想，要不要直接叫 AI agent 幫我做。

## 讓 Agent 讀現有的 Flow

我用的是 Claude（在 VS Code 裡面跑），透過 [**FlowStudio MCP**](https://mcp.flowstudio.app?utm_source=hubspot&utm_medium=content&utm_campaign=blog-dictionary-pattern-zh) 連到客戶的 Power Automate 環境。MCP 讓 agent 可以直接讀 flow definition、deploy 修改、trigger 測試、看 run history, 不用開 Power Automate designer。

第一步是讓 agent 讀現有的 flow：

```
agent → list_live_flows → 找到現有的 flow
agent → get_live_flow → 讀完整的 flow definition
```

Agent 看完之後馬上理解整個結構：trigger 是 SharePoint list item created，Apply to Each 跑 attachments，裡面兩個 Switch block 分文件類型, 一個處理 PDF 轉檔跟存檔，一個處理 Teams message 跟 email。

## 第一版：直接照抄

Agent 直接照抄邏輯，把 3 種改成 6 種 => 6 個 case 的 Switch，每個 case 裡面一整組重複的 action。deploy 上去，80 幾個 action。

其實也不是不行，畢竟舊的那一套也是我做的，結構一樣。只是改 bug 的時候在 Switch 裡面改有點麻煩, 6 種文件類型就要改 6 次，很容易漏。

**舊版 Switch 長這樣：  
![Screenshot 2026-03-16 215712](https://learn.flowstudio.app/hs-fs/hubfs/blog-screenshots/dictionary-pattern/Screenshot%202026-03-16%20215712.png?width=1742&height=860&name=Screenshot%202026-03-16%20215712.png)**

*3 個 case 展開，每個 case 裡面一整組重複的 action, Compose、HTTP Graph、Send email、Post Teams message。新版要 6 個 case，改一個 bug 要改 6 次。*

## 第二版：Dictionary Lookup

然後我丟了我老公 John Liu 的一篇 blog 給 agent 看, [**split twice pattern**](https://johnliu.net/blog/2026/2/flow-lightweight-fast-template-engine-using-split-twice)，用 config 取代 Switch 的寫法。

Agent 看完之後建議用 dictionary lookup。做法是：

1. 一個 **Compose** action 放 JSON config，6 種文件類型當 key，value 放 library ID、Teams channel ID、mailing list 欄位名稱
2. 後面所有 action 都用 `outputs('Compose_Config')?[triggerBody()?['Type/Value']]` 去查表
3. 兩個 Switch 砍掉

**80 幾個 action 變 17 個。**

![Power Automate flow with dictionary config lookup pattern - clean single set of actions](https://learn.flowstudio.app/hubfs/blog-screenshots/dictionary-pattern/new-dictionary-flow.png)

*左邊是 Compose Config 的 JSON, 6 種文件類型當 key，每個 key 放對應的 library ID、channel ID、mailing list 欄位。右邊是乾淨的 Apply to Each，一組共用的 action 處理所有文件類型。加新的類型只要在 config 加一筆。*

## Deploy 之後才是真正踩坑的開始

新版 deploy 上去之後跑了第一次, 壞了。

SharePoint connector 有些限制是文件上寫不清楚的、path 格式跟你想的不一樣、JSON 字串組出來多了一個 single quote 就壞掉、欄位更新邏輯沒寫好會互相蓋掉。

每次都是這個 loop：

```
agent → update_live_flow（deploy 修改）
agent → trigger_live_flow（跑一次）
agent → get_live_flow_runs（看 run history）
agent → get_live_flow_run_error（找到哪個 action 壞掉）
agent → get_live_flow_run_action_outputs（看 input/output 確認問題）
→ 改 code → 再 deploy
```

來回了大概 7 次。中間還 cancel 了 11 個壞掉的 run。

**重點是這 7 次我都沒有打開 Power Automate designer。**

全部都是 agent 自己 deploy、自己跑、自己看錯在哪裡、自己改。我只是在旁邊看它跑，偶爾提示一下方向（像是丟 John 的 blog 給它看）。

## 為什麼 MCP 是關鍵

如果 agent 沒有 MCP，它還是可以 deploy flow。但 flow 壞掉的時候，它看不到 run history 裡面的 error detail 跟 action input/output。你就要自己去 Power Automate designer 看錯在哪，然後把 error message 跟 input/output 貼回去給 agent。

有了 MCP，agent 可以直接：

- 讀現有的 flow（`get_live_flow`）
- Deploy 修改（`update_live_flow`）
- Trigger 測試（`trigger_live_flow`）
- 看 run history 跟 action-level 的 error（`get_live_flow_runs`、`get_live_flow_run_error`）
- 看每個 action 的 input/output（`get_live_flow_run_action_outputs`）

差別就是 agent 能不能自己跑完 deploy → test → debug 的 loop。能跑的話，一個下午搞定。不能的話，你就是那個 loop 裡面的人肉 middleware。

---

想試試看的話：[**FlowStudio MCP**](https://mcp.flowstudio.app?utm_source=hubspot&utm_medium=content&utm_campaign=blog-dictionary-pattern-zh) 免費方案有 100 次 API call，不綁信用卡。

可用 VS Copilot, Claude 跟各種 MCP-compatible agent.

John 的 split twice pattern 原文：[johnliu.net](https://johnliu.net/blog/2026/2/flow-lightweight-fast-template-engine-using-split-twice)

---

*Catherine Han, [FlowStudio](https://flowstudio.app?utm_source=hubspot&utm_medium=content&utm_campaign=blog-dictionary-pattern-zh)*

[Insights & Tips](https://learn.flowstudio.app/zh-hant/blog/tag/insights-tips), [Debugging](https://learn.flowstudio.app/zh-hant/blog/tag/debugging), [MCP](https://learn.flowstudio.app/zh-hant/blog/tag/mcp), [Power Automate](https://learn.flowstudio.app/zh-hant/blog/tag/power-automate), [AI Agents](https://learn.flowstudio.app/zh-hant/blog/tag/ai-agents), [Vibe Coding](https://learn.flowstudio.app/zh-hant/blog/tag/vibe-coding)

## Related posts

[![FlowStudio MCP：AI Agent 存取 Power Automate](https://learn.flowstudio.app/hs-fs/hubfs/blog-featured-images/flow-studio-mcp-feature.png?height=200&name=flow-studio-mcp-feature.png)](https://learn.flowstudio.app/zh-hant/blog/stop-learning-power-automate-ai-agent-mcp-zh-tw?hsLang=zh-hant)

[Insights & Tips](https://learn.flowstudio.app/zh-hant/blog/tag/insights-tips), [Debugging](https://learn.flowstudio.app/zh-hant/blog/tag/debugging), [MCP](https://learn.flowstudio.app/zh-hant/blog/tag/mcp), [Power Automate](https://learn.flowstudio.app/zh-hant/blog/tag/power-automate), [AI Agents](https://learn.flowstudio.app/zh-hant/blog/tag/ai-agents), [Vibe Coding](https://learn.flowstudio.app/zh-hant/blog/tag/vibe-coding)

## [為什麼我會叫一個 Reddit 上的創業老闆不要去學 Power Automate](https://learn.flowstudio.app/zh-hant/blog/stop-learning-power-automate-ai-agent-mcp-zh-tw?hsLang=zh-hant)

![Picture of Catherine Han](https://learn.flowstudio.app/hs-fs/hubfs/catherine-circle.jpg?width=50&name=catherine-circle.jpg) [Catherine Han](https://learn.flowstudio.app/zh-hant/blog/author/catherine-han) 

 Apr 12, 2026, 1:06:06 AM

昨天我在 Reddit 的 r/PowerAutomate 看到一篇貼文。 是一個一人公司的老闆發的。他手上同時有 50 個案子在跑，用...

[Read more](https://learn.flowstudio.app/zh-hant/blog/stop-learning-power-automate-ai-agent-mcp-zh-tw?hsLang=zh-hant)

[![AI agent 使用 MCP server 除錯 Power Automate 流程](https://learn.flowstudio.app/hs-fs/hubfs/blog-images/ai-agent-debugging-power-automate.jpg?height=200&name=ai-agent-debugging-power-automate.jpg)](https://learn.flowstudio.app/zh-hant/blog/ai-agents-power-automate-debugging-trap-zh-tw?hsLang=zh-hant)

[Debugging](https://learn.flowstudio.app/zh-hant/blog/tag/debugging), [MCP](https://learn.flowstudio.app/zh-hant/blog/tag/mcp), [Power Automate](https://learn.flowstudio.app/zh-hant/blog/tag/power-automate), [AI Agents](https://learn.flowstudio.app/zh-hant/blog/tag/ai-agents), [Vibe Coding](https://learn.flowstudio.app/zh-hant/blog/tag/vibe-coding)

## [AI Agent 幫我建 Power Automate 流程，結果除錯燒掉 $20 美金](https://learn.flowstudio.app/zh-hant/blog/ai-agents-power-automate-debugging-trap-zh-tw?hsLang=zh-hant)

![Picture of Catherine Han](https://learn.flowstudio.app/hs-fs/hubfs/catherine-circle.jpg?width=50&name=catherine-circle.jpg) [Catherine Han](https://learn.flowstudio.app/zh-hant/blog/author/catherine-han) 

 Mar 16, 2026, 11:49:19 PM

這陣子我迷上了 OpenClaw。 一開始只是好奇，想玩看看 AI agent 到底能幹嘛。結果一發不可收拾—— 我買了一台 Raspberry Pi 5 來當蝦蝦的家、訂了 Claude...

[Read more](https://learn.flowstudio.app/zh-hant/blog/ai-agents-power-automate-debugging-trap-zh-tw?hsLang=zh-hant)

[![Flow Studio](https://learn.flowstudio.app/hs-fs/hubfs/flow-studio-transparency.png?width=90&height=90&name=flow-studio-transparency.png "Flow Studio")](https://flowstudio.app)

flowstudio.app

---

[Go to FlowStudio MCP](https://mcp.flowstudio.app/)

[Go to FlowStudio App](https://flowstudio.app/)

[youtube icon](https://www.youtube.com/playlist?list=PLXiXrMydfoLYzS-Ya3yOmYvfEyLbkXhpQ) [linkedin-in icon](https://www.linkedin.com/company/flow-studio-solutions/about/) [envelope icon](mailto:support@flowstudio.app) [link icon](https://flowstudio.app/)

Copyright © 2026, Flow Studio Solutions

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Catherine Han",
    "url" : "https://learn.flowstudio.app/zh-hant/blog/author/catherine-han"
  },
  "dateModified" : "2026-03-16T13:04:57.856Z",
  "datePublished" : "2026-03-16T12:49:19.000Z",
  "headline" : "用 AI Agent 幫客戶寫 Power Automate Flow, 從 80 個 Action 到 17 個",
  "image" : [ "https://learn.flowstudio.app/hubfs/blog-featured-images/cover-dictionary-pattern.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://learn.flowstudio.app/zh-hant/blog/ai-agent-build-power-automate-flow-dictionary-pattern-zh-tw",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://learn.flowstudio.app/hubfs/flow-studio-transparency.png"
    },
    "name" : "Flow Studio Solutions"
  }
}
```