Photo: FOX

On December 4, 2013, I was sitting around a conference table on the Fox lot getting notes on the table draft of New Girl episode 315 — an episode that we had been working on almost nonstop for a month, an episode that would star, unbelievably, Prince. Someone handed me some dumplings — at least I think they were dumplings; listen, in all honesty, they may have been some kind of Asian-fusion buns. I picked one up, took a bite, and then saw my phone ringing with a number I didn’t recognize, from Minnesota. I answered it, mid-dumpling.

“Hew-wo?”

“Hello, I have Prince for you.”

I stood up suddenly, like a guest at a wedding seeing the bride appear. I banged my knee. I dropped the dumpling. I made insane gestures to the people around me. I ran outside. “Hello, this is Prince.”

His voice was … I don’t need to tell you what his voice was like. Soft. Strong. A whisper that sounded like it was booming out over a loudspeaker. He spoke, and the street I was standing on opened up. It’s possible I was having a full-on panic attack. I don’t know what I said. I talked just to talk, like some sweet kid in a war movie who was about to get blown up on the battlefield (“I can’t feel my legs, Sarge, am I okay? Tell Ma I love her.”). I said things like “it’s an honor” and “huge fan” because it seemed like the kind of thing I was supposed to say. But I knew, all the way in Minnesota, Prince could tell he was speaking to a person who had, moments ago, spit a dumpling out of her mouth.

The truth is, I had no idea why Prince had agreed to guest-star on New Girl. I was told he loved the show, that it was one of the few shows he watched. How could that be true? We weren’t cool enough for Prince — we did an entire episode about someone leaving a wet towel in the bathroom. A very real part of me felt that this was a prank some mean girls from middle school had spent 15 years concocting. I had also been told that Prince was known to back out of things at the last moment if he was unhappy. My interactions until this call had been with a manager, though I could sometimes tell what was coming directly from Prince in forwarded emails because of the way he spelled words: Letters were mostly capitalized. Numbers replaced letters whenever possible. 2Day. 2Morrow. An email from Prince was like a message that had been beamed down from a party in space by a robot whose job it was to communicate during all space parties.

We had originally approached Prince in season two for a cameo in an episode called “Virgins.” He said no. Obviously, in hindsight: The episode was too racy. But we were told he would be interested in coming back to do something else another time. I thought that was just the polite bullshit of the casting world. (An actor didn’t hate the script; she just “did not respond to the material.”) So when his manager reached out at the beginning of season three to ask if we were still interested in having Prince on the show, I was shocked. Yes. Yes, yes, yes.

That year, Fox had asked us to air an episode after the Super Bowl. It had to be the one. It had to be Prince. I met his manager and pitched the idea: The characters were going to end up at a party at Prince’s house, and with Prince’s help Nick and Jess would finally say “I love you” to each other. It was a big moment for our show. Prince liked the idea that he would be the one to get Jess to tell Nick how she felt about him. He referenced Silver Streak and Hitch. Two of our writers, Rob Rosell and Dave Feeney, wrote a very funny, wonderful script, and he signed on. He told us he wanted the party on the show to be as close as possible to what parties at his house were really like. I couldn’t believe this was happening.

So now, finally, I was actually speaking to him on the phone. When I paused long enough to take a breath, he started talking. He wasn’t happy. The script had changed from the script he had read. He apologized but said he was going to have to back out.

The street I was standing on opened up again. We were scheduled to start shooting in four days. We had booked the house for the party, the sets were being built, it was going to be the most expensive episode we had ever done, and I think I’d been awake for 20 of the last 24 hours. I knew exactly what had happened: The network had asked us to end the episode at the loft, the home base of the show, instead of at Prince’s house, and I had changed the story to have Nick and Jess say “I love you” back in their bathroom, away from Prince and his influence. It was a dumb call — the kind of call that you convince yourself is right in the echo chamber of the writers room, after multiple rounds of notes and very little sleep.

At that moment, talking to Prince, it was obvious: He had to be the catalyst of Jess’s emotional breakthrough. That was the reason for the episode. That was the good stuff, and I had taken that away. I can’t tell you exactly what I said, but I must have sounded desperate. “Can you give me until the end of the day? I’ll revise the script and send it to you.” There was a pause. “Okay. The end of the day.” It was probably 3 p.m. I started running. I’m not just saying that. I was sprinting across the lot. I didn’t stop until there was a computer in my hands. By 9 p.m., he was back in. I still don’t know why he gave me another chance.

