Kaling, who said she devotes less than a minute to each Tweet — “You know the whole thing where if it takes a long time to write a poem, then you probably shouldn’t be writing poetry? With Tweets, if you’re sitting around for more than 45 seconds, it’s probably not the medium for you”— has 1.5 million followers. She has looked into learning who they are, demographically speaking, but she said: “Ultimately, it became too boring for me to figure out. I just thought 70 percent are probably those Spam sexbots or whatever. But I’ll take the Spam sexbots. That’s fine.”

More likely, many of Kaling’s followers are big fans of “The Office,” the irresistibly awkward NBC sitcom that is in its eighth season. In 2004, when the producer Greg Daniels was gearing up to adapt “The Office” from the BBC show of the same name — in mock-documentary style, both versions chronicle the lives of unglamorous employees of a paper company — he hired Kaling as a writer-performer, after reading a spec script she wrote. “She’s very original,” he said. “If anything feels phony or lazy or passé, she’ll pounce on it.”

When she joined the show, Kaling was 24, new to Los Angeles and the only woman on a writing staff of eight. As she recalls in her comic memoir, “Is Everyone Hanging Out Without Me? (And Other Concerns),” to be published by Crown Archetype this November, she rented a small apartment on Fairfax Avenue and Fountain Boulevard, which she did not know was the nexus of transvestite social life in West Hollywood. “I . . . enjoyed late-night interactions with strangely tall, flat-chested women named Felice or Vivica, who always wanted rides to the Valley. If my life at the time had been a sitcom, an inebriated tranny gurgling, ‘Heeeeey, giiiirrrrrl!’ would have been my ‘Norm!’ ”

In some ways, of course, Kaling’s life is a sitcom, or perhaps it’s more accurate to say a sitcom is her life. These days, “The Office” has 18 writers, four of whom are women, and Kaling — who still lives in West Hollywood but now, at 32, owns a four-bedroom house — has ascended to a position of power: in addition to continuing to write and act for the show, she is an executive producer and has also directed two episodes. She’s admired by her colleagues for tackling juicy emotional conflicts. “I always call her the best writer on our staff,” Daniels told me over the phone. “It’s probably completely the wrong thing to do.”

Photo

Credit
Justin Stephens for The New York Times

Many of the 22 episodes Kaling has written in the last seven years are fan favorites: “The Injury,” in which the doofus boss, Michael Scott, burns his foot on a George Foreman Grill while getting out of bed (“I like waking up to the smell of bacon,” he explains. “Sue me.”); “The Dundies” and “Michael’s Last Dundies,” about the employees’ much-loathed annual prize ceremony; and “Niagara,” in which the sweethearts Pam and Jim marry. Kaling co-wrote “Niagara” with Daniels, and they both received an Emmy nomination.

Kaling can be snarkily hilarious or unsentimentally poignant, often within the same episode and even the same moment. As a writer, she’s both fast and prolific. And though she’s the first to deglamorize her own creative process — she has mentioned on Twitter writing over French fries at the chain Johnny Rockets — it remains mysterious, even to those she works with closely.

“Your average writer, when they get really good, I know how they got it,” Daniels said. “I can see the steps. But I love how with Mindy, I don’t see how she does it.”

A succinct way to describe the cultural space that Kaling occupies is to say that she appears to be the No. 1 girl crush of the irreverent “celebrity, sex, fashion” Web site Jezebel. Or that she’s like Tina Fey’s cool little sister. Or perhaps, given her love of romantic comedies and the fact that last year she co-wrote a script for one titled “The Low Self-Esteem of Lizzie Gillespie,” she’s the next Nora Ephron.

Kaling would most likely find both the Fey and Ephron comparisons facile, irritated as she is by the media’s tendency to define funny women in relation to one another, as if they’re all competing in a game of musical chairs. A recent “E! Online” poll incensed Kaling by asking, on the hundredth anniversary of Lucille Ball’s birth, which of three red-haired young actresses is the next Ball.

“They’re saying that the essence of Lucille Ball was in the color of her hair,” Kaling said. “Was Conan O’Brien like, ‘I’m a redhead!’? Maybe this isn’t exactly the right person, but they would never think the Lucille Ball essence could have been transferred into a man like, like Sacha Baron Cohen. Or they’d never be like: ‘Who’s the next Peter Sellers? Is it Steve Carell? Or is it Danny McBride? Now, let’s pit them against each other and talk about both of their weaknesses, because there can only be one.’ ”

