[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F4N5A9ASH06T3Y9XQRTK66":3,"skill-same:01M6F4N5A9ASH06T3Y9XQRTK66":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M6F4N5A9ASH06T3Y9XQRTK66","flowstudio-power-automate-build",null,"Build, scaffold, and deploy Power Automate cloud flows using the FlowStudio MCP server. Load this skill when asked to: create a flow, build a new flow, deploy a flow definition, scaffold a Power Automate workflow, construct a flow JSON, update an existing flow's actions, patch a flow definition, add actions to a flow, wire up connections, or generate a workflow definition from scratch. Requires a FlowStudio MCP subscription — see https:\u002F\u002Fmcp.flowstudio.app","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fgithub\u002Fawesome-copilot\u002Fflowstudio-power-automate-build\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"build","flowstudio power automate build","automate","power","flows","MCP","From Scratch","add","app","connections","patch","up","flow","actions","server","update","generate","create","workflow","mcp server","2026-11-10 10:12:30",false,"---\nname: flowstudio-power-automate-build\ndescription: >-\n  Build, scaffold, and deploy Power Automate cloud flows using the FlowStudio\n  MCP server. Load this skill when asked to: create a flow, build a new flow,\n  deploy a flow definition, scaffold a Power Automate workflow, construct a flow\n  JSON, update an existing flow's actions, patch a flow definition, add actions\n  to a flow, wire up connections, or generate a workflow definition from scratch.\n  Requires a FlowStudio MCP subscription — see https:\u002F\u002Fmcp.flowstudio.app\n---\n\n# Build & Deploy Power Automate Flows with FlowStudio MCP\n\nStep-by-step guide for constructing and deploying Power Automate cloud flows\nprogrammatically through the FlowStudio MCP server.\n\n**Prerequisite**: A FlowStudio MCP server must be reachable with a valid JWT.\nSee the `flowstudio-power-automate-mcp` skill for connection setup.  \nSubscribe at https:\u002F\u002Fmcp.flowstudio.app\n\n---\n\n## Source of Truth\n\n> **Always call `tools\u002Flist` first** to confirm available tool names and their\n> parameter schemas. Tool names and parameters may change between server versions.\n> This skill covers response shapes, behavioral notes, and build patterns —\n> things `tools\u002Flist` cannot tell you. If this document disagrees with `tools\u002Flist`\n> or a real API response, the API wins.\n\n---\n\n## Python Helper\n\n```python\nimport json, urllib.request\n\nMCP_URL   = \"https:\u002F\u002Fmcp.flowstudio.app\u002Fmcp\"\nMCP_TOKEN = \"\u003CYOUR_JWT_TOKEN>\"\n\ndef mcp(tool, **kwargs):\n    payload = json.dumps({\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools\u002Fcall\",\n                          \"params\": {\"name\": tool, \"arguments\": kwargs}}).encode()\n    req = urllib.request.Request(MCP_URL, data=payload,\n        headers={\"x-api-key\": MCP_TOKEN, \"Content-Type\": \"application\u002Fjson\",\n                 \"User-Agent\": \"FlowStudio-MCP\u002F1.0\"})\n    try:\n        resp = urllib.request.urlopen(req, timeout=120)\n    except urllib.error.HTTPError as e:\n        body = e.read().decode(\"utf-8\", errors=\"replace\")\n        raise RuntimeError(f\"MCP HTTP {e.code}: {body[:200]}\") from e\n    raw = json.loads(resp.read())\n    if \"error\" in raw:\n        raise RuntimeError(f\"MCP error: {json.dumps(raw['error'])}\")\n    return json.loads(raw[\"result\"][\"content\"][0][\"text\"])\n\nENV = \"\u003Cenvironment-id>\"  # e.g. Default-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n```\n\n---\n\n## Step 1 — Safety Check: Does the Flow Already Exist?\n\nAlways look before you build to avoid duplicates:\n\n```python\nresults = mcp(\"list_store_flows\",\n    environmentName=ENV, searchTerm=\"My New Flow\")\n\n# list_store_flows returns a direct array (no wrapper object)\nif len(results) > 0:\n    # Flow exists — modify rather than create\n    # id format is \"envId.flowId\" — split to get the flow UUID\n    FLOW_ID = results[0][\"id\"].split(\".\", 1)[1]\n    print(f\"Existing flow: {FLOW_ID}\")\n    defn = mcp(\"get_live_flow\", environmentName=ENV, flowName=FLOW_ID)\nelse:\n    print(\"Flow not found — building from scratch\")\n    FLOW_ID = None\n```\n\n---\n\n## Step 2 — Obtain Connection References\n\nEvery connector action needs a `connectionName` that points to a key in the\nflow's `connectionReferences` map. That key links to an authenticated connection\nin the environment.\n\n> **MANDATORY**: You MUST call `list_live_connections` first — do NOT ask the\n> user for connection names or GUIDs. The API returns the exact values you need.\n> Only prompt the user if the API confirms that required connections are missing.\n\n### 2a — Always call `list_live_connections` first\n\n```python\nconns = mcp(\"list_live_connections\", environmentName=ENV)\n\n# Filter to connected (authenticated) connections only\nactive = [c for c in conns[\"connections\"]\n          if c[\"statuses\"][0][\"status\"] == \"Connected\"]\n\n# Build a lookup: connectorName → connectionName (id)\nconn_map = {}\nfor c in active:\n    conn_map[c[\"connectorName\"]] = c[\"id\"]\n\nprint(f\"Found {len(active)} active connections\")\nprint(\"Available connectors:\", list(conn_map.keys()))\n```\n\n### 2b — Determine which connectors the flow needs\n\nBased on the flow you are building, identify which connectors are required.\nCommon connector API names:\n\n| Connector | API name |\n|---|---|\n| SharePoint | `shared_sharepointonline` |\n| Outlook \u002F Office 365 | `shared_office365` |\n| Teams | `shared_teams` |\n| Approvals | `shared_approvals` |\n| OneDrive for Business | `shared_onedriveforbusiness` |\n| Excel Online (Business) | `shared_excelonlinebusiness` |\n| Dataverse | `shared_commondataserviceforapps` |\n| Microsoft Forms | `shared_microsoftforms` |\n\n> **Flows that need NO connections** (e.g. Recurrence + Compose + HTTP only)\n> can skip the rest of Step 2 — omit `connectionReferences` from the deploy call.\n\n### 2c — If connections are missing, guide the user\n\n```python\nconnectors_needed = [\"shared_sharepointonline\", \"shared_office365\"]  # adjust per flow\n\nmissing = [c for c in connectors_needed if c not in conn_map]\n\nif not missing:\n    print(\"✅ All required connections are available — proceeding to build\")\nelse:\n    # ── STOP: connections must be created interactively ──\n    # Connections require OAuth consent in a browser — no API can create them.\n    print(\"⚠️  The following connectors have no active connection in this environment:\")\n    for c in missing:\n        friendly = c.replace(\"shared_\", \"\").replace(\"onlinebusiness\", \" Online (Business)\")\n        print(f\"   • {friendly}  (API name: {c})\")\n    print()\n    print(\"Please create the missing connections:\")\n    print(\"  1. Open https:\u002F\u002Fmake.powerautomate.com\u002Fconnections\")\n    print(\"  2. Select the correct environment from the top-right picker\")\n    print(\"  3. Click '+ New connection' for each missing connector listed above\")\n    print(\"  4. Sign in and authorize when prompted\")\n    print(\"  5. Tell me when done — I will re-check and continue building\")\n    # DO NOT proceed to Step 3 until the user confirms.\n    # After user confirms, re-run Step 2a to refresh conn_map.\n```\n\n### 2d — Build the connectionReferences block\n\nOnly execute this after 2c confirms no missing connectors:\n\n```python\nconnection_references = {}\nfor connector in connectors_needed:\n    connection_references[connector] = {\n        \"connectionName\": conn_map[connector],   # the GUID from list_live_connections\n        \"source\": \"Invoker\",\n        \"id\": f\"\u002Fproviders\u002FMicrosoft.PowerApps\u002Fapis\u002F{connector}\"\n    }\n```\n\n> **IMPORTANT — `host.connectionName` in actions**: When building actions in\n> Step 3, set `host.connectionName` to the **key** from this map (e.g.\n> `shared_teams`), NOT the connection GUID. The GUID only goes inside the\n> `connectionReferences` entry. The engine matches the action's\n> `host.connectionName` to the key to find the right connection.\n\n> **Alternative** — if you already have a flow using the same connectors,\n> you can extract `connectionReferences` from its definition:\n> ```python\n> ref_flow = mcp(\"get_live_flow\", environmentName=ENV, flowName=\"\u003Cexisting-flow-id>\")\n> connection_references = ref_flow[\"properties\"][\"connectionReferences\"]\n> ```\n\nSee the `power-automate-mcp` skill's **connection-references.md** reference\nfor the full connection reference structure.\n\n---\n\n## Step 3 — Build the Flow Definition\n\nConstruct the definition object. See [flow-schema.md](references\u002Fflow-schema.md)\nfor the full schema and these action pattern references for copy-paste templates:\n- [action-patterns-core.md](references\u002Faction-patterns-core.md) — Variables, control flow, expressions\n- [action-patterns-data.md](references\u002Faction-patterns-data.md) — Array transforms, HTTP, parsing\n- [action-patterns-connectors.md](references\u002Faction-patterns-connectors.md) — SharePoint, Outlook, Teams, Approvals\n\n```python\ndefinition = {\n    \"$schema\": \"https:\u002F\u002Fschema.management.azure.com\u002Fproviders\u002FMicrosoft.Logic\u002Fschemas\u002F2016-06-01\u002Fworkflowdefinition.json#\",\n    \"contentVersion\": \"1.0.0.0\",\n    \"triggers\": { ... },   # see trigger-types.md \u002F build-patterns.md\n    \"actions\": { ... }     # see ACTION-PATTERNS-*.md \u002F build-patterns.md\n}\n```\n\n> See [build-patterns.md](references\u002Fbuild-patterns.md) for complete, ready-to-use\n> flow definitions covering Recurrence+SharePoint+Teams, HTTP triggers, and more.\n\n---\n\n## Step 4 — Deploy (Create or Update)\n\n`update_live_flow` handles both creation and updates in a single tool.\n\n### Create a new flow (no existing flow)\n\nOmit `flowName` — the server generates a new GUID and creates via PUT:\n\n```python\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    # flowName omitted → creates a new flow\n    definition=definition,\n    connectionReferences=connection_references,\n    displayName=\"Overdue Invoice Notifications\",\n    description=\"Weekly SharePoint → Teams notification flow, built by agent\"\n)\n\nif result.get(\"error\") is not None:\n    print(\"Create failed:\", result[\"error\"])\nelse:\n    # Capture the new flow ID for subsequent steps\n    FLOW_ID = result[\"created\"]\n    print(f\"✅ Flow created: {FLOW_ID}\")\n```\n\n### Update an existing flow\n\nProvide `flowName` to PATCH:\n\n```python\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    flowName=FLOW_ID,\n    definition=definition,\n    connectionReferences=connection_references,\n    displayName=\"My Updated Flow\",\n    description=\"Updated by agent on \" + __import__('datetime').datetime.utcnow().isoformat()\n)\n\nif result.get(\"error\") is not None:\n    print(\"Update failed:\", result[\"error\"])\nelse:\n    print(\"Update succeeded:\", result)\n```\n\n> ⚠️ `update_live_flow` always returns an `error` key.\n> `null` (Python `None`) means success — do not treat the presence of the key as failure.\n>\n> ⚠️ `description` is required for both create and update.\n\n### Common deployment errors\n\n| Error message (contains) | Cause | Fix |\n|---|---|---|\n| `missing from connectionReferences` | An action's `host.connectionName` references a key that doesn't exist in the `connectionReferences` map | Ensure `host.connectionName` uses the **key** from `connectionReferences` (e.g. `shared_teams`), not the raw GUID |\n| `ConnectionAuthorizationFailed` \u002F 403 | The connection GUID belongs to another user or is not authorized | Re-run Step 2a and use a connection owned by the current `x-api-key` user |\n| `InvalidTemplate` \u002F `InvalidDefinition` | Syntax error in the definition JSON | Check `runAfter` chains, expression syntax, and action type spelling |\n| `ConnectionNotConfigured` | A connector action exists but the connection GUID is invalid or expired | Re-check `list_live_connections` for a fresh GUID |\n\n---\n\n## Step 5 — Verify the Deployment\n\n```python\ncheck = mcp(\"get_live_flow\", environmentName=ENV, flowName=FLOW_ID)\n\n# Confirm state\nprint(\"State:\", check[\"properties\"][\"state\"])  # Should be \"Started\"\n\n# Confirm the action we added is there\nacts = check[\"properties\"][\"definition\"][\"actions\"]\nprint(\"Actions:\", list(acts.keys()))\n```\n\n---\n\n## Step 6 — Test the Flow\n\n> **MANDATORY**: Before triggering any test run, **ask the user for confirmation**.\n> Running a flow has real side effects — it may send emails, post Teams messages,\n> write to SharePoint, start approvals, or call external APIs. Explain what the\n> flow will do and wait for explicit approval before calling `trigger_live_flow`\n> or `resubmit_live_flow_run`.\n\n### Updated flows (have prior runs)\n\nThe fastest path — resubmit the most recent run:\n\n```python\nruns = mcp(\"get_live_flow_runs\", environmentName=ENV, flowName=FLOW_ID, top=1)\nif runs:\n    result = mcp(\"resubmit_live_flow_run\",\n        environmentName=ENV, flowName=FLOW_ID, runName=runs[0][\"name\"])\n    print(result)\n```\n\n### Flows already using an HTTP trigger\n\nFire directly with a test payload:\n\n```python\nschema = mcp(\"get_live_flow_http_schema\",\n    environmentName=ENV, flowName=FLOW_ID)\nprint(\"Expected body:\", schema.get(\"triggerSchema\"))\n\nresult = mcp(\"trigger_live_flow\",\n    environmentName=ENV, flowName=FLOW_ID,\n    body={\"name\": \"Test\", \"value\": 1})\nprint(f\"Status: {result['status']}\")\n```\n\n### Brand-new non-HTTP flows (Recurrence, connector triggers, etc.)\n\nA brand-new Recurrence or connector-triggered flow has no runs to resubmit\nand no HTTP endpoint to call. **Deploy with a temporary HTTP trigger first,\ntest the actions, then swap to the production trigger.**\n\n#### 7a — Save the real trigger, deploy with a temporary HTTP trigger\n\n```python\n# Save the production trigger you built in Step 3\nproduction_trigger = definition[\"triggers\"]\n\n# Replace with a temporary HTTP trigger\ndefinition[\"triggers\"] = {\n    \"manual\": {\n        \"type\": \"Request\",\n        \"kind\": \"Http\",\n        \"inputs\": {\n            \"schema\": {}\n        }\n    }\n}\n\n# Deploy (create or update) with the temp trigger\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    flowName=FLOW_ID,       # omit if creating new\n    definition=definition,\n    connectionReferences=connection_references,\n    displayName=\"Overdue Invoice Notifications\",\n    description=\"Deployed with temp HTTP trigger for testing\")\n\nif result.get(\"error\") is not None:\n    print(\"Deploy failed:\", result[\"error\"])\nelse:\n    if not FLOW_ID:\n        FLOW_ID = result[\"created\"]\n    print(f\"✅ Deployed with temp HTTP trigger: {FLOW_ID}\")\n```\n\n#### 7b — Fire the flow and check the result\n\n```python\n# Trigger the flow\ntest = mcp(\"trigger_live_flow\",\n    environmentName=ENV, flowName=FLOW_ID)\nprint(f\"Trigger response status: {test['status']}\")\n\n# Wait for the run to complete\nimport time; time.sleep(15)\n\n# Check the run result\nruns = mcp(\"get_live_flow_runs\",\n    environmentName=ENV, flowName=FLOW_ID, top=1)\nrun = runs[0]\nprint(f\"Run {run['name']}: {run['status']}\")\n\nif run[\"status\"] == \"Failed\":\n    err = mcp(\"get_live_flow_run_error\",\n        environmentName=ENV, flowName=FLOW_ID, runName=run[\"name\"])\n    root = err[\"failedActions\"][-1]\n    print(f\"Root cause: {root['actionName']} → {root.get('code')}\")\n    # Debug and fix the definition before proceeding\n    # See power-automate-debug skill for full diagnosis workflow\n```\n\n#### 7c — Swap to the production trigger\n\nOnce the test run succeeds, replace the temporary HTTP trigger with the real one:\n\n```python\n# Restore the production trigger\ndefinition[\"triggers\"] = production_trigger\n\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    flowName=FLOW_ID,\n    definition=definition,\n    connectionReferences=connection_references,\n    description=\"Swapped to production trigger after successful test\")\n\nif result.get(\"error\") is not None:\n    print(\"Trigger swap failed:\", result[\"error\"])\nelse:\n    print(\"✅ Production trigger deployed — flow is live\")\n```\n\n> **Why this works**: The trigger is just the entry point — the actions are\n> identical regardless of how the flow starts. Testing via HTTP trigger\n> exercises all the same Compose, SharePoint, Teams, etc. actions.\n>\n> **Connector triggers** (e.g. \"When an item is created in SharePoint\"):\n> If actions reference `triggerBody()` or `triggerOutputs()`, pass a\n> representative test payload in `trigger_live_flow`'s `body` parameter\n> that matches the shape the connector trigger would produce.\n\n---\n\n## Gotchas\n\n| Mistake | Consequence | Prevention |\n|---|---|---|\n| Missing `connectionReferences` in deploy | 400 \"Supply connectionReferences\" | Always call `list_live_connections` first |\n| `\"operationOptions\"` missing on Foreach | Parallel execution, race conditions on writes | Always add `\"Sequential\"` |\n| `union(old_data, new_data)` | Old values override new (first-wins) | Use `union(new_data, old_data)` |\n| `split()` on potentially-null string | `InvalidTemplate` crash | Wrap with `coalesce(field, '')` |\n| Checking `result[\"error\"]` exists | Always present; true error is `!= null` | Use `result.get(\"error\") is not None` |\n| Flow deployed but state is \"Stopped\" | Flow won't run on schedule | Check connection auth; re-enable |\n| Teams \"Chat with Flow bot\" recipient as object | 400 `GraphUserDetailNotFound` | Use plain string with trailing semicolon (see below) |\n\n### Teams `PostMessageToConversation` — Recipient Formats\n\nThe `body\u002Frecipient` parameter format depends on the `location` value:\n\n| Location | `body\u002Frecipient` format | Example |\n|---|---|---|\n| **Chat with Flow bot** | Plain email string with **trailing semicolon** | `\"user@contoso.com;\"` |\n| **Channel** | Object with `groupId` and `channelId` | `{\"groupId\": \"...\", \"channelId\": \"...\"}` |\n\n> **Common mistake**: passing `{\"to\": \"user@contoso.com\"}` for \"Chat with Flow bot\"\n> returns a 400 `GraphUserDetailNotFound` error. The API expects a plain string.\n\n---\n\n## Reference Files\n\n- [flow-schema.md](references\u002Fflow-schema.md) — Full flow definition JSON schema\n- [trigger-types.md](references\u002Ftrigger-types.md) — Trigger type templates\n- [action-patterns-core.md](references\u002Faction-patterns-core.md) — Variables, control flow, expressions\n- [action-patterns-data.md](references\u002Faction-patterns-data.md) — Array transforms, HTTP, parsing\n- [action-patterns-connectors.md](references\u002Faction-patterns-connectors.md) — SharePoint, Outlook, Teams, Approvals\n- [build-patterns.md](references\u002Fbuild-patterns.md) — Complete flow definition templates (Recurrence+SP+Teams, HTTP trigger)\n\n## Related Skills\n\n- `flowstudio-power-automate-mcp` — Core connection setup and tool reference\n- `flowstudio-power-automate-debug` — Debug failing flows after deployment\n\n","# Build & Deploy Power Automate Flows with FlowStudio MCP\n\nStep-by-step guide for constructing and deploying Power Automate cloud flows\nprogrammatically through the FlowStudio MCP server.\n\n**Prerequisite**: A FlowStudio MCP server must be reachable with a valid JWT.\nSee the `flowstudio-power-automate-mcp` skill for connection setup.  \nSubscribe at https:\u002F\u002Fmcp.flowstudio.app\n\n---\n\n## Source of Truth\n\n> **Always call `tools\u002Flist` first** to confirm available tool names and their\n> parameter schemas. Tool names and parameters may change between server versions.\n> This skill covers response shapes, behavioral notes, and build patterns —\n> things `tools\u002Flist` cannot tell you. If this document disagrees with `tools\u002Flist`\n> or a real API response, the API wins.\n\n---\n\n## Python Helper\n\n```python\nimport json, urllib.request\n\nMCP_URL   = \"https:\u002F\u002Fmcp.flowstudio.app\u002Fmcp\"\nMCP_TOKEN = \"\u003CYOUR_JWT_TOKEN>\"\n\ndef mcp(tool, **kwargs):\n    payload = json.dumps({\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools\u002Fcall\",\n                          \"params\": {\"name\": tool, \"arguments\": kwargs}}).encode()\n    req = urllib.request.Request(MCP_URL, data=payload,\n        headers={\"x-api-key\": MCP_TOKEN, \"Content-Type\": \"application\u002Fjson\",\n                 \"User-Agent\": \"FlowStudio-MCP\u002F1.0\"})\n    try:\n        resp = urllib.request.urlopen(req, timeout=120)\n    except urllib.error.HTTPError as e:\n        body = e.read().decode(\"utf-8\", errors=\"replace\")\n        raise RuntimeError(f\"MCP HTTP {e.code}: {body[:200]}\") from e\n    raw = json.loads(resp.read())\n    if \"error\" in raw:\n        raise RuntimeError(f\"MCP error: {json.dumps(raw['error'])}\")\n    return json.loads(raw[\"result\"][\"content\"][0][\"text\"])\n\nENV = \"\u003Cenvironment-id>\"  # e.g. Default-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n```\n\n---\n\n## Step 1 — Safety Check: Does the Flow Already Exist?\n\nAlways look before you build to avoid duplicates:\n\n```python\nresults = mcp(\"list_store_flows\",\n    environmentName=ENV, searchTerm=\"My New Flow\")\n\n# list_store_flows returns a direct array (no wrapper object)\nif len(results) > 0:\n    # Flow exists — modify rather than create\n    # id format is \"envId.flowId\" — split to get the flow UUID\n    FLOW_ID = results[0][\"id\"].split(\".\", 1)[1]\n    print(f\"Existing flow: {FLOW_ID}\")\n    defn = mcp(\"get_live_flow\", environmentName=ENV, flowName=FLOW_ID)\nelse:\n    print(\"Flow not found — building from scratch\")\n    FLOW_ID = None\n```\n\n---\n\n## Step 2 — Obtain Connection References\n\nEvery connector action needs a `connectionName` that points to a key in the\nflow's `connectionReferences` map. That key links to an authenticated connection\nin the environment.\n\n> **MANDATORY**: You MUST call `list_live_connections` first — do NOT ask the\n> user for connection names or GUIDs. The API returns the exact values you need.\n> Only prompt the user if the API confirms that required connections are missing.\n\n### 2a — Always call `list_live_connections` first\n\n```python\nconns = mcp(\"list_live_connections\", environmentName=ENV)\n\n# Filter to connected (authenticated) connections only\nactive = [c for c in conns[\"connections\"]\n          if c[\"statuses\"][0][\"status\"] == \"Connected\"]\n\n# Build a lookup: connectorName → connectionName (id)\nconn_map = {}\nfor c in active:\n    conn_map[c[\"connectorName\"]] = c[\"id\"]\n\nprint(f\"Found {len(active)} active connections\")\nprint(\"Available connectors:\", list(conn_map.keys()))\n```\n\n### 2b — Determine which connectors the flow needs\n\nBased on the flow you are building, identify which connectors are required.\nCommon connector API names:\n\n| Connector | API name |\n|---|---|\n| SharePoint | `shared_sharepointonline` |\n| Outlook \u002F Office 365 | `shared_office365` |\n| Teams | `shared_teams` |\n| Approvals | `shared_approvals` |\n| OneDrive for Business | `shared_onedriveforbusiness` |\n| Excel Online (Business) | `shared_excelonlinebusiness` |\n| Dataverse | `shared_commondataserviceforapps` |\n| Microsoft Forms | `shared_microsoftforms` |\n\n> **Flows that need NO connections** (e.g. Recurrence + Compose + HTTP only)\n> can skip the rest of Step 2 — omit `connectionReferences` from the deploy call.\n\n### 2c — If connections are missing, guide the user\n\n```python\nconnectors_needed = [\"shared_sharepointonline\", \"shared_office365\"]  # adjust per flow\n\nmissing = [c for c in connectors_needed if c not in conn_map]\n\nif not missing:\n    print(\"✅ All required connections are available — proceeding to build\")\nelse:\n    # ── STOP: connections must be created interactively ──\n    # Connections require OAuth consent in a browser — no API can create them.\n    print(\"⚠️  The following connectors have no active connection in this environment:\")\n    for c in missing:\n        friendly = c.replace(\"shared_\", \"\").replace(\"onlinebusiness\", \" Online (Business)\")\n        print(f\"   • {friendly}  (API name: {c})\")\n    print()\n    print(\"Please create the missing connections:\")\n    print(\"  1. Open https:\u002F\u002Fmake.powerautomate.com\u002Fconnections\")\n    print(\"  2. Select the correct environment from the top-right picker\")\n    print(\"  3. Click '+ New connection' for each missing connector listed above\")\n    print(\"  4. Sign in and authorize when prompted\")\n    print(\"  5. Tell me when done — I will re-check and continue building\")\n    # DO NOT proceed to Step 3 until the user confirms.\n    # After user confirms, re-run Step 2a to refresh conn_map.\n```\n\n### 2d — Build the connectionReferences block\n\nOnly execute this after 2c confirms no missing connectors:\n\n```python\nconnection_references = {}\nfor connector in connectors_needed:\n    connection_references[connector] = {\n        \"connectionName\": conn_map[connector],   # the GUID from list_live_connections\n        \"source\": \"Invoker\",\n        \"id\": f\"\u002Fproviders\u002FMicrosoft.PowerApps\u002Fapis\u002F{connector}\"\n    }\n```\n\n> **IMPORTANT — `host.connectionName` in actions**: When building actions in\n> Step 3, set `host.connectionName` to the **key** from this map (e.g.\n> `shared_teams`), NOT the connection GUID. The GUID only goes inside the\n> `connectionReferences` entry. The engine matches the action's\n> `host.connectionName` to the key to find the right connection.\n\n> **Alternative** — if you already have a flow using the same connectors,\n> you can extract `connectionReferences` from its definition:\n> ```python\n> ref_flow = mcp(\"get_live_flow\", environmentName=ENV, flowName=\"\u003Cexisting-flow-id>\")\n> connection_references = ref_flow[\"properties\"][\"connectionReferences\"]\n> ```\n\nSee the `power-automate-mcp` skill's **connection-references.md** reference\nfor the full connection reference structure.\n\n---\n\n## Step 3 — Build the Flow Definition\n\nConstruct the definition object. See [flow-schema.md](references\u002Fflow-schema.md)\nfor the full schema and these action pattern references for copy-paste templates:\n- [action-patterns-core.md](references\u002Faction-patterns-core.md) — Variables, control flow, expressions\n- [action-patterns-data.md](references\u002Faction-patterns-data.md) — Array transforms, HTTP, parsing\n- [action-patterns-connectors.md](references\u002Faction-patterns-connectors.md) — SharePoint, Outlook, Teams, Approvals\n\n```python\ndefinition = {\n    \"$schema\": \"https:\u002F\u002Fschema.management.azure.com\u002Fproviders\u002FMicrosoft.Logic\u002Fschemas\u002F2016-06-01\u002Fworkflowdefinition.json#\",\n    \"contentVersion\": \"1.0.0.0\",\n    \"triggers\": { ... },   # see trigger-types.md \u002F build-patterns.md\n    \"actions\": { ... }     # see ACTION-PATTERNS-*.md \u002F build-patterns.md\n}\n```\n\n> See [build-patterns.md](references\u002Fbuild-patterns.md) for complete, ready-to-use\n> flow definitions covering Recurrence+SharePoint+Teams, HTTP triggers, and more.\n\n---\n\n## Step 4 — Deploy (Create or Update)\n\n`update_live_flow` handles both creation and updates in a single tool.\n\n### Create a new flow (no existing flow)\n\nOmit `flowName` — the server generates a new GUID and creates via PUT:\n\n```python\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    # flowName omitted → creates a new flow\n    definition=definition,\n    connectionReferences=connection_references,\n    displayName=\"Overdue Invoice Notifications\",\n    description=\"Weekly SharePoint → Teams notification flow, built by agent\"\n)\n\nif result.get(\"error\") is not None:\n    print(\"Create failed:\", result[\"error\"])\nelse:\n    # Capture the new flow ID for subsequent steps\n    FLOW_ID = result[\"created\"]\n    print(f\"✅ Flow created: {FLOW_ID}\")\n```\n\n### Update an existing flow\n\nProvide `flowName` to PATCH:\n\n```python\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    flowName=FLOW_ID,\n    definition=definition,\n    connectionReferences=connection_references,\n    displayName=\"My Updated Flow\",\n    description=\"Updated by agent on \" + __import__('datetime').datetime.utcnow().isoformat()\n)\n\nif result.get(\"error\") is not None:\n    print(\"Update failed:\", result[\"error\"])\nelse:\n    print(\"Update succeeded:\", result)\n```\n\n> ⚠️ `update_live_flow` always returns an `error` key.\n> `null` (Python `None`) means success — do not treat the presence of the key as failure.\n>\n> ⚠️ `description` is required for both create and update.\n\n### Common deployment errors\n\n| Error message (contains) | Cause | Fix |\n|---|---|---|\n| `missing from connectionReferences` | An action's `host.connectionName` references a key that doesn't exist in the `connectionReferences` map | Ensure `host.connectionName` uses the **key** from `connectionReferences` (e.g. `shared_teams`), not the raw GUID |\n| `ConnectionAuthorizationFailed` \u002F 403 | The connection GUID belongs to another user or is not authorized | Re-run Step 2a and use a connection owned by the current `x-api-key` user |\n| `InvalidTemplate` \u002F `InvalidDefinition` | Syntax error in the definition JSON | Check `runAfter` chains, expression syntax, and action type spelling |\n| `ConnectionNotConfigured` | A connector action exists but the connection GUID is invalid or expired | Re-check `list_live_connections` for a fresh GUID |\n\n---\n\n## Step 5 — Verify the Deployment\n\n```python\ncheck = mcp(\"get_live_flow\", environmentName=ENV, flowName=FLOW_ID)\n\n# Confirm state\nprint(\"State:\", check[\"properties\"][\"state\"])  # Should be \"Started\"\n\n# Confirm the action we added is there\nacts = check[\"properties\"][\"definition\"][\"actions\"]\nprint(\"Actions:\", list(acts.keys()))\n```\n\n---\n\n## Step 6 — Test the Flow\n\n> **MANDATORY**: Before triggering any test run, **ask the user for confirmation**.\n> Running a flow has real side effects — it may send emails, post Teams messages,\n> write to SharePoint, start approvals, or call external APIs. Explain what the\n> flow will do and wait for explicit approval before calling `trigger_live_flow`\n> or `resubmit_live_flow_run`.\n\n### Updated flows (have prior runs)\n\nThe fastest path — resubmit the most recent run:\n\n```python\nruns = mcp(\"get_live_flow_runs\", environmentName=ENV, flowName=FLOW_ID, top=1)\nif runs:\n    result = mcp(\"resubmit_live_flow_run\",\n        environmentName=ENV, flowName=FLOW_ID, runName=runs[0][\"name\"])\n    print(result)\n```\n\n### Flows already using an HTTP trigger\n\nFire directly with a test payload:\n\n```python\nschema = mcp(\"get_live_flow_http_schema\",\n    environmentName=ENV, flowName=FLOW_ID)\nprint(\"Expected body:\", schema.get(\"triggerSchema\"))\n\nresult = mcp(\"trigger_live_flow\",\n    environmentName=ENV, flowName=FLOW_ID,\n    body={\"name\": \"Test\", \"value\": 1})\nprint(f\"Status: {result['status']}\")\n```\n\n### Brand-new non-HTTP flows (Recurrence, connector triggers, etc.)\n\nA brand-new Recurrence or connector-triggered flow has no runs to resubmit\nand no HTTP endpoint to call. **Deploy with a temporary HTTP trigger first,\ntest the actions, then swap to the production trigger.**\n\n#### 7a — Save the real trigger, deploy with a temporary HTTP trigger\n\n```python\n# Save the production trigger you built in Step 3\nproduction_trigger = definition[\"triggers\"]\n\n# Replace with a temporary HTTP trigger\ndefinition[\"triggers\"] = {\n    \"manual\": {\n        \"type\": \"Request\",\n        \"kind\": \"Http\",\n        \"inputs\": {\n            \"schema\": {}\n        }\n    }\n}\n\n# Deploy (create or update) with the temp trigger\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    flowName=FLOW_ID,       # omit if creating new\n    definition=definition,\n    connectionReferences=connection_references,\n    displayName=\"Overdue Invoice Notifications\",\n    description=\"Deployed with temp HTTP trigger for testing\")\n\nif result.get(\"error\") is not None:\n    print(\"Deploy failed:\", result[\"error\"])\nelse:\n    if not FLOW_ID:\n        FLOW_ID = result[\"created\"]\n    print(f\"✅ Deployed with temp HTTP trigger: {FLOW_ID}\")\n```\n\n#### 7b — Fire the flow and check the result\n\n```python\n# Trigger the flow\ntest = mcp(\"trigger_live_flow\",\n    environmentName=ENV, flowName=FLOW_ID)\nprint(f\"Trigger response status: {test['status']}\")\n\n# Wait for the run to complete\nimport time; time.sleep(15)\n\n# Check the run result\nruns = mcp(\"get_live_flow_runs\",\n    environmentName=ENV, flowName=FLOW_ID, top=1)\nrun = runs[0]\nprint(f\"Run {run['name']}: {run['status']}\")\n\nif run[\"status\"] == \"Failed\":\n    err = mcp(\"get_live_flow_run_error\",\n        environmentName=ENV, flowName=FLOW_ID, runName=run[\"name\"])\n    root = err[\"failedActions\"][-1]\n    print(f\"Root cause: {root['actionName']} → {root.get('code')}\")\n    # Debug and fix the definition before proceeding\n    # See power-automate-debug skill for full diagnosis workflow\n```\n\n#### 7c — Swap to the production trigger\n\nOnce the test run succeeds, replace the temporary HTTP trigger with the real one:\n\n```python\n# Restore the production trigger\ndefinition[\"triggers\"] = production_trigger\n\nresult = mcp(\"update_live_flow\",\n    environmentName=ENV,\n    flowName=FLOW_ID,\n    definition=definition,\n    connectionReferences=connection_references,\n    description=\"Swapped to production trigger after successful test\")\n\nif result.get(\"error\") is not None:\n    print(\"Trigger swap failed:\", result[\"error\"])\nelse:\n    print(\"✅ Production trigger deployed — flow is live\")\n```\n\n> **Why this works**: The trigger is just the entry point — the actions are\n> identical regardless of how the flow starts. Testing via HTTP trigger\n> exercises all the same Compose, SharePoint, Teams, etc. actions.\n>\n> **Connector triggers** (e.g. \"When an item is created in SharePoint\"):\n> If actions reference `triggerBody()` or `triggerOutputs()`, pass a\n> representative test payload in `trigger_live_flow`'s `body` parameter\n> that matches the shape the connector trigger would produce.\n\n---\n\n## Gotchas\n\n| Mistake | Consequence | Prevention |\n|---|---|---|\n| Missing `connectionReferences` in deploy | 400 \"Supply connectionReferences\" | Always call `list_live_connections` first |\n| `\"operationOptions\"` missing on Foreach | Parallel execution, race conditions on writes | Always add `\"Sequential\"` |\n| `union(old_data, new_data)` | Old values override new (first-wins) | Use `union(new_data, old_data)` |\n| `split()` on potentially-null string | `InvalidTemplate` crash | Wrap with `coalesce(field, '')` |\n| Checking `result[\"error\"]` exists | Always present; true error is `!= null` | Use `result.get(\"error\") is not None` |\n| Flow deployed but state is \"Stopped\" | Flow won't run on schedule | Check connection auth; re-enable |\n| Teams \"Chat with Flow bot\" recipient as object | 400 `GraphUserDetailNotFound` | Use plain string with trailing semicolon (see below) |\n\n### Teams `PostMessageToConversation` — Recipient Formats\n\nThe `body\u002Frecipient` parameter format depends on the `location` value:\n\n| Location | `body\u002Frecipient` format | Example |\n|---|---|---|\n| **Chat with Flow bot** | Plain email string with **trailing semicolon** | `\"user@contoso.com;\"` |\n| **Channel** | Object with `groupId` and `channelId` | `{\"groupId\": \"...\", \"channelId\": \"...\"}` |\n\n> **Common mistake**: passing `{\"to\": \"user@contoso.com\"}` for \"Chat with Flow bot\"\n> returns a 400 `GraphUserDetailNotFound` error. The API expects a plain string.\n\n---\n\n## Reference Files\n\n- [flow-schema.md](references\u002Fflow-schema.md) — Full flow definition JSON schema\n- [trigger-types.md](references\u002Ftrigger-types.md) — Trigger type templates\n- [action-patterns-core.md](references\u002Faction-patterns-core.md) — Variables, control flow, expressions\n- [action-patterns-data.md](references\u002Faction-patterns-data.md) — Array transforms, HTTP, parsing\n- [action-patterns-connectors.md](references\u002Faction-patterns-connectors.md) — SharePoint, Outlook, Teams, Approvals\n- [build-patterns.md](references\u002Fbuild-patterns.md) — Complete flow definition templates (Recurrence+SP+Teams, HTTP trigger)\n\n## Related Skills\n\n- `flowstudio-power-automate-mcp` — Core connection setup and tool reference\n- `flowstudio-power-automate-debug` — Debug failing flows after deployment\n\n",{"name":5,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fgithub\u002Fawesome-copilot\u002Fflowstudio-power-automate-build",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill flowstudio-power-automate-build",{"tool":59,"command":60},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill flowstudio-power-automate-build",{"tool":62,"command":63},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill flowstudio-power-automate-build","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fgithub\u002Fawesome-copilot\u002Fflowstudio-power-automate-build\u002FSKILL.md",true,[],[68,77,85,94,100,106],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[74,75,76],"model","model hierarchy","model hierarchy skill",{"skillNo":78,"name":79,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[24,83,84],"zoom","zoom mcp",{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[91,92,93,83],"sdk","zoom apps sdk","apps",{"skillNo":95,"name":96,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[96],{"skillNo":101,"name":102,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[102],{"skillNo":107,"name":108,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[108]]