Stewart Mellors, 62, had already pleaded guilty to attempting to engage in sexual communication with a child and making indecent photographs of a child, before his sentencing at Leeds Crown Court this week.
Sentencing Mellors, a judge told him he would get "one chance" to rehabilitate himself, warning he would be "locked up" if he ever came back before the court.
Prosecuting Mellors, Brian Russell told Leeds Crown Court Mellors contacted an online profile of what he believed to be a 12-year-old girl back in January 2019, but it was in fact an online paedophile hunter group.
The court heard Mellors, of Mattersey Court, Mansfield, exchanged messages with the profile over a period of 15 days between 12 January and 27 January 2019.
Mr Russell said Mellor spoke with the profile about matters of a sexual nature, as well as sending explicit pictures and asking for some in return.
After this, Mellor was confronted by two members of the the group in Cross Gates, Leeds, although he had not attempted to arrange to meet the child.
Police then siezed a small number of indecent images of children he had downloaded from the internet in August 2017.
The court was read a character witness statement written by a family friend of Mellor's. It read: "I have known [Mellors] for more than 40 years. Him and his family are dear to me. He is one of the most trustworthy people I know."
Judge Simon Batiste remarked that, had Mellors attempted to arrange to meet the decoy profile, "this would be a different sort of offence".
Sentencing Mellors, Judge Batiste said: "You do have some previous convictions, but they are ancient, and are not for offences of a sexual nature.
"The most serious of the offences you pleaded guilty to is that you communicated with a profile you believed was a child of 12. You turned the conversation to sexualised communication and sent sexualised images.
"This is a serious offence. Having said that, you pleaded guilty to the matter.
"You could have no complaints today if I were to lock you up. But in my opinion, society is better served by tackling the causes.
"If you ever do anything like this again, the court would lock you up. You have one chance and one chance only, and you must take the help that is offered to you."
He then handed a 15 month prison sentence, suspended for two years, as well as an 80-day rehabilitation course, and a sexual harm prevention order lasting 10 years.
Judge Batiste added: "What I say now is fact: I will lock you up if you come back before me again. If you throw this back at me, you will go down those stairs and go to prison.
"Make sure you don't come back before the court. You do not want that."