A novel tool utilizing machine learning techniques was designed to forecast ap index values for the next three consecutive days (24 values). The tool employs time series data from the 3 h ap index of solar cycles 23 and 24 to train the Long Short-Term Memory (LSTM) model, predicting ap index values for the next 72 h at three-hour intervals. During periods of quiet geomagnetic activity, the LSTM model’s performance is sufficient to yield favorable outcomes. Nevertheless, during geomagnetically disturbed conditions, such as geomagnetic storms of different levels, the model needs to be adapted in order to provide accurate ap index results. In particular, when coronal mass ejections occur, the ap Prediction tool is modulated by inserting predominant features of coronal mass ejections such as the date of the event, the estimated time of arrival and the linear speed. In the present work, this tool is described thoroughly; moreover, results for G2 and G3 geomagnetic storms are presented.