I created an instant flow and set an input field to optional however anytime it was left blank I would get the following error:

InvalidTemplate. Unable to process template language expressions in action ‘Compose_3’ inputs at line ‘0’ and column ‘0’: ‘The template language expression ‘coalesce(triggerBody()[‘text_2′], null)’ cannot be evaluated because property ‘text_2’ doesn’t exist, available properties are ‘file, text, entity’. Please see https://aka.ms/logicexpressions for usage details.’.

I tried the following expressions and still got the above error:

@{coalesce(triggerBody()['text_2'], null)}
@{empty(triggerBody()['text_2'])}
@{if(equals(triggerBody()['text_2'],null), 'true', 'false')}
Turns out adding a ? before the property resolved the issue:
@{coalesce(triggerBody()?['text_2'], null)}
@{empty(triggerBody()?['text_2'])}
@{if(equals(triggerBody()?['text_2'],null), 'true', 'false')}
So this:
triggerBody()['text_2']
Became this:
triggerBody()?['text_2']
Reference: