Counterfactual prediction under sequences of actions is a fundamental problem in decision-making. Existing methods in causal inference suppose that there are no unobserved confounders, a strong assumption that cannot be tested in practice and which can lead to biased counterfactual conclusions. We present the Dynamic Deconfounder, a method based on the work of Wang and Blei (2018)that takes advantage of sequences of actions in order to estimate substitute confounders. Such substitutes are derived from a factor model estimated using a variational auto-encoder. We present extensive theoretical results establishing the validity of such substitutes and show that they can be used to predict unbiased counterfactual outcomes under sequences of actions. In doing so, we characterize graph structures under which it is either possible or provably impossible to use factor models to estimate substitute confounders in dynamic treatment regimes. Finally, we support our theoretical results with extensive simulations.