SAN FRANCISCO — When Amazon introduced its Echo device in late 2014, Google executives were caught off guard. For years, they had predicted the creation of a virtual assistant that would answer questions or help accomplish tasks, and they focused on building that capability into smartphones and tablets.

Amazon took a different approach and created the Echo, a device with the sole purpose of showcasing the company’s artificially intelligent assistant software, called Alexa. Since then, the Echo has become a surprise hit, vaulting Amazon ahead of Google in a race to build technology that interacts as humans do. Users can ask Alexa to play music, dim the lights or call for a ride.

For Google, whose name is synonymous with finding answers on the internet, Amazon’s success with Alexa exposed a vulnerability. Google, along with its parent company, Alphabet, has invested heavily to solve the technology world’s toughest problems, but it often trails competitors in turning those advancements into products and businesses.

On Tuesday, Google is expected to finally unveil its answer to the Echo, alongside new smartphones and tablets. The Google Home device, which looks a little like an air freshener, is expected to go on sale later this month.