Web-based collaborative systems, where most computation is performed by human collectives, have distinctly different requirements from traditional workflow orchestration systems, as humans have to be mobilised to perform computations and the system has to adapt to their collective behaviour at runtime. In this paper, we present a social orchestration system called SmartOrch, which has been designed specifically for collective adaptive systems in which human participation is at the core of the overall distributed computation. SmartOrch provides a flexible and customisable workflow composition framework that has multi-level optimisation capabilities. These features allow us to manage the uncertainty that collective adaptive systems need to deal with in a principled way.We demonstrate the benefits of SmartOrch with simulation experiments in a ridesharing domain. Our experiments show that SmartOrch is able to respond flexibly to variation in collective human behaviour, and to adapt to observed behaviour at different levels. This is accomplished by learning how to propose and route human-based tasks, how to allocate computational resources when managing these tasks, and how to adapt the overall interaction model of the platform based on past performance. By proposing novel, solid engineering principles for these kinds of systems, SmartOrch addresses shortcomings of previous work that mostly focused on application-specific, non-adaptive solutions.