Stationary fuel cells provide potential opportunities for energy savings when integrated with buildings. Through smart dispatch of both electrical power and heat generated by the fuel cells and managing the building loads, the buildings can achieve more efficient operation. In this paper, we develop an optimal energy dispatch controller to operate a fuel cell-integrated building. The controller leverages the inherent thermal storage and the dispatchable fuel cell to reduce its operating cost and to allow the building to participate in grid services. The proposed controller is implemented on two types of commercial buildings, a large office building and a large hotel, and the effectiveness of the controller is demonstrated through simulations. The results also indicate that the potential saving varies significantly with different system parameters, including season, fuel prices, and equipment sizing, which provide helpful insights for building operators and other stake holders.