Right before we were about to shoot him performing his new song in the episode, as he toured the set in his black shoes that lit up with a pink light when he walked, he asked my producer Erin O’Malley for a megaphone. People were called. A megaphone was found. Later, when the cameras were rolling, I stood in the back of the set and watched the song start. Right before the first notes, he pulled out the megaphone and called out: “Does anyone want to fall in love tonight?” Everyone cheered. We hadn’t asked them to. It was just a feeling. You just had to shout out. The megaphone made the song suddenly feel like a movement, like a political rally, like we were all standing there together that night in support of falling in love. It was brilliant.

We shot nights for a week in this enormous house an hour outside of Los Angeles, which meant working from 5 p.m. to 7 a.m., when everything starts to feel like a dream. I was incredibly shy around him, convinced that I would say the wrong thing and make him leave. But once I got over the initial terror of speaking to him, I realized we were just two people who were both obsessed with making the episode good. He wanted to choose the name of the non-speaking chef character, the chef’s wardrobe, the paintings on the walls, the linens in the bedroom set, his wardrobe, Zooey’s wardrobe, the music, the pancakes, the hairstyles … he had a piece of art, a poem written out in the shape of an egg, flown from Minnesota to hang on the wall of the set. His vision of the episode was all-encompassing, but I never felt overpowered. He always asked what I thought. It was like he was asking me to rise up to meet him.

At 3 a.m., in the middle of the week, I was holding on to a cup of coffee for dear life when someone elbowed me. “Hey, I think Prince wants you.” I looked up. Prince was standing on the balcony, beckoning to me. I put the coffee down and prepared for the worst. I must have done something wrong. It was all over. I walked up the stairs and followed him into a bathroom. He turned out the lights. For a moment, I was standing in a small, dark bathroom alone with Prince. Then he flicked a lighter on underneath his chin.

“Isn’t this funnier?”

I realized he was acting out the scene we were about to shoot. As scripted, Zooey was in a dark closet, and Prince surprises her by turning on a flashlight under his chin. Prince thought a lighter would be funnier. It was, and it would be beautiful on-camera. I started laughing. He smiled. I tried to stay cool. “Yeah, that’s funnier. Let’s do that.” As if there were ever a world where doing exactly what was inside Prince’s head wasn’t one of the greatest privileges of my life. We were still standing in the dark with only a lighter between us. I think he kept the light on for my benefit, because nothing could have ever stopped Prince from being able to see in the dark. He made his own light.

I didn’t know Prince personally. Ultimately, I only worked with him for a couple of weeks in December three years ago. But I will remember that time for the rest of my life, not because of his celebrity — I mean, a little bit because of that, sure — but because I got to observe the way he worked. I got to observe the rigor and the care that he put into every detail, every word, every moment. We’ve all seen The Voice or American Idol — we’ve all bought into the myth, at some level, that a great voice and a little bit of luck can make someone a pop star. After a week with Prince, I realized how ridiculous that is. He was an artist down to the bone. It’s not enough to have extraordinary vision; you have to know how to turn that vision into something that exists in the very flawed, complicated world of human beings and money and phone calls. To do that is an endless battle, especially if what you see in your head is unimaginable to other people. Obviously he could see things and hear things that no one else could, but what amazed me was his ability to defend and cultivate that vision until it became real in everyone else’s heads, until we could all see it too.

During my worst moments as a writer, I have the feeling of “flying blind.” These are the times when I feel I’ve lost the sense of what I want, when my internal compass is spinning, when I close my eyes and I have no vision. It was clear, in those few weeks that we made something together, that Prince rarely, if ever, lost his vision. That wasn’t because he was a magical, otherworldly being; it was because he was rigorous, and generous, and he knew how to fight for what he wanted. It was a beautiful, constant fight. It was love.

Fox will be rebroadcasting the episode of New Girl featuring Prince tonight, April 26, at 9:30 EST. If you want to watch any other day or time, there’s always Netflix.

Now Watch: 7 Things You Didn’t Know About Prince

*A version of this article appears in the May 2, 2016 issue of New York Magazine.