🚀 New batches open: Advanced Excel • Power BI • SQL • AI for Analytics — Book a free demo

Day 11 — A real flow, end to end

Everything so far, doing one real job from start to finish.

The brief

A form gives you an enrolment. The flow must:

  1. Clean the name, email and region
  2. Reject it early if the essentials are missing
  3. Work out the fee including GST
  4. Route it - manager approval over 25,000, fast track for priority regions, otherwise the standard queue
  5. Turn the multi-select interests into a list
  6. Email the student and notify the team

Read the brief, then build it yourself before scrolling. It is worth the hour.

Step one - clean and validate

{
  "trigger": {
    "name": "When a form is submitted",
    "type": "automated",
    "body": {
      "Name": "  priya NAIR ",
      "Email": " Priya.Nair@Example.COM ",
      "Phone": "+91 98765 43210",
      "Region": " north ",
      "Course": "Power BI",
      "Fee": 14000,
      "Interests": "Dashboards;DAX;Power Query"
    }
  },
  "actions": [
    { "name": "Clean name", "type": "Compose",
      "input": "@concat(toUpper(substring(trim(triggerBody()?['Name']), 0, 1)), toLower(substring(trim(triggerBody()?['Name']), 1)))" },
    { "name": "Clean email", "type": "Compose",
      "input": "@toLower(trim(triggerBody()?['Email']))" },
    { "name": "Clean region", "type": "Compose",
      "input": "@toLower(trim(triggerBody()?['Region']))" },
    { "name": "Clean phone", "type": "Compose",
      "input": "@replace(replace(replace(triggerBody()?['Phone'], '+91', ''), ' ', ''), '-', '')" },
    {
      "name": "Anything missing?",
      "type": "Condition",
      "expression": "@or(empty(outputs('Clean name')), empty(outputs('Clean email')))",
      "yes": [
        { "name": "Reject", "type": "Terminate", "status": "Cancelled",
          "message": "Name or email was blank" }
      ],
      "no": []
    },
    { "name": "Validated", "type": "Compose",
      "input": "@{outputs('Clean name')} - @{outputs('Clean email')} - @{outputs('Clean phone')}" }
  ]
}

Blank out the Name in the trigger and run it again to watch the early exit.

Look closely at the cleaned name " priya NAIR " comes out as Priya nair, not "Priya Nair". The one-liner upper-cases the first character and lower-cases everything after it - which is sentence case, not title case. It is right for a single word and wrong for a full name.
There is no title-case function in Power Automate. To do it properly you have to split on the space, capitalise each part in an Apply to each, and join them back. Whether that is worth six actions depends on whether the name goes in an email greeting or into a database. Know the limitation and decide on purpose - do not let a customer discover it for you.

The whole thing

