Redmond, WASH. - A meeting of Microsoft Cortana’s writing team – which includes a poet, a novelist, a playwright, and a former tv writer. Leading the meeting is Deborah Harrison, Senior Content Developer, who talks with Chris O’Connor, also a Senior Content Developer, to her left. Across the table is August Niehaus, a writer for the team (Photo by Stuart Isett for The Washington Post)

SAN FRANCISCO -- Until recently, Robyn Ewing was a writer in Hollywood, developing TV scripts and pitching pilots to film studios.

Now she’s applying her creative talents toward building the personality of a different type of character — a virtual assistant, animated by artifical intelligence, that interacts with sick patients.

Ewing works with engineers on the software program, called Sophie, which can be downloaded to a smartphone. The virtual nurse gently reminds users to check their medication, asks them how they are feeling or if they are in pain, and then sends the data to a real doctor.

As tech behemoths and a wave of start-ups double down on virtual assistants that can chat with human beings, writing for AI is becoming a hot job in Silicon Valley. Behind Apple’s Siri, Amazon’s Alexa and Microsoft’s Cortana are not just software engineers. Increasingly, there are poets, comedians, fiction writers, and other artistic types charged with engineering the personalities for a fast-growing crop of artificial intelligence tools.

“Maybe this will help pay back all the student loans,” joked Ewing, who has master’s degrees from the Iowa Writer’s Workshop and film school.

Unlike the fictional characters that Ewing developed in Hollywood, who are put through adventures, personal trials and plot twists, most virtual assistants today are designed to perform largely prosaic tasks, such as reading through email, sending meetings reminders or turning off the lights as you shout across the room.

But a new crop of virtual assistant start-ups, whose products will soon flood the market, have in mind more ambitious bots that can interact seamlessly with human beings.

Because this wave of technology is distinguished by the ability to chat, writers for AI must focus on making the conversation feel natural. Designers for Amazon’s Alexa have built humanizing “hmms” and “ums” into her responses to questions. Apple’s Siri assistant is known for her wry jokes, as well as her ability to beatbox upon request.

As in fiction, the AI writers for virtual assistants dream up a life story for their bots. Writers for medical and productivity apps make character decisions such as whether bots should be workaholics, eager beavers or self-effacing. “You have to develop an entire backstory — even if you never use it,” Ewing said.

Even mundane tasks demand creative effort, as writers try to build personality quirks into the most rote activities. At the start-up x.ai, a Harvard theater graduate is tasked with deciding whether its scheduling bots, Amy and Andrew, should use emojis or address people by first names. “We don’t want people saying, ‘Your assistant is too casual — or too much,’ ” said Anna Kelsey, whose title is AI interaction designer. “We don’t want her to be one of those crazy people who uses 15 million exclamation points.”

Virtual assistant start-ups garnered at least $35 million in investment over the past year, according to CBInsights and Washington Post research (This figure doesn’t count the many millions spent by tech giants Google, Amazon, Apple, Facebook, and Microsoft).

The surge of investor interest in virtual assistants that can converse has been fueled in part by the popularity of messaging apps, such as WeChat, WhatsApp, and Facebook’s Messenger, which are among the most widely downloaded smartphone applications. Investors see that users are increasingly drawn to conversational platforms, and hope to build additional features into them.

Virtual assistants have also received a boost from major advances in subsets of artificial intelligence known as machine learning and natural language processing, or the ability for computers to understand speech. Accuracy of word recognition reached something of a tipping point in recent years, going from 80 percent in 2009 to 95 percent in 2014, said Christopher Manning, a Stanford computer science professor and natural language expert.

The rise of this technology is evident in a wave of new jobs at the intersection of human and artificial intelligence. By 2025, 12.7 million new U.S. jobs will involve building robots or automation software; by 2019, more than one-third of the workforce will work side by side with such technologies, according to Forrester Data.

Some virtual assistants are already becoming useful companions in the office. Howdy, a bot in the popular productivity software Slack, can query employees on behalf of a boss and collate their answers into a single document. Amy and Andrew, the meeting-scheduling bots built by x.ai, can email back and forth with real administrative assistants.

Sophie and Molly, nurse avatars built by the start-ups IDAvatars and Sense.ly, respectively, question patients about their medical conditions and try to cheer them up. Another start-up, Botanic.io, is building a guru avatar that can coach users in meditation and weight loss.

