How to store Assistant output into structured database?

Hi!

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.

Instructions:
“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?

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

Response I get is:
" {
“role”:
“user”
“content”:[
0:{
“type”: “text”
“text”: “My name is John”
}
]
}"