Emotions are cognitive schemata
Machines can have emotions if i) they can model the complex schema involved in concepts such as pride and shame, and ii) these concepts can be (partially) responsible for the behaviour of the system.
The essence of emotions is the schema of cognitive evaluation that determine the relationship between the emotion and the rest of the cognitive states of the subject. Margaret Boden, 1977.