Traditionally, port terminals implement Truck Appointment System to control expected arrivals of trucks in port terminals. However, the occurrence of disruptions during transport causes unexpected circumstances, generating congestion and unbalanced arrivals at port hinterland. The use of smart technologies, in the context of Industry 4.0, is capable of collecting real-time geolocation and improve the visibility in the port logistics system, offering the opportunity to design a flexible TAS allowing dynamic rescheduling of truck appointments. In this sense, a new method combining a Machine Learning algorithm with discrete event simulation to predict truck conditions during the transport, and dynamically reschedule appointments of trucks classified as early and late trucks using real-time data acquired by smart technologies is proposed in this paper. The approach was evaluated in a Brazilian port terminal, and we use the average and the maximum waiting time of trucks in queue at the entrance gate, the average and the maximum number of trucks in queue at the entrance gate, and the percentage of trucks attended off-schedule as Key Performance Indicators. The Machine Learning accuracy was identified as 95.37% and the flexible method achieved a 90.4% improvement in the waiting time of trucks at port hinterland and a reduction of queue sizes compared to the current scenario, by the synchronization of arrivals in balanced time windows. Furthermore, this research contributes to increase the visibility in port logistics systems and reduce the vulnerability of port terminals.