Introduction The conventional tACS approach involves defining the frequency and phase of stimulation ad hoc and testing them on a cohort of subjects. However, this approach exhibits two limitations: (1) the brain networks targeted by the stimulation cannot be verified without simultaneous functional magnetic resonance imaging (fMRI); (2) those stimulation parameters may vary across subjects due to difference in anatomy or heterogeneity in disease. Yet, there is a combinatorial explosion in the biologically plausible range of stimulation frequencies and phases, resulting in thousands of possibilities. Identifying the optimal stimulation protocol for a given individual is like ‘finding a needle in a haystack’. Therefore, using conventional methodology makes tailoring tACS to an individual highly unfeasible. Methods To address this fundamental challenge, we combine tACS with an innovative framework that utilizes real-time fMRI and machine-learning: The Automatic Neuroscientist (Lorenz, 2016). The framework starts with a target brain state and finds a set of tACS parameters (frequency and phase of stimulation) that maximally activates it. This is done in a closed-loop fashion (Fig. 1), i.e. real-time fMRI provides instantaneous information on how effective certain stimulation parameters are. Based on this, the Bayesian optimization approach proposes the combination of tACS parameters that will be applied in the next iteration. This cycle continues until the Automatic Neuroscientist identifies the sweet spot within the exhaustive parameter space (Fig. 2) that maximally activates the target brain state. Results We could demonstrate the technical feasibility of novel neurotechnology that combines real-time fMRI, machine-learning and tACS in a fully automated manner. Moreover, we showed that our closed-loop framework is far more efficient that the standard approach. Conclusion We envision that our framework will advance personalized treatment by means of non-invasive brain stimulation. This will be of particular importance for neurological and psychiatric deficits that are diffuse and widely heterogeneous in their origin.