I have seen a few requests about this error in the forum but no solution yet so I thought I'd post what I found.
My flow needs to use the replace function on an output from the trigger.
As an initial test I just put the output from the trigger directly into my output (create a row in a spreadsheet on SharePoint). This worked fine which says the flow is detecting data in that field.
Next, I used the expression editor to wrap the trigger output into the replace function. In the expression editor I typed
replace(
then used the Dynamic content chooser to find the trigger output, and entered my new and old texts. The result was
replace(triggerOutputs()?['body/2']?[' What activities.topics were covered during this session?'],'-','|')
This failed with the error in the error
'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.
In the Run History I checked the output of my trigger field, there was an output:
"2. What activities/topics were covered during this session?": "-Going Digital"
So, I noticed that the chooser had made an error in the field name, it had split it at the dot (.) character and converted the / character to a dot. So I manually edited my expression to:
replace(triggerOutputs()?['body/2. What activities/topics were covered during this session?'],'-','|')
Probably predictably that failed.
Then I just dropped my trigger field straight into my flow output field using the Dynamic content chooser and ran the flow. It ran successfully and dropped the unprocessed output into my spreadsheet. This again proved that the field is accessible and has a non null value.
Next, in an inspirational moment, I hovered over the field in my output, the one I had dropped in directly using the Content chooser and I noticed the reference to my trigger field was different - it has replaced the / character in the field name with ~1

So, my final step was to use that trigger reference directly in my replace statement thus:
replace(triggerOutputs()?['body/2. What activities~1topics were covered during this session?'],'-','|')
and Bingo! it worked !