This current research is based on the implementation of an algorithm that assigns pets, cats, or dogs to persons with depressive disorders such as low self-esteem. We found that even though different institutions have made the assignments of pets to patients, we were not able to find one that uses an IT tool for this task. Because of this situation, we decided to adapt to the well-known Gale-Shapley algorithm that has been used successfully in different situations in which it needs a perfect match between two parties. The results obtained have been validated by experts in the field of animal and person psychology. Because the Gale-Shapley algorithm needs a preference array between the parts involved and due that an animal cannot establish this set of preferences, we aimed to use a string similarity-based algorithm for obtaining preferences arrays based on the behavioral traits of an animal or person.