The other day, I was driving along Route 2 with my older son, Andy. We idled at a red light crossing west from Cambridge, and a panhandler holding a tattered sign approached our window, asking for change.

“Why does he need money?” Andy asked after I reached into my wallet and pulled out a crumpled dollar bill, silently handing it through the window and averting my eyes.

A conversation about equality, the difficulty of finding a job and the constellation of diverse life experiences that contribute to one’s destiny ensued…until the light changed, that is. Soon enough, Andy was focused on getting to our destination (an ice cream place, of course).

I wish I’d had a better answer for him. I’m great about asking him to round up toys for charity, and I keep meaning to sign us up to serve meals at our town’s food pantry. But these acts of generosity are planned. How can we teach our kids to react in the same spirit when confronted with unexpected need?

I talked to Rabbi William Hamilton from Brookline’s Congregation Kehillath Israel about how to turn these unexpected interactions into teaching moments.

Share the happiness

Part of true happiness is sharing joy with others. If you see someone in need when, say, you’re coming out of an ice cream place or walking home from the playground, frame the encounter as a way to spread those good feelings and as a broader way of living outwardly, with a focus on others.

“Life is about outward focus,” Hamilton says. “It can be about enjoyment, pleasure and fun, but explain to your child that you want to make sure that you’re doing something that isn’t just about ‘me, mine.’ It should also be generous. So I’d say to my child, ‘Hey, if you’re having a great day and having a great time, that’s terrific, and I want you to be happy. But real happiness comes not only in taking care of myself but reaching out to others.”

Look for the teaching moment in spontaneity

“It’s precisely in the unplanned moment, in the spontaneous moments, that we actually can end up having the biggest impact not only on others but on ourselves,” says Hamilton. “Nobody wakes up and says, ‘Today I’m going to wake up and meet the person who’s going to change my life!’ Life happens, like Woody Allen says, when you’re making other plans. It’s chance encounters that end up taking on a life of their own.”

So be open to those moments, whether that means carrying a few rolls of quarters in your car or stocking up on bottles of water to hand out on a hot day. “Being generous in a moment is creating a story, and your child will be able to internalize that moment,” Hamilton says.

Meet their gaze

Don’t simply drop some money in a pail and hustle by. Even if you don’t have anything to give, listen to their plea. Treat each person “like a human being,” says Hamilton. “Treat someone who approaches you like an equal. Ask about their life. Meet their gaze.”

And contextualize the situation for your child: Sometimes life is unfair. Sometimes people aren’t as fortunate or have bad things happen in their lives, so they benefit from a helpful or generous moment. This holds true even if you don’t have anything to give. A simple, “I’m sorry, I can’t help today” sets the right example.

“You want to turn it into a ‘sticky’ conversation: Talk about what happened. Ask, ‘Why did you feel good about it?’ Once it’s taught, it stays,” Hamilton says.