How Spotify and Amazon are using A.I. to learn your preferences—and even read your mood

When Spotify recommends a “Songs to Sing in the Shower” playlist to you, the tracks are assembled using what its machines have learned about you, from more than 4 billion user-created playlists and from the company’s own musical experts. The streaming music platform is even increasingly using automation to detect the mood of songs to better personalize the user experience, said Spotify’s senior director of product Ziad Sultan at this week’s Fortune Brainstorm A.I. conference in Boston.

“When [users] are adding songs to their playlists, they are calling it ‘My Happy Rock Songs,’ ‘My Happy Jams,’ ‘My Sad Ballads,’ my this or that,” he said. 

“For any given song, if we know it is in 1 million playlists called ‘happy,’ another million called, you know, ‘a rainy Sunday,’ we’re able to understand the emotion of the content of the song, as well as the emotional state of the user when they’re listening to it,” Sultan said. 

Personalizing user experiences are increasingly happening in real time. Spotify is doing that with its Enhance playlist feature, which rolled out in early September. When a user taps the Enhance button, the platform weaves in up to 30 songs tailored to dovetail with the user’s own playlist.

“This is basically the user and the machine learning hand-in-hand building the experience,” Sultan said.

Amazon is likewise working to enable users to help teach Alexa, the virtual assistant it introduced seven years ago. The company is launching a new capability that allows users to explicitly tell Alexa to learn certain preferences. 

“You can say, ‘I’m a vegetarian’ or ‘I’m a Red Sox fan,’ and that lets Alexa decide how to personalize the experience for you,” said Rohit Prasad, a senior vice president at Amazon and head scientist for Alexa artificial intelligence, who also spoke at the event. 

That combination of explicit and implicit preference learning is the best way to further personalize user experiences with tech like Alexa, he said. 

If a user tells Alexa that they are vegetarian, “then Alexa will be very explicit in terms of I’m going to use your food choice for when I recommend restaurants to you,” Prasad said. That transparency “is still super important in building that trust with the A.I.”

Amazon’s vision for Alexa is to be ambient artificial intelligence, “which is there when you need it and recedes into the background when you don’t,” he said. 

Getting there means the device needs to offer “self-serve” artificial intelligence, allowing users, not just developers, to guide the device’s learning, he said. That means, being able to ask the device to let you know when the dog is barking, he explained—or when your kids are playing video games for too long.

More must-read business news and analysis from Fortune:

Subscribe to Fortune Daily to get essential business stories straight to your inbox each morning.