In most cases, users could go online and get the information themselves, without the help of a virtual assistant, though it might take a bit longer, Ewing said. “So if the character doesn’t delight you, then what is the point?”

At a recent meeting of Microsoft Cortana’s six-person writing team — which includes a poet, a novelist, a playwright and a former TV writer — the group debated how to answer political questions.

August Niehaus gestures to fellow members of the Cortana writing team, Deborah Harrison and Jon Douglas (Photo by Stuart Isett for The Washington Post)

To field increasingly common questions about whether Cortana is a fan of Hillary Clinton’s, for instance, or Donald Trump’s, the team dug into the backstory to find an answer that felt “authentic.” The response they developed reflects Cortana’s standing as a “citizen of the Internet,” aware of both good and bad information about the candidates, said Deborah Harrison, senior writer for Cortana, and a movie review blogger on the side. So Cortana says that all politicians are heroes and villains. She declines to say she favors a specific candidate.

The group, which meets every morning at Microsoft’s offices in Redmond, Wash., also brainstorms Cortana’s responses to new issues. Some members who are shaping Cortana’s personality for European and Canadian markets dial in. (Cortana is available in Spanish, Portuguese, French, Japanese, Italian, German, limited Chinese, and British and Indian English.)

When the team was preparing to launch a feature that has Cortana sifting through emails and suggesting people to meet with, members debated whether a reminder — “You said you wanted to meet with” so-and-so — sounded pushy. They considered whether “Star Wars” jokes were appropriate or too cultish. And they talked about how to shut down vulgar comments and respond to a tendency, among some users, to goad Cortana into repeating sexual comments.

Across the Microsoft campus, a different group apparently didn’t heed that lesson: Tay, a chat bot Microsoft recently released on Twitter, was terminated within a week after it started talking like a Nazi. The bot was parroting comments made on the Internet.

“We will do everything possible to limit technical exploits but also know we cannot fully predict all possible human interactive misuses without learning from mistakes,” Microsoft said on its blog after it took Tay down.

Such incidents reflect a fundamental challenge in building AI: Negotiating the virtual assistant’s relationship to human beings. Writers and designers said the trickiest question they wrestle with is how human can — and should — the bot sound? Should the virtual assistant be purely functional or should it aspire to connect emotionally with the user?

Human beings have higher expectations of software that is personalized than they do of automation software that can perform similar tasks, said Mark Stephen Meadows, founder and president of San Francisco-based Botanic.io. When software can talk and is personified, it opens up a Pandora’s box of human behavior. People don’t go out of their way to trick or use vulgarities with other types of software, he pointed out.

Moreover, studies of human-robot interaction have described a phenomenon known as the “uncanny valley,” in which attempts to make robots seems humanlike can inspire unease or revulsion instead of empathy.

For that reason, many developers of artificial intelligence make a point of adding a weird element to their avatar designs — such as an asymetrical face or an odd joke — something that signals that the virtual assistant isn’t human and doesn’t aspire to be, Meadows said. At the same time, the imperfections are meant to be endearing. A robot without such flaws could seem cold and alienating.

If you ask Cortana if she is human, she says no, and then she adds a meant-to-be endearing joke: “But I have the deepest respect for humans. You invented calculus — and milkshakes.”

Not aspiring to be human — and having a sense of humor about it — are attributes that can have the added benefit of making users more forgiving of a virtual assistant’s limitations and mistakes, said Cathy Pearl, director of user experience at Sense.ly. And as anyone who has used a virtual assistant knows, they make a lot of them. The technology is still young, and its capacity to handle situations is restricted by the limited information it has been exposed to. Artfully conveying that a bot recognizes that it doesn’t know something is one of the most challenging aspects of writing for AI, she said.

Another difficult question concerns gender. While Cortana is “crystal clear” that she is not human, the team gave her a female voice because early users expressed a preference for a female virtual assistant, Harrison said. Siri and Google Now also have female voices by default, though you can configure them to be male. Amazon’s Alexa can only be female (the company’s chief executive, Jeffrey P. Bezos, owns The Washington Post), while IBM’s Watson has a male voice.

Nonetheless, Cortana’s developers were concerned enough about playing into female stereotypes that they attempted to avoid them. The design, for instance, limits the number of times she apologizes and eschews self-deprecating remarks.

And despite the voice, the team insists that Cortana isn’t a woman. “She knows that gender is a biological construct, and since she’s not biological, she has no gender,” Harrison said. “She’s proud of her AI-ness.”