“Brooklyn Nine-Nine” made its move from Fox to NBC this month, marking the sixth season Stephanie Beatriz is portraying the gruff but lovable Det. Rosa Diaz. It is her longest-running role, and it may just be the one most close to her, as she personally inspired Rosa’s coming out storyline on the show last season. But Beatriz is not a one-character wonder, also grabbing attention for her portrayal of Gloria’s sister on “Modern Family,” her vocal performances in the animated “Danger & Eggs” and “BoJack Horseman,” and starring in and exec producing indie feature “The Light of the Moon” in 2017.

What keeps “Brooklyn Nine-Nine” fresh for you, this far in and knowing Rosa inside and out?

What struck me when you just said that is “Oh no, I don’t!” This woman is someone who keeps so many secrets, and I think she’s one of those women that keeps secrets from herself, really. And what’s been exciting about the development of the character over the course of now six seasons is that the writers continue to surprise me — especially in the way that they’re able to find a really funny balance between who Rosa wants to be in the world and who Rosa surprises herself with who she is. I think a lot of women that are ambitious and driven and good at their jobs can often be surprised by their capacity for being good in other realms. … And the way they’ve developed Rosa’s love life is surprising to me because she’s finding that she kind of wants to be in love and that’s not necessarily something you might think about from such a loner character.

What is the biggest challenge Rosa will face on the sixth season of “Brooklyn Nine-Nine”?

It’s trying to maintain a sort of tough shell even though there’s a chink in the armor. She came out to her family and wasn’t fully accepted by them, and I think that’s really, really difficult, and she’s also taken the very vulnerable step of sharing that with her entire group of friends, and so that’s going to be further explored in the season, and I think it will be challenging for her because she’s not used to letting anybody in. Yet now, over the course of five seasons she’s grown to a place where now it’s valuable to let people in, but how she negotiates how to do it so she still feels true to herself is [challenging].

Executive producer Dan Goor has talked about how Rosa coming out was inspired by you. Is that a satisfying feeling to have so much influence, or is that added pressure to represent her a certain way?

I don’t feel pressure; I feel honored. I feel absolutely honored to bring that storyline to television and have people witness it who may be going through something similar in their own lives, whether it’s about being in the LGBT community or not — or just holding onto a secret you feel you can’t share with your family because you don’t feel supported. I feel honored and privileged to tell stories that are influenced by my own truths in this world, but that story wasn’t exactly how it unfolded with my family because I have yet to have a sit down conversation with my family. It’s not at that point where I feel like I could sit my parents down and say that to them, which was the most challenging part of that [coming out episode]. I was experiencing that reality, albeit in another person’s body, in the way another person would handle it and with certain comedic notes we had to hit, as well. That was excruciating but also really joyful.

You’re making your directorial debut this season with a topical #MeToo episode. What made this time, and this story, right for you to step behind the camera?

Well, first I’ve finally actually done over 100 episodes of television, where before I had really only done guest stars, and that was a huge part of it — logging these educational hours and watching our writers and everyone on our crew create. In the beginning I really didn’t know how long this show would last, so I was just doing everything I could to learn as much as I could in the chunk of time, and then it was two seasons and then it was three, and every time we got extended, an alarm went off in my brain that said, “OK buckle down and study even more. Watch, watch, watch what everyone is doing.” I finally wanted to ask, but I thought, “Is anyone going to trust me? I didn’t go to school for this.” I don’t have the background in this, but that doesn’t mean it’s not possible, so it was very scary to ask Dan Goor and our producers if I could take on an episode, but I finally felt brave enough and I asked and they granted it.

Did you specifically ask to helm the #MeToo episode?

It was really about timing. It was really about who was going to be available what week — because not only do you have to direct, but I still had to act in the show, and I had to prep the episode, and that takes time, too. We shoot Monday through Friday so I had to be available to prep in a week when I wasn’t heavily involved in the episode that was shooting. So because of scheduling it just sort of happened that that was the one that was going to be for me. … I know that to Dan it was really important that there was a woman at the helm for this storyline, and I’m still sort of flabbergasted that it was me, but I was ready.

What was most important to the approach of balancing the comedy of the format with the sensitive subject matter?

I approach my work, always, with as much honesty as I can get out of myself and the work and everyone in the room, and that’s something that I really learned from Andre Braugher from day one. TV’s such a machine and everyone just wants to get it done, get the shot and get out of there, and Andre is not of that school. He is of the school of, “What is this moment about? What is this truth we’re trying to tell?” Especially in comedy, we need to focus down into what the moment is supposed to be and how truthful we can make it, and that is what I wanted to do on-set that week. And particularly the scenes that were more emotional — there was a good chunk for Melissa Fumero that was painful because all of us have had an experience like that, that’s the core of #MeToo — literally every woman you know has had something s—y happen to her. So to create a safe environment for that actress to draw from her own experience and draw from her imagination and feel free and safe in a work environment to create that work, for someone who has mostly focused on comedy in the last few years, I was so excited to give that to another actress because that’s all that I would want.

How did the fact that you have had such a close working relationship for years aid in this?

Not only do we have a shorthand where I just have to say two words to her and she knows what I mean, but we trust each other implicitly, and I’m a huge fan of her work. I just think she has so much range and is lovely to watch, so I was so thrilled that whole week. It was one of the best weeks I think I’ve ever had working.

Going forward, how heavily do you want to incorporate producing and directing into the work you put out?

The only way any of this work happens is someone has to direct it, so in the words of one of my favorites, Mindy Kaling, why not me? I have a viewpoint; I have things to say; I have a very specific worldview. And in specificity, it is universal, and that’s why watching what got nominated and won at the Globes was thrilling [this year]. There are stories from groups that have traditionally been marginalized and set to the side, “No one cares about your story, no one cares about what you have to say.” But that’s not true, and we’re seeing it more and more. We’re seeing it at the box office and we’re seeing it in the work that’s becoming applauded for its artistry, and I want to be a part of that.