How to parse a GPT response to output to a spreadsheet?

Let’s take a concrete example. My script asks GPT3.5 to look through out of office emails and say if the person is coming back or if he left the company and give new contacts if provided in email).

Currently I explicitly direct in my system prompt how GPT should format its answer (ex: "Separate such and such info with “|” "etc…)
With that technique, GPT outputs things like:
Out of office reply|OOO|John Doe|[my email]

I can then parse it with a script easily and output to excel. It’s pretty good but sometimes it messes up and doesn’t format correctly its answers.

I feel like perhaps there is a more full proof way to have GPT format its answers. Is there? Is that what function calling is for for example?

forced function calling has been the most stable way I’ve found to produce structured output.
so perhaps a function that takes an array of objects with a string name and something like an enum “vacation”|“left company”|“other” for the status or a bool “is_away_permanently” or so.
then you can just json decode the arguments that the model sends you and you can loop through the array and access each object and make an xl sheet


(or just a simple function with name and the enum if it’s looking at one person per request)