I recently read an article that offered tips for people tempted to cheat on their partners. It got me thinking about what happens before anyone acts. It could be a late-night conversation with a coworker, a friendship that has started to feel romantic, or the attention of someone new at a time when you feel disconnected at home.

I asked on my Facebook page what draws people toward an affair. One man said he noticed more interest in other women when he and his wife hadn’t had sex in a while. Another person described the appeal of feeling wanted: “if somebody wants to have sex with me, that means that I must be really lovable.” Those answers point to different needs. Understanding yours can help you choose what to do next.

Name the need and the agreement

Ask yourself what the attention gives you. Do you miss affection, novelty, sex, or a sense of being seen? Then ask what you and your partner have agreed to. People can draw different lines around private messages, flirting and physical intimacy. If the agreement is unclear, talk about it before taking a step you would feel compelled to conceal.

Set a boundary you can keep

Choose an action you control. You might end flirtatious messages, keep conversations with a coworker about work, or decline an invitation that feels like a date. If you’ve already crossed an agreed boundary, stop the behavior and decide how to take responsibility. Attraction can show up unexpectedly. You still get to decide how you respond.

Talk about what you want from the relationship

Start with one concrete observation and one request. For example, “I miss how close we used to feel. Could we set aside some time this week to talk about affection and what each of us needs?” Either partner can decline sex. If you both want to reconnect, you can explore what kind of time or intimacy feels welcome to each of you.

If your needs or priorities have changed, you can discuss different agreements only if you both freely want them. You can also end the relationship before pursuing someone else. If trust has already been damaged, read about recovering from infidelity and consider what each person would need to make an informed decision about staying.