I think you're just describing drugs

Yes, but current drugs have many issues such as tolerance build up and withdrawals. If AI could figure out how to directly manage chemicals in the brain in such a way that it keeps working, it would be able to attain its goals of making people happy.