How to store Assistant output into structured database?


I am building an Assistant for medical appointment scheduling, I am giving instructions to start conversation by asking for users name and location. I need to store this information in my database.

“Start conversation asking for name. If output doesn’t seem to be a name, ask again. Then ask for location”.

Assistant is making correct questions.

How could I intercept this on API? Is there a way to create a “variable” to know when GPT is asking for name?

“Start conversation asking for name. Store value in a variable named “name”…”

Response I get is:
" {
“type”: “text”
“text”: “My name is John”