With their entire caper inadvertently recorded on a cellphone message, a couple of bumbling bandits were left with no alibi — and no way to cover their tracks.

So they pleaded guilty on Thursday, hoping for a break in their prison sentences.

The big break, though, had come earlier for police, whose key evidence was a long voice-mail message left after the victim dialed his girlfriend’s number just before the heist.

Brandon Madison Pritchett, 25, of Minneapolis, and Anthony Darling, 24, of Chicago, were sent to prison for aggravated robbery. The man they shot has a bullet lodged in his chest, but no complications.

“This was a perfect combination of good citizen involvement by the girlfriend realizing what was on her cellphone, police investigators in compiling all the evidence and our prosecutor putting together a strong case,” Hennepin County Attorney Mike Freeman said Friday.

The crime played out in the early morning hours of July 8, 2012, when a Brooklyn Park man tried to call his girlfriend but got voice mail. He had wanted her to unlock the house door as he was pulling into his driveway on 84th Avenue S., according to the criminal complaint.

When he exited his car, two men grabbed him, pulled a bag over his head and forced him to the side of his house. They stole his car keys, money and cellphone — still connected to the girlfriend’s voice mail.

It kept on recording as they hit him on the head, knocking him to the ground. Then they shot him.

Anoka County authorities swiftly nabbed Pritchett and Darling in a ­stolen car they were driving. They had tossed the man’s cellphone out the window, but police later found it in a roadside ditch.

Investigators listened to the voice mail left on the girlfriend’s phone. They could hear the robbery, gunshot and the bandits driving off while each blamed the other for flipping off the gun’s safety catch.

On Thursday, both apologized to the victim, insisting that they hadn’t meant to shoot him.

Judge Gina Brandt sentenced Pritchett, who has a history of robberies and fleeing police, to eight years and six months. Darling got four years and two months.