I found these tutorials really helpful when I was starting with AI: https://www.youtube.com/playlist?list=PLbRBWFaQHaW9ZrXdkLVQSOkyUvUvdVlfO
He covers the basics about Behavior Trees first, and then goes ahead to show how you can create a basic AI system from scratch using the same. If I remember correctly, what you’re looking for should be in part 5: memory.