In this paper, a gas-electricity-heat integrated energy system with smart buildings is described. The special focus is flexible energy demand including electricity and heat integrated into the smart buildings, where customers have multiple options to satisfy their energy demand. Considering energy prices in the market, the aggregator is introduced to manage these smart buildings in the most economical way. This paper proposes a bi-level programming approach for the integration of flexible demand in the combined smart energy system (CoSES). The integrated system operator (ISO) aims at maximizing social welfare according to the operation strategy of the aggregator, which minimizes the energy purchase cost of downstream demand. Then, the linearization method and Karush-Kuhn-Tucker (KKT) conditions are used to transform the bi-level optimization problem into an easily handled singlelevel problem. The proposed approach is illustrated in a modified test system.