An AI can detect emotions by learning from examples of facial expressions labeled as emotions like happy and sad. The AI learns the patterns between facial features and expressions to determine emotions. This type of AI is supervised learning, where the AI is provided examples with the correct answers to learn from.