This paper proposes an optimization framework for retailers that are involved in demand response (DR) programs. In a first phase responsive users optimize their own household consumption, characterizing not only their appliances and equipment but also their comfort preferences. Then, the retailer exploits in a second phase this preliminary non-coordinated solution to implement a strategy for the aggregated loads. This strategy is formulated as a bilevel problem in which the retailer costs are minimized in the upper level assuring that the aggregated residential users do not incur any economic or comfort losses by participating in the DR program. The retailer requests are considered by each user in the lower level in order to optimize its consumption under its particular non-financial loss criterion. The resulting problem is cast as a mixed-integer non linear bilevel problem with lower-level binary variables. A mixed-integer linear single-level reformulation is presented and an exact solution technique based on Dantzig-Wolfe decomposition is proposed. Simulations with up to 10000 residential users illustrate the advantages of the proposed two-phase framework in terms of privacy, effectiveness and scalability.