Affordances encode relationships between actions, objects and effects. They play an important role on basic cognitive capabilities such as prediction and planning. We address the problem of learning affordances through the interaction of a robot with the environment, a key step to understand the world properties and develop social skills. We present a general model for learning object affordances using Bayesian networks integrated within a general developmental architecture for social robots. Since learning is based on a probabilistic model, the approach is able to deal with uncertainty, redundancy and irrelevant information. We demonstrate successful learning in the real world by having an humanoid robot interacting with objects. We demonstrate the benefits of the acquired knowledge in imitation games.