This work introduces CAmIE, an agent-based model for the bottom-up development of large-scale AmI environments. It offers tools to easily develop AmI applications and, while not visible to the users, it assures the interactions between these applications at runtime, enhancing them with a highly intelligent behavior. A series of distribution platforms as well as a collection of shared knowledge libraries are used, to motivate the human actors to contribute, leading, thus, to environments that integrate in the best possible way their collective intelligence.