WASHINGTON — North Korean leader Kim Jong Un heaped praise on President Donald Trump in a letter to the White House before a summit between the two leaders last month in Vietnam, while making clear he wished to negotiate only with the president and not his envoys, current and former U.S. officials told NBC News.

The letter appeared aimed at cutting out the U.S. envoy to North Korea, Stephen Beguin, and Secretary of State Mike Pompeo, in the discussions on the regime's nuclear and missile arsenal, while seeking to appeal to the president's ego, said one current and two former U.S. officials familiar with the matter, who spoke on condition of anonymity.

While Kim sought to curry favor with Trump before the Hanoi meeting, their second one-on-one summit, officials across the U.S. government as well as allied governments worked to prevent the president from giving up too much in the negotiations, the current and former officials said.

"A huge amount of energy was devoted to avoiding disaster," said one former U.S. official. "They were playing defense."

President Donald Trump and North Korea's leader Kim Jong Un walk in the garden at the Metropole hotel in Hanoi on Feb. 28, 2019. Leah Millis / Reuters file

Kim wanted the discussions "strictly at the Trump and KJU level," said a current U.S. official, referring to the North Korean leader.

"It was about flattery, that only the president could deliver peace," said the former U.S. official.

The regime appeared to believe it had a better chance of securing a favorable agreement in exclusively direct talks with the president than in a more traditional negotiation with Trump's deputies preceding a one-on-one meeting, former officials and a foreign diplomat said.

A spokesperson for the National Security Council declined to comment.

When asked about the letter and the pre-summit preparations, a State Department spokesperson said, "We don't comment on the details of our private diplomatic conversations."

Kim’s letter tapped into Trump’s own inclinations about how to conduct negotiations, with an emphasis on his personal role and his deal-making skills, as opposed to a more lengthy, detailed process carried out between the leaders’ deputies, current and former officials said.

The letter helped create the momentum for the Hanoi summit, as it came when diplomacy was somewhat dormant over the December holidays, regional analysts said.

But it echoed other signals that the North Korean regime sought to cut Pompeo and Beguin and the professionals out of the process. U.S. diplomats met with resistance when attempting to lay the groundwork for the Feb. 27-28 summit in Hanoi, which then ended abruptly without an agreement.

Former officials said working-level, detailed discussions establishing the summit agenda and the outlines of a potential agreement only began in earnest a week before the summit.

The administration has offered a different account, saying discussions began much earlier with talks between Beguin and his North Korean counterparts.

U.S. officials said Kim offered to dismantle the Yongbyon nuclear site in return for the end of the bulk of U.N. economic sanctions on the country. Trump said he rejected the offer, telling reporters: "Sometimes you have to walk, and this was just one of those times."

Trump has cited a series of letters from the North Korean leader as proof of his excellent relationship with Kim. In September, Trump said at a rally in West Virginia that after initial tensions earlier in his presidency, the two "fell in love."

"No, really, he wrote me beautiful letters, and they're great letters. We fell in love."

The Japanese government was involved in the effort to keep Trump from making concessions and remained deeply concerned about a potential damaging outcome in the run-up to the Hanoi talks. At the first summit between the two leaders last year in Singapore, Trump took allies and his own military commanders by surprise when he announced Washington would curtail military exercises on the Korean peninsula.

The pre-Hanoi briefings were largely about making sure the president understood what not to agree to in Hanoi, as opposed to focusing on a potential deal, the sources said.

"Ultimately Trump told Kim Jong Un no and walked away, which we see as a positive outcome," the current official said.

North Korean leader Kim Jong Un and U.S. President Donald Trump begin a historic summit at a hotel on Sentosa island in Singapore on June 12, 2018. Saul Loeb / AFP - Getty Images file

The Hanoi discussions were scheduled to conclude with a signing ceremony for an unspecified agreement, but the summit was cut short — even before Trump and Kim could sit down for a planned lunch. The White House announced there would be nothing to sign.

Former officials said North Korea's negotiating stance made it relatively easy for the United States to walk away from the talks, as it offered a vague proposal on its Yongbyon nuclear site in return for a major concession in the form of a relaxation of the bulk of international sanctions.

Both Pompeo and national security adviser John Bolton advised the president to reject the offer, former officials said.