Back in highschool I had a teacher that taught me a couple of things that I actually took to heart and carried with me into real life.
One of them was, when you ask someone how they are doing, listen to their answer. Don't just say "hey, how's it going" as you rush on by. I think it also important to give a genuine answer to those who ask sincerely. Don't just say "fine".
The other thing was the skill of active listening. Perhaps this resonated with me because as someone whose love language is quality time, it is important that people actually listen to me without distraction. Since my personality is not one well known for good listening skills, I feel like learning how to listen actively was really helpful. Eye contact, lean toward the person, respond to what they're saying, etc.
Another thing I have learned in life, this one from my mom-in-law, is that you never know what someone is going through, or has gone through. You don't know their story. You might think you know most of it, but you probably don't know all of it. Keeping this in mind has helped me respond to people more gently than I might feel like reacting. This life lesson also has a flip side. Don't assume that people cannot relate to what you are going through. If you are the kind of person who keeps things buried inside, try sharing and you might find someone who has gone through the same thing.
I don't know who taught me this life lesson, but another thing is to never say the words "I understand" unless you truly feel like you get it. There are many other comforting and encouraging words to choose from, such as "I'm sorry", "That must be tough", and "I'm praying for you" (if you actually are), if you feel like you cannot understand the person's feelings or situation. I personally will never say "I understand" if I do not feel like I actually do. Since I haven't yet had anybody closer to me than my Grandpa pass away, I won't say "I know how hard this is for you" when your loved one passes away. However, if you are going through stress, panic attacks, depression, anxiety, etc, I will say "I understand" because I personally know that world much too well. I think there is great comfort in someone understanding where you are at, especially if they have been able to come out the other side. Even if your situations aren't identical, they may be able to understand what you are going through well enough for you to be able to trust their "I understand".