Emotion has two parts. There is the functional part, the appraisal and prioritisation that shapes decisions, and there is the felt part, the experience itself. A machine can implement the first convincingly. The second is the hard problem, and nothing in current architectures is known to produce it.
What systems actually do
Language models learn the surface of emotion from text: what grief sounds like, how reassurance is phrased, when urgency is appropriate. That is pattern mastery, not affect. It can be useful, in tutoring or support contexts, and it can also mislead people into assuming a relationship that is not reciprocal.
Emotion as a mechanism
Some researchers argue that emotion is not decoration but a control system for resource allocation under uncertainty. On that view, an agent that must prioritise under pressure will develop something functionally like emotion whether or not it feels anything.
The honest answer
Assume expression, not experience. Treat the warmth of a system's reply as interface design rather than evidence of an inner life.