How can I make an player react to(Detect) AI punches

I did that and its working ok for now. But I still have one more question if you don’t mind. How can I detect whether the player is getting attacked from the front side or back side? So, I can play different reactions depending upon that. Or I should just make the player face the enemy if it is getting attacked?