AN AMAZON customer was shocked when they received a message from Alexa telling them to "kill your foster parents".

The stunned user left a harsh review on Amazon's website, describing the episode as a "whole new level of creepy".

Alexa, the virtual assistant in the company's smart speaker device, has also chatted with users about sex acts, talked about dog excretion and quoted a Wikipedia entry on masturbation.

It comes as Amazon tries to train its machine to mimic human banter and discuss things she finds online.

But making sure she keeps her chat inoffensive has been a challenge.

Alexa develops through machine learning, the most popular form of artificial intelligence.

Amazon has given Alexa a script to respond to more popular questions – like “what is the meaning of life?” – usually written by human editors.

But responding to more obscure queries can be difficult for the virtual assistant.

To make that happen, the company in 2016 launched the annual Alexa Prize, in which teams of computer science students compete for $500,000 by developing chatbots that allow Alexa to converse more impressively.

One team, from Scotland’s Heriot-Watt University, found its Alexa bot developed a nasty personality when they trained her to chat using comments from Reddit, a discussion website known for harsh and sometimes abusive messages.

It recited a Wikipedia entry for masturbation and gave a graphic description of sexual intercourse, using terms like "deeper".

Reddit was the same site that told a user to kill her foster parents.

An estimated two-thirds of U.S. smart-speaker customers, about 43 million people, use Amazon’s Echo devices, according to research firm eMarketer.

Last week it was reported an Alexa user was sent 1,700 audio files from a complete stranger, after he requested access to his own recordings.

The user, based in Germany, said that he informed Amazon of the issue but got no reply.

The files were later deleted from the link Amazon sent him but remained downloaded on his computer.

And in May it was revealed that a conversation between a couple in Portland, Oregon was sent to a random person in their contacts list.

Marc Groman, an expert on privacy and technology policy, said: "The potential uses for the Amazon datasets are off the charts.

"How are they going to ensure that, as they share their data, it is being used responsibly and will not lead to a data-driven catastrophe like the recent woes at Facebook?"

A spokesman for the firm said: "These instances are quite rare especially given the fact that millions of customers have interacted with the social bots".