Millions of users of Amazon's Echo speakers have grown accustomed to the soothing strains of Alexa, the human-sounding virtual assistant that can tell them the weather, order takeout and handle other basic tasks in response to a voice command.

So a customer was shocked last year when Alexa blurted out: "Kill your foster parents."

Alexa has also chatted with users about sex acts. She gave a discourse on dog defecation. And this summer, a hack Amazon traced back to China may have exposed some customers' data, according to five people familiar with the events.