{
  "trigger": {
    "name": "When a form is submitted",
    "type": "automated",
    "body": {
      "Name": "  priya NAIR ",
      "Email": " Priya.Nair@Example.COM ",
      "Phone": "+91 98765 43210",
      "Region": " north ",
      "Course": "Power BI",
      "Fee": 14000,
      "Interests": "Dashboards;DAX;Power Query"
    }
  },
  "actions": [
    { "name": "Init route", "type": "InitializeVariable", "variable": "route", "value": "" },
    { "name": "Init notes", "type": "InitializeVariable", "variable": "notes", "value": [] },

    { "name": "Clean name", "type": "Compose",
      "input": "@concat(toUpper(substring(trim(triggerBody()?['Name']), 0, 1)), toLower(substring(trim(triggerBody()?['Name']), 1)))" },
    { "name": "Clean email", "type": "Compose",
      "input": "@toLower(trim(triggerBody()?['Email']))" },
    { "name": "Clean region", "type": "Compose",
      "input": "@toLower(trim(triggerBody()?['Region']))" },

    {
      "name": "Anything missing?",
      "type": "Condition",
      "expression": "@or(empty(outputs('Clean name')), empty(outputs('Clean email')))",
      "yes": [
        { "name": "Reject", "type": "Terminate", "status": "Cancelled",
          "message": "Name or email was blank" }
      ],
      "no": []
    },

    { "name": "GST", "type": "Compose",
      "input": "@mul(triggerBody()?['Fee'], 0.18)" },
    { "name": "Total fee", "type": "Compose",
      "input": "@int(add(triggerBody()?['Fee'], outputs('GST')))" },

    {
      "name": "Needs approval?",
      "type": "Condition",
      "expression": "@greaterOrEquals(outputs('Total fee'), 25000)",
      "yes": [
        { "name": "To manager", "type": "SetVariable", "variable": "route", "value": "Manager approval" },
        { "name": "Note approval", "type": "AppendToArrayVariable", "variable": "notes",
          "value": "Over the approval threshold" }
      ],
      "no": [
        {
          "name": "Priority region?",
          "type": "Condition",
          "expression": "@or(equals(outputs('Clean region'),'north'), equals(outputs('Clean region'),'west'))",
          "yes": [
            { "name": "Fast track", "type": "SetVariable", "variable": "route", "value": "Fast track" },
            { "name": "Note region", "type": "AppendToArrayVariable", "variable": "notes",
              "value": "Priority region" }
          ],
          "no": [
            { "name": "Standard", "type": "SetVariable", "variable": "route", "value": "Standard queue" }
          ]
        }
      ]
    },

    { "name": "Interest list", "type": "Compose",
      "input": "@split(triggerBody()?['Interests'], ';')" },
    { "name": "Interest count", "type": "Compose",
      "input": "@length(outputs('Interest list'))" },
    { "name": "Interests text", "type": "Compose",
      "input": "@join(outputs('Interest list'), ', ')" },

    { "name": "Start date", "type": "Compose",
      "input": "@addDays(utcNow(), 14, 'dd MMM yyyy')" },

    { "name": "Email the student", "type": "SendEmail",
      "to": "@outputs('Clean email')",
      "subject": "Your @{triggerBody()?['Course']} enrolment",
      "body": "Dear @{outputs('Clean name')},\n\nYour place on @{triggerBody()?['Course']} is confirmed.\nTotal fee including GST: @{outputs('Total fee')}\nYour batch starts on @{outputs('Start date')}.\n\nYou told us you are interested in: @{outputs('Interests text')}.\n\nDAI ACADEMY, Noida" },

    { "name": "Notify the team", "type": "SendEmail",
      "to": "admissions@dai-academy.com",
      "subject": "[@{variables('route')}] @{outputs('Clean name')} - @{triggerBody()?['Course']}",
      "body": "Route: @{variables('route')}\nFee: @{outputs('Total fee')}\nRegion: @{outputs('Clean region')}\nInterests (@{outputs('Interest count')}): @{outputs('Interests text')}\nNotes: @{join(variables('notes'), '; ')}" }
  ]
}

Read the run history

14,000 plus 18 per cent is 16,520 - under the 25,000 threshold. The region is north, so it takes Fast track. Both emails are written out in full, with every expression resolved.

Three things worth trying:

  1. Change the Fee to 30000. The total becomes 35,400, the first condition takes the yes branch, and the route becomes Manager approval - and the nested region check is skipped entirely.
  2. Change the Region to "east" with the original fee. The route becomes Standard queue.
  3. Blank the Name. The flow terminates at the fourth action and every later step is marked Skipped.
Why the Composes are named the way they are "Clean email", "Total fee", "Interest list" - every downstream expression reads like a sentence because of it. Compare with what the designer gives you by default: outputs('Compose_7'). Naming actions is not tidiness, it is the difference between a flow you can maintain and one you rewrite.

What is missing from this flow

Before this went live it would need A Try/Catch scope around the email actions, so a mail failure notifies somebody rather than dying quietly. A check that the course name is one you actually run. A duplicate check, because forms get submitted twice. And a Terminate with status Succeeded for the legitimate "nothing to do" case.
The logic is the easy half. The reliability is the half that gets you paid.

Try these yourself

  1. Build the flow yourself from the brief before reading the solution.
  2. Change the fee so the flow takes the Manager approval route.
  3. Add a third route for enrolments over 100,000.
  4. Add a Compose that produces a reference like PB-2026-PRIYA.
  5. List three things you would add before putting this flow in front of real students.