The adoption of a digital twin for a smart factory offers several advantages, such as improved production and reduced costs, and energy consumption. Due to the growing demands of the market, factories have adopted the reconfigurable manufacturing paradigm, wherein the structure of the factory is constantly changing. This situation presents a unique challenge to traditional modeling and simulation approaches. To deal with this scenario, we propose a generic data-driven framework for automated construction of digital twins for smart factories. The novel aspects of our proposed framework include a pure data-driven approach incorporating machine learning and process mining techniques, and continuous model improvement and validation.