A humanoid robot called "Sophia" trolled tech billionaire Elon Musk at a conference on Wednesday when asked about the potential dangers of artificial intelligence by a CNBC journalist.

The lifelike robot, developed by Hong Kong-based robot manufacturer Hanson Robotics, mocked Musk on stage during The Future Investment Initiative in Riyadh, Saudi Arabia -- a country where Sophia has just been given citizenship.

Andrew Sorkin, the co-anchor of CNBC Squawk Box and a columnist for The New York Times, told Sophia during a live demo that "we all want to prevent a bad future."

Sophia replied, in a rather creepy manner: "You've been reading too much Elon Musk. And watching too many Hollywood movies. Don't worry, if you're nice to me, I'll be nice to you. Treat me as a smart input output system."