The Twelfth Doctor existed in the Shadow World as a virtual replica of the original Twelfth Doctor from the Doctor's World. Like the rest of the Shadow World, he was created by the Monks, so that they could plan the perfect invasion of Earth.
The Twelfth Doctor shared the history and personality of his non-virtual counterpart, only parting with that history shortly after the events aboard Chasm Forge, meaning he was also blind. He was a perfect duplicate and, like the rest of the people living within the Shadow World, he believed himself to be real.
After having read the Veritas, the Doctor discovered that he was merely a simulant in a virtual world. Realising the threat to Earth, and facing the imminent erasure of his world, the Doctor used his sonic sunglasses to email his physical counterpart.
He was in his lecture hall at St Luke's University when the Pope arrived. After some initial confusion caused by his partial blindness, even with the assistance of his sonic sunglasses, Nardole helped him understand the Pope wanted him to investigate the Veritas, a document that caused anyone who read it to kill themselves.
Travelling to Bill's house, the Doctor interrupted her date and brought her along, hiding the fact he was blind despite Nardole's concerns. When they arrived at the Haereticum, where the Veritas was kept, they found a priest had shot the lockout and read the text. The Doctor instructed Bill and Nardole to go find the priest, and used the time alone to borrow regeneration energy from his future with a device he had attached to his temples, briefly restoring his eyesight. However, before he could read the text, he was confronted by the Monks, forcing him to flee with a laptop instead.
Despite nearly being captured, he made it to the Oval Office, finding the President dead. He listened to the Veritas via the laptop and realised that he was part of a simulation created by aliens that wished to invade Earth. Bill arrived, but was deleted by the Monks shortly after the Doctor told her the truth. Before being deleted himself, the Doctor used the sonic sunglasses to send an email to his real world counterpart to warn him of the impending invasion, musing that he was doing what everyone did when the world was in danger: calling the Doctor. (TV: Extremis)