When two men opened fire at the “Draw Muhammad” contest in a Dallas suburb in 2015, the FBI had an undercover agent on the scene, newly filed court documents reveal.

On May 3, 2015, two men from Arizona armed with assault rifles — Elton Simpson and his roommate, Nadir Soofi — attacked a convention center in Garland, Texas, where Pamela Geller had organized the “First Annual Muhammad Art Exhibit and Contest.” The two attackers shot a guard outside the convention center and were then killed in the parking lot by Texas police.

Hours earlier, the FBI had sent a bulletin to local police with Simpson’s photo, warning that he was “interested in the event.” FBI Director James Comey said in a press conference following the shooting that the FBI did not have reason to believe Simpson was planning to attack the event, even though the bureau had spent years trying to build a case against him.

The new information came to light in an indictment filed Wednesday against Erick Jamal Hendricks, 35, of Charlotte, North Carolina, who allegedly recruited people online to join the Islamic State. An affidavit in the case reveals that an FBI undercover agent was at the “Draw Muhammad” event and was communicating with Hendricks about security there. The affidavit raises questions about whether the FBI knew, or should have known, that the event was a likely target of attack.

It’s unclear, in the affidavit, whether the communication between Hendricks and the undercover agent was via text or through another messaging system.

“If you see that pig [Geller] make your ‘voice’ heard against her,” Hendricks wrote to the undercover agent.

Hendricks then asked the agent a series of questions to gauge security at the event.

“How big is the gathering?”

“How many ppl?”

“How many/police agents?”

“Do u see feds there?”

It’s unclear from the affidavit what information the FBI agent provided in response. It’s also unclear whether any of the information the agent provided to Hendricks was, in turn, passed on to the men who attacked the drawing event.

But the affidavit states that the FBI was aware that Hendricks and Simpson were in contact to some degree. In fact, according to the document, Hendricks had made an online introduction between Simpson and the undercover agent and was the nexus between them. As a result of that introduction, Simpson and the undercover agent corresponded online. After Simpson posted a link to the “Draw Muhammad” event, the undercover agent wrote: “Tear Up Texas.”

Simpson appears to have suggested violence.

“Bro, u don’t have to say that … U know what happened in Paris … I think … Yes or no?” he wrote, referring to the January 7, 2015, attack on Charlie Hebdo.

“Right,” the agent responded.

“So that goes without saying,” Simpson responded.

After the Garland shooting, Hendricks posted a statement online in which he referenced the shooters as “a new Muslim of 2 years and another of 11 years.”

Simpson had told the undercover agent he’d been a Muslim for 11 years. The agent’s cover was that he’d been a Muslim for two years. Simpson’s actual accomplice, Nadir Soofi, was born a Muslim. In the affidavit, the FBI admits that Hendricks, not knowing about Soofi, had assumed the undercover agent was the second shooter.

The undercover agent got back in touch with Hendricks after the shooting and said he watched as police shot Simpson and Soofi.

“Keep in touch with me,” Hendricks told the agent. “If you need a safe house, let me know. This is why I’m here.”

Less than two weeks later, Hendricks cut off contact with the undercover agent. It took the FBI another 15 months to arrest Hendricks, and the affidavit does not disclose what was happening during that time period.