Immediately after delivering this mini-rant, Kaling added: “I hope I’m not waxing too political. I spend about 4 percent of my time thinking about this.”

Kaling freely acknowledges the central contradiction of her career thus far, which is that she is a smart, ambitious woman who has excelled in the still-macho arena of comedy at the same time that she’s most widely recognized for playing the part of a materialistic, ditzy customer-service rep named Kelly Kapoor. And Kaling is unabashed about sharing her alter ego’s frivolous interests.

Photo

Kaling, home as a child in Weston, Mass.Credit
Mindy Kaling

A few years ago, until she decided it was too time-consuming, she maintained a blog called Things I’ve Bought That I Love; archives can still be found at mindyephron.blogspot.com, a name Kaling chose because she was amused by the idea of her 20-something Indian-American self as a long-lost Ephron sister. Kaling studs her Tweets with references to shopping and celebrities, and when Beyoncé Knowles’s pregnancy became public on the day I interviewed Kaling, she received texts from five separate people making sure she’d heard the blessed news. In my conversation with Greg Daniels, no sooner had he finished praising Kaling’s talents as a writer than he was expressing admiration at her slyness in persuading the wardrobe department, over his objections, to give Kapoor hair extensions.

“I want it both ways,” Kaling told me as we sat at her dining-room table last month. Quoting Ricky Gervais, who co-created the original “Office” and played the role of the boss, named David Brent in the British version, Kaling said: “David Brent wants to run with the foxes and hunt with the hounds. And I definitely feel that way, too.”

In her book, Kaling tries to set the record straight about what she does and doesn’t share with Kapoor with separate lists of “Things Kelly would do that I would not” (fake a pregnancy for attention; write a letter of support to Jennifer Aniston) and “Things Kelly and I would both do” (go to goop.com every day; choreograph and star in a music video).

An error has occurred. Please try again later.

You are already subscribed to this email.

Reading Kaling’s Twitter feed, you might assume that she’s an actress about town in a way her alter ego would envy. She exchanges Tweets with the actresses Zooey Deschanel and Busy Philipps as well as with the D.J. Samantha Ronson, also known for being the former girlfriend of Lindsay Lohan — but Kaling claims that she dreads parties and decided a few years ago to attend only birthday parties because she remembers who does and doesn’t show up for hers.

Kaling also prides herself on being at least mildly prim. She is happy to divulge certain kinds of personal information — which medicine she prefers for urinary-tract infections, or her postcollege habit of eating raw salmon­ fillets from the supermarket (this “homemade ‘sashimi,’ ” she writes in “Is Everybody . . . ,” was “delicious and a fraction of the price it would be at a sushi restaurant, though not at all safe”). But she draws the line at revealing anything sexual. “There’s all these women writing as if they were orphans,” Kaling said of the recent crop of books by female comedians. “It’s just about getting out the most embarrassing, raunchy, incredibly intimate, hilarious, detailed story. It’s as though catharsis equals art.”

Kaling’s own book is raunch-free. For more than two years, she has been dating a Web analyst and improv actor named David Harris, but his only appearance in her memoir is in a photo of him asking her out by holding up tickets for a Harry Potter movie.

Kaling has limited time for a personal life. In order to create that pleasantly ridiculous half-hour of Thursday-night television that many of us consider a brief and relaxing interlude before bed, she routinely works 18-hour days.“Office” writers get started at 10 a.m. and leave at 7 p.m. at the earliest, though more frequently they’re on set until close to midnight. On days on which she’s playing Kapoor, Kaling must arrive by 6 a.m. to spend an hour in hair and makeup, then hurry between shooting scenes and cooking up new material in the writers’ room, an arrangement also navigated by the “Office” writer and executive producer B. J. Novak, who plays the character of Ryan, and Paul Lieberstein, an executive producer, who plays Toby. Kaling doesn’t mind the schedule, professing to have no hobbies other than dieting.

“I’d rather be in the writers’ room complaining about how overworked I am than in the Bahamas, where I’m like, What am I doing here? By Monday night of a long weekend, I’m getting stir-crazy.” By choice, she has never had the experience of going home before sundown. “Oftentimes, the show runner will be like: ‘Hey, we don’t need everybody to stay. Who wants to leave?’ I have never volunteered. What if this is the time when they make some great discovery or there’s this great line of jokes and I would have not been a part of that?”

Photo

In the “Office” Kaling, left, with Steve Carell.Credit
NBC

