Skip to main content

How to Use the triggerBody() Function in Power Automate

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

The values a flow starts with, such as what someone typed into a manually triggered flow, are in the trigger's body. triggerBody() returns that body, and adding a key picks one value from it. This guide reads a name typed into a flow's input.

Syntax​

General form
triggerBody()?['<key>']
  • triggerBody(): the trigger's body. Microsoft's functions reference describes it as: Return a trigger's body output at runtime. Shorthand for trigger().outputs.body.
  • ?['<key>']: one value from the body, by its key. The ? returns nothing instead of failing the flow when the key isn't there.
  • <key>: the value's name in the body, in single quotes. A manual trigger names its inputs by type, not by the label you give them: the first text input is text, the second text_1, then text_2, and so on.

The Example​

A flow, Use triggerBody, has two parts:

  1. Manually trigger a flow (How to Create an Instant Cloud Flow Inside a Solution in Power Automate) with one text input, Name.
  2. A Compose action, Name typed, that reads it with triggerBody()?['text'] (How to Use the Compose Action in Power Automate).

Step 1: Add a Text Input​

In the trigger, add a text input called Name, described as Who to greet (How to Add a Text Input to a Manually Triggered Flow in Power Automate):

The Manually trigger a flow trigger with one text input, Name, described as Who to greet

It's the trigger's first text input, so its key is text.

Step 2: Read It with triggerBody()​

Add a Compose action and rename it Name typed. In Inputs, add this expression (How to Add an Expression in Power Automate):

Name typed → Inputs
triggerBody()?['text']

The designer recognises the expression and shows it as the trigger's Name token, the same token dynamic content offers:

The Name typed Compose action with the trigger's Name token in Inputs

Step 3: Run the Flow​

Save the flow and test it manually (How to Test a Cloud Flow Manually in Power Automate). Type Ada in Name and run it. In the run, the trigger's Body has one field, text, with the value Ada:

The Body of the trigger in the run, a table with the field text and the value Ada

Name typed read it with triggerBody()?['text'], so its Inputs and Outputs are both Ada:

The run results of Name typed with Inputs Ada and Outputs Ada

Common Mistakes​

MistakeWhat happensDo this instead
Using the input's label as the key, ?['Name']The body has no Name key, so the result is emptyUse the key, such as text
Guessing the key of a second inputIt's text_1, not text2Look at the trigger's body in a run
Leaving out the ?A missing key fails the flow instead of returning nothingWrite ?['<key>']

Troubleshooting​

SymptomLikely causeFix
The result is emptyThe key doesn't match the inputRead the key from the trigger's body in a run
The value comes from another inputThe key belongs to another inputCheck which input has which key
Only part of the body is wantedtriggerBody() alone returns all of itAdd ?['<key>']

FAQ​

Is triggerBody() the same as the token in dynamic content?​

Yes. Here the expression and the Name token are the same thing: the designer showed the typed expression as that token.

Does triggerBody() work with other triggers?​

Yes, with triggers that start a flow with data. A SharePoint item trigger's body holds the item's columns, with the columns' internal names as the keys.

Where do I see all the keys?​

In a run, select the trigger and look at its Body: every key is a row in the table.

Conclusion​

triggerBody()?['<key>'] reads one of the values a flow started with. For a manual trigger the first text input's key is text, so triggerBody()?['text'] returned Ada, the name typed into the flow.

Additional Resources​