One of the best perks of speechwriting is the way it lets you indulge your sense of humor. Nearly every time you sit down to write a speech, there’s a chance to tell at least one joke.

That’s not something most other communicators get to do nearly as often. (Try slipping a one-liner into the annual report some time. Let me know how that goes.)

And it isn’t an indulgence—or at least, it isn’t just an indulgence. Humor has real communications power. It humanizes your speaker, builds a rapport with an audience and can help overcome hostility, suspicion and resistance to new ideas.

But written or delivered badly, a joke can work against your speaker. Which gives us a responsibility to use humor carefully and sensibly.

Jokes have a tiny little soul that can be redeemed by laughter and scorched by indifference.We have a duty, after all, to the people we write for to let them help their stories as authentically and effectively as we can. We have a secondary duty to the audience, because inflicting a dud on them is an act of inhumanity.

And if you believe, like I do, that jokes have a tiny little soul that can be redeemed by laughter and scorched by indifference, then we have a duty to the jokes themselves: to hone them to razor sharpness, and not to send them out to die uselessly if we don’t think the speaker can deliver them.

Here’s what I do to give those jokes — and the people delivering them — every chance of success:

Fit the joke to the speaker.

The joke doesn’t just have to be one your speaker can physically deliver; it has to be a joke your speaker can credibly deliver. A 68-year-old bank CEO with a deft little Macklemore lyric parody isn’t fooling anyone.

Know what your speaker can and can’t do.

If your speaker can’t tell a joke to save their life, then don’t make them. If they can’t make an offhand remark sound anything but stilted and rehearsed, don’t make them deliver one. If their strength is anecdotes concluding with a wry observation more likely to inspire a chuckle than a guffaw, then write those. Play to your speaker’s strengths.

Respect your speaker’s comfort zone.

There are places I’ll sometimes push a speaker, but I won’t fight for a joke — not any more. Just a note of unease from them is enough to make an audience lose confidence in the joke, and once that happens, confidence in the speaker is next to go. Conversely, a joke delivered with confidence lets an audience relax, feeling as though they’re in good hands, and gives your speaker a welcome burst of positive energy.

Respect your audience’s comfort zone.

Humor often pushes boundaries, and lets you move an audience to see things in a new way. It’s probably the most powerful way to break down walls between speaker and listener. But as powerful as that is, it’s also dangerous; push just a little too far, and instead of laughter and self-revelation, you’ll get silence broken only by the rustle of awkward squirming. Push any farther, and it’s torches and pitchforks. Or, worse, hostile tweets.

Know your audience’s sense of humor.

Comedians know that material that kills with a college crowd may well get cricket noises in Vegas, and vice versa. Keep the tone and language consistent with their sense of humor. And use reference points that they’ll relate to: pop culture jokes that reflect the music, TV and other media they watch and listen to, for example. (My wife has finally persuaded me that many 20-somethings aren’t conversant with the Friends oeuvre. Tragic.)

Fit the occasion.

You want your joke to fit your speech well. Too many speakers, told to open with a joke, shoehorn in something about a farmer and a prairie dog on a golf course. Does your speech to a room full of pipe-fitters needs to have a joke about four-inch flange-spreaders? No. But a) if you have one, I’m impressed and a little frightened, and b) whatever jokes you do tell should resonate with the theme and message of your speech. And in that spirit…

Advance the narrative.

Make your joke carry its own weight. Even if it gets a good laugh, if it stops the flow of your speech dead, then it’s done more harm than good. Call out something intrinsic to the joke that reinforces the point you’ve made, or leads you into the next section of your speech.

Pace yourself.

Make sure the joke fits in with the emotional rhythm and pace of the speech. Jokes provide a release of tension, and a joke can stall you if you’re building to a crescendo. The exception: when the crescendo is itself a joke; laughter can build on laughter marvellously.

Some laughs aren’t worth it.

No “ethnic” “humor.” No sexism. No homophobia. If there’s a chance your joke will be mistaken for something offensive if it’s taken out of context or if someone tunes in halfway through, cut it. If you have to set out an elaborate rationale for the joke’s acceptability, cut it. If your description of the joke includes the word “harmless,” cut it. If you have a faint inkling that your joke’s a little raunchy for this crowd, cut it. You’re writing for a speaker, and artistic performance risks a standup comic might take aren’t the goal here. And neither your speech nor the audience is served by an offensive joke, intentionally so or otherwise.

And finally,

Be kind.

While good-natured jokes are the likeliest to endear you to an audience without alienating them, it’s the jabs that people often remember. And jokes can be critical without being mean. The moment you come off as bullying or hitting someone when they’re already down, you’ll lose your audience—and you probably won’t get them back.

But if you can tell even a critical joke with grace and clear good will, then you’re well on your way to building a solid, durable relationship with your audience—the kind that keeps them listening long after the punchline.