Cyber-Physical Systems constitute one of the core concepts in Industry 4.0 aiming at realizing production systems that combine the efforts of human workers, robots, and intelligent entities. This is particularly crucial in Human-Robot Collaboration manufacturing where a tight peer-to-peer interaction between humans and intelligent autonomous robots is necessary. The work proposes the integration of novel Artificial Intelligence technologies to enhance the flexibility and adaptability of collaborative robots. The integrated functionalities allow a collaborative robot to autonomously recognize the tasks a human worker performs, and accordingly adapt its behavior. The approach is deployed on a real HRC scenario showing the functioning of the developed cognitive capabilities and the increased flexibility of resulting collaborations.