How to save responses from chatGPT to variables?

Hello. I’m trying to write code based on what I learned from a chatbot lecture. Chatbot is good at extracting and printing keywords from the input string provided by the user. However, I’m having trouble saving the keyword to a variable so that I can use it globally. Is there a way to instruct the code to find the keyword from the user input and store it in a variable for global use?

*GPT models are stateless.
You can save the state at your end and use it for future interactions.

If this explanation doesn’t help, please share link to the exact lecture / notebook & cell.

I took a chatbot lecture and wrote this question.
What I want to implement is to ask the customer about their interests and extract the keywords from that sentence. After that, it fetches the data it has and recommends it from an item or list related to the keyword. During the conversation, it is necessary to store keywords in variables and search the data based on them.
If I understand “save the state at your end and use it for future interactions” well, can it be implemented by making 2 prompts, receiving keywords, stopping them, and providing what you find in the data in the next prompt?

Getting keywords from the user can be done via something as simple as using the input function and performing initial filtering of content. (You can get as involved as you’d like on this topic itself.)

Use the filtered content as context to the AI prompt to get the final response.