Director Joss Whedon revealed that he developed the idea for Avengers: Age of Ultron in just 45 minutes.

The recently published book, The Story of Marvel Studios: The Making of the Marvel Cinematic Universe, revealed how Whedon came up with the idea for the second Avengers film. The director had been sitting in a British pub when his agent texted him, "Do you want to direct Avengers 2?" After receiving the text, Whedon put pen to paper and wrote his ideas for the sequel in less than an hour.

RELATED: The Strange Reason Loki Was Not in Avengers: Age of Ultron

Whedon, who also directed 2012’s The Avengers, recalled the adrenaline rush of coming up with ideas for the plot. "I texted back saying, 'Let’s do this.' I couldn’t shut the ideas up. Reopened, they just flooded in," he added. However, Whedon also revealed that prior to the opportunity, he was initially skeptical of returning to direct the second installment in the Avengers series. "I thought I never wanted to do this again," he admitted. "Honestly. It was a very tough process."

The book also reveals that prior to that moment, during his first meeting with Marvel, the director had already come up with and pitched the idea for Jarvis to become Vision, played by Paul Bettany, and Ultron to be the villain of the following sequel after The Avengers. "If you do it, and you do a sequel, in the sequel, it has to be Ultron. And then he has to take Jarvis and make Vision. Because Paul Bettany has to play The Vision," Whedon added.

RELATED: MCU Theory: Thor's Age of Ultron Vision Foretold the Eternals' Movie Threat

Avengers: Age of Ultron saw a second team-up for Iron Man, Captain America, Thor, Black Widow, Hawkeye and Hulk as they battled to save Earth from Ultron, an artificial intelligence with the goal of human extinction. The movie also saw Elizabeth Olsen and Aaron Taylor-Johnson join the franchise as Wanda Maximoff/Scarlet Witch and Pietro Maximoff/Quicksilver.

While the film received generally positive reviews from critics, it is regarded among fans as the worst Avengers movie. That said, the film still holds a favorable review on Rotten Tomatoes, with a "Fresh" 76% critic rating and an 83% audience score. The movie also went on to become the fourth highest-grossing film worldwide of 2015.

KEEP READING: Age of Ultron's Avengers Vs. X2's X-Men: Which Marvel Team Is More Powerful?

Source: The Story of Marvel Studios: The Making of the Marvel Cinematic Universe