Late Tuesday afternoon, as President Trump’s team readied for an evening of dramatic reveals and made-for-TV twists at his State of the Union address, they hit a momentary snafu.

Aides involved in the planning told the House sergeant at arms that they wanted to have a surprise guest enter the chamber in the middle of the president’s speech. He resisted, citing protocol and security concerns.

But the White House held firm: If the sergeant at arms wouldn’t open the door, then first lady Melania Trump would get up and do it herself, according to a Democratic aide and a senior White House official familiar with the planning who spoke on the condition of anonymity to discuss the preparations.

In the end, Trump got the reality-show moment he wanted. As he introduced Amy Williams — a military spouse from Fort Bragg, N.C., whose husband was serving on his forth deployment to the Middle East — and her two young children, he paused to build suspense for the big reveal.

“But, Amy, there is one more thing,” the president said. “Tonight, we have a very special surprise. I am thrilled to inform you that your husband is back from deployment. He is here with us tonight. And we couldn’t keep him waiting any longer.”

Williams’s hand flew to her mouth, as Sgt. 1st Class Townsend Williams’s shiny black dress boots appeared over her left shoulder as he made his way down into the House chamber for an emotional reunion with his family, which drew rare bipartisan applause during an evening with more division than unity.

The moment was one of several theatrical flourishes orchestrated by the president and his aides that brought a reality-TV or game-show feel to the usually staid annual address to Congress, thrilling Trump’s supporters and angering critics who said he was cheapening the event.

Trump invited Venezuelan opposition leader Juan Guaidó to be his guest, taking great pains to keep his attendance a secret until the last minute despite Guaidó’s clear interest in recent weeks for a public sign of support from Trump in the face of tensions at home.

Also on hand was a 100-year-old member of the Tuskegee Airmen, retired officer Charles McGee, who the president had recently promoted to brigadier general and who stood and proudly saluted when acknowledged. He was accompanied by his 13-year-old great-grandson, Iain Lanphier, whom Trump pointed out, noting his desire to one day join the newly formed Space Force.

Trump surprised Stephanie Davis, a single mother from Philadelphia, and her fourth-grade daughter, Janiyah Davis, with a scholarship that will allow her to attend the school of her choice. And he awarded the controversial conservative radio host Rush Limbaugh — who was just diagnosed with late-stage lung cancer — the Presidential Medal of Freedom, the nation’s highest civilian honor.

Cliff Sims, a former White House aide who wrote a book about his time in the Trump administration, said the president is “always cognizant of the backdrop,” exhorting aides, “I don’t just want to announce this. I want to do it in the Rose Garden.”

Trump’s decision to transform the usually rote, if prestigious, State of the Union address into a theatrical canvas, he added, is classic Trump, honed during his years as the host of NBC’s “The Apprentice.”

“During the campaign, people used the reality-TV experience he had as a pejorative to try to attack him, but in fact, very few things about the modern presidency are more important than the ability to communicate to the American people the way they consume information, and he’s the best reality-TV producer in American history,” Sims said. “He’s constantly thinking about . . . the way that it looks and the way it plays it out and the drama of the moment.”

The first lady’s office was also closely involved in the planning process, officially inviting the guests to sit in Melania Trump’s box and ensuring they were comfortable throughout the process.

Though presidents have long used their congressional addresses to highlight their accomplishments and spotlight everyday Americans, Trump took the practice to new levels, turning in a performance replete with stunts (in the view of his critics) and heartwarming vignettes (in the estimation of his supporters).

“Trump has certainly taken it further, and taken it into the reality-television age, by not just recognizing people in the audience, but by giving the Presidential Medal of Freedom to Rush Limbaugh right there, rather than having a separate ceremony,” said Ann Burnette, an associate professor of communication at Texas State University.

Indeed, Trump was determined to pepper his speech with emotional plumes, and asked aides to keep the details of the Venezuelan leader’s visit a secret. One senior administration official, who spoke on the condition of anonymity to discuss the preparations, said the president did not want to meet Guaidó in Florida over the weekend, partially to maintain the surprise and add to the drama of the moment.

Administration officials also asked the Venezuelans not to tell anyone that Guaidó would be attending the speech, according to the official.

Another beneficiary of Trump’s stagecraft was Janiyah Davis, the fourth-grader. She and her mother were invited to the House chamber to represent thousands of children on waiting lists for taxpayer-supported private school scholarships. For the second year in a row, Trump asked Congress for a federal tax break to encourage donations, an idea that went nowhere in 2019.

“Janiyah’s mom, Stephanie, is a single parent,” the president said. “She would do anything to give her daughter a better future.”

Then, Trump went a step further, offering help to Janiyah, who was stuck on the waiting list.

“Janiyah, I have some good news for you,” the president said. “I can proudly announce tonight that an Opportunity Scholarship has become available, it’s going to you, and you will soon be heading to the school of your choice.”

The Davises looked at each other and beamed, before Stephanie stood and enveloped Janiyah in a hug.

As it turns out, the scholarship had “become available” thanks to Trump’s own education secretary. On Wednesday, a spokeswoman for Education Secretary Betsy DeVos said that Janiyah’s tuition was being paid for by DeVos personally. DeVos, a billionaire, donates her government salary each year, and this year it will be going in part to pay for Janiyah’s entire private school tuition bill.

The whirlwind continued for the Davis duo Wednesday, as they hitched a ride aboard Air Force Two with DeVos and Vice President Pence back to Philadelphia, where Pence promoted the administration’s school choice agenda.

Perhaps one of the biggest reveals occurred when Townsend Williams, back from Afghanistan, materialized in the chamber to greet his family. Williams’s unit deployed last summer and was scheduled to return in the spring, but Williams had already planned to return home early to attend warrant officer school, though the exact timing was not known to his wife, said Army Lt. Col. Mike Burns, a spokesman for the 82nd Airborne Division.

Williams did not return specifically to take part in the State of the Union, Burns said.

Logistics to get him from Afghanistan to Capitol Hill proved challenging, according to an Army official who was not authorized to speak about the coordination. Handlers ensured communications with his wife were not disrupted to avoid suspicion or worry. And once in the Capitol, the White House coordinated her arrival, while military officials were careful to ensure he did not accidentally run into her before the speech.

Then there was the issue of his uniform. Since Williams did not go home, soldiers in the unit had to assemble a new service uniform with various patches and medals. His unit also ran into some challenges finding a pair of jump boots that would fit him, the official said.

Trump himself was the one who seemed to botch the surprise for Limbaugh when, during an off-the-record lunch with television anchors before his Tuesday address, Trump told the group that Limbaugh would be in the audience that evening and that he would be giving him the Medal of Freedom.

The news promptly leaked out, infuriating White House press secretary Stephanie Grisham — who chastised the anchors over email — and ruining the reveal.

But it was unclear when, exactly, Trump would award Limbaugh the highest civilian honor, and the president seized the opportunity to do it right there in the ornate House chamber.

“I will now ask the first lady of the United States to present you with the honor,” Trump said, as s seemingly overcome Limbaugh stood so Melania could pin the medal around his neck.

Later, speaking on camera to TMZ, Limbaugh still seemed astonished by the whole evening, saying, “I’m in a state of disbelief.”

And that’s exactly what Trump had intended.

When the television anchors had asked him earlier what else he had planned, the president — like any good showman — kept them in suspense.

“You’ll just have to watch,” Trump told the group.

Alex Horton, Laura Meckler and Paul Sonne contributed to this report.