The daughter of an ob/gyn mother and an architect father who are both from India but met while working in Nigeria, Kaling was born in 1979, the same year her parents immigrated to the United States. Kaling’s sense of humor came partly from her mother, who she and her older brother Vijay each said is very funny and beloved by her patients. As Vijay put it, “She’s a professional gossip who does Pap smears.”

In junior high, Kaling began not just watching but — with “attentive nerdiness” — studying the sketch-comedy shows of the late ’80s and early ’90s: “The Kids in the Hall,” “In Living Color” and “Saturday Night Live.” “I could tell you who the line producer on ‘Saturday Night Live’ was when I was 12 years old,” she said.

Following her graduation from a prestigious prep school in Cambridge, Mass., where Kaling was a Latin whiz, she went to Dartmouth College to pursue, as she puts it in her book, “my love of white people and North Face parkas.” After college, Kaling moved in with two friends in Brooklyn, and worked as a baby sitter and then a production assistant for a cable-television psychic. She also started doing stand-up and shortened her original surname, Chokalingam, because club emcees would make bad jokes about its unpronounceability. She said her parents were not troubled by her decision, which “certainly isn’t to escape my Indianness or Hinduness,” she wrote in an e-mail. “I mean, you get that instantly.” For the third season of “The Office,” Kaling wrote an episode set at a celebration of Diwali, the Hindu festival of lights, in which Kelly Kapoor’s parents were played by Kaling’s real mother and father.

Just a year after college, Kaling and one roommate — Brenda Withers, with whom Kaling sang a cappella at Dartmouth — wrote a short play that became the surprise hit of the 2002 New York International Fringe Festival. Withers and Kaling, who are best friends, would, for their own entertainment, mockingly pretend to be the best friends Matt Damon and Ben Affleck; that pretending spawned “Matt & Ben,” the goofy play that reimagined how Damon and Affleck came to write the movie “Good Will Hunting.” (As Kaling and Withers tell it, the screenplay inexplicably fell from the ceiling of Affleck’s apartment.) Adding to the goofiness, Kaling played Affleck, and Withers, a willowy blonde, played Damon. Because they had no budget, they wore Withers’s brothers’ clothes as costumes. On the night that The New York Times’s Bruce Weber reviewed the play when it was restaged Off Broadway, Kaling accidentally broke Withers’s nose during what was supposed to be a choreographed punch. After a downpour of blood, the show went on, and Weber gave the play a rave. (Withers still works in theater — and appeared in the 2006 “Booze Cruise” episode of “The Office.” She and Kaling remain close.)

When Greg Daniels’s wife took him to see the play, he was struck by Kaling’s bizarre but impressive ability to persuade the audience that she was Ben Affleck. Just two months later, Daniels hired her to write for “The Office.” Today, Kaling’s “Office” contract includes a development deal with NBC to produce a new show for which she will also act and write. The tentative plan is for Kaling to play an ob/gyn, a role partly inspired by her mother.

It was just before noon on a Monday in August, and in the messy trailer that serves as one of two “Office” writers’ rooms, Kaling was running a meeting. She and five other people — three men around 40, one 30-something woman and a young female assistant — had gathered to work on a script for an introductory segment that the writers for “The Office” were asked to create for this year’s Emmys (last year, the team behind ABC’s “Modern Family” did something similar).

Kaling sat at the head of the table, typing on a keyboard; elevated above the table was a monitor, on which everyone could view the burgeoning script. There was much laughter as the writers riffed off one another, talking in the animated and overlapping shorthand of funny people who are accustomed to working together.

Kaling didn’t explicitly reject anyone else’s ideas, but her decision not to type in a particular line was visible to all. When coming up with dialogue for a character, she un-self-consciously spoke in the character’s voice: a precisely enunciated, vaguely Southern growl for Stanley, the middle-aged African-American sales rep; a high and girlish inflection for Erin, the sunny red-headed receptionist; and a stiff, slow cadence for portly Kevin in accounting.

As Kaling channeled these personalities, she mused aloud on various topics (Would Taylor Swift be willing to appear on the show? How do you spell “libidinously”?) Someone suggested a line in which Erin complimented a certain celebrity by calling her “alien pretty,” and Kaling laughed appreciatively as she typed it in. “I think that’s the one to beat,” she said.

Curtis Sittenfeld (curtissittenfeld@gmail.com) is the author of the novels "Prep" and "American Wife."

Editor: Ilena Silverman (i.silverman-MagGroup@nytimes.com)

A version of this article appears in print on September 25, 2011, on Page MM40 of the Sunday Magazine with the headline: 'I Want It Both Ways'. Today's Paper|Subscribe