The emergence of artificial intelligence over the past few years has led millions of Americans to turn to chatbots for emotional support amid a national shortage of mental health providers.