We propose a computational model of emotion using the mechanism of the immune system. This model is inspired by the observation that emotion is similar to the immune system, in that each is a result of a self-defense system that is capable of adapting to the environment. The main component of this model is a body , in which many cells undergo Brownian Motion. Each cell has energy and characteristics that correspond to one of the five ego states in transactional analysis(Berne, 1964). The cells' state as a whole is its emotional state . Some cells are activated when antigens invade the body, and they work to sweep away those antigens. This process changes the emotional state. We implemented this model, and the results of experiments indicate that the model has the following two characteristics, which other models have not been able to achieve: (1) Emotional states change continuously. (2) Emotional states change in response to stimuli (antigens) according to the state at that moment and its past changes. We implemented a dialogue system using this model and found that the system can imitate human dialogues.