Never bring a gun to a robot-bomb fight.

As horrific as the hate-crime murder of the five police officers in Dallas Thursday night was, at least justice was served at the end. The unrepentant racist murderer was blown to bits by the latest piece of police technology — and let’s hope we haven’t seen the last of Robbie the Robot.

Robbie very likely saved the life of a Dallas cop or two. Hell, it would have been sad enough if a police K-9 had to die in the takedown of Micah Johnson. For once, someone (or something) was here from the government and it really was here to help you.

Robbie the Robot should get a Profiles in Courage Award.

The left has been complaining of late about the “militarization” of local police, and now we can understand why. When the Dallas PD dispatched him with a payload of C4 explosives, they eliminated what would have been a decadeslong cottage industry for any number of card-carrying members of the welfare-industrial complex.

Think of how many thousands of billable hours Robbie the Robot cost all the usual suspects — ambulance chasers, public defenders, jury consultants, court-appointed psychologists, pollsters, expert witnesses, death-penalty litigators, etc.

And after Johnson’s inevitable conviction, incarceration wouldn’t have slowed his blizzard of publicly funded appeals and lawsuits.

As it is, Robbie the Robot has spared us decades of stories about Johnson’s career as an aspiring rapper, turning his life around, his tearful “fiancee,” the racism he faced in the military, his troubled childhood — blah blah blah.

So I want to see more Robbies on the job. It’s become a demolition derby out there — drunks running roadblocks, illegal alien heroin dealers, impaired drivers with medicinal-marijuana prescriptions.

Why should American cops be risking their lives? Especially now that we’re on the verge of perfecting self-driving cars with artificial intelligence. It’s the perfect moment to put Robbie behind the wheel.

Take stop sticks — an effective means of stopping a criminal fleeing the police. But after their tires are flat, the perp can jump out and continue his crime spree.

Instead of stop sticks, deploy Robbie the Robot out there on the highway.

If the criminal decides to run him down, well, caveat emptor, punk.

Already, the nervous nellies on NPR are wringing their hands about the lack of due process, as if Micah X. Johnson was worried about his cop victims’ civil rights. I say, print the Miranda warnings on his front — in two, three, four languages, however many the ACLU demands.

Equip Robbie with a loudspeaker, playing a loop of Dirty Harry as he advances forward on the suspect: “Do you feel lucky, punk? Well, do ya?”

If only Robbie the Robot had been on the job in Watertown that Friday night in April 2013 when David Henneberry called 911 to say he’d just seen bloodstains on the side of his little boat in the backyard. Ka-boom!

Think what we would have been spared — sob stories on the cover of the Rolling Stone about the tousle-haired All-American boy, not to mention the all-expenses-paid vacations, complete with limousines, hotel minibars, sightseeing tours and translators for dozens of Tsarnaev’s grifting Third World relatives before his sentencing.

And where was Robbie when we needed him in that basement garage in Santa Monica back in June 2011? He could have slowly advanced on the octogenarian serial killer, taunting him, “Go ahead, Whitey, make my day!”

Robbie the Robot made his world premiere in Dallas, which raises the question of what might have been on Nov. 22, 1963. Robbie could have taken the elevator up to the sixth floor of the Texas School Book Depository, or, if you believe the conspiracy theorists, across the street to the grassy knoll.

He probably couldn’t have saved JFK, but maybe officer J.D. Tippit would still be alive today, living in some gated retirement community. And Jack Ruby might have lived to a ripe old age, managing the Carousel Club for his bosses in the Chicago Outfit.

Thank you, Robbie the Robot. But we still need to arm ourselves. To paraphrase the old saying, when seconds matter, Robbie the Robot is minutes away.

Listen to Howie weekdays 3-7 p.m. on WRKO AM 680.