Scott Gaunt, of Williamson Avenue, Peterborough, messaged the girl between November 25 and December 17 last year.
During this time, Gaunt spoke sexually to the young girl and encouraged her to perform sex acts on herself.
At the start of the conversation, Gaunt told the girl he was 24. She replied that he was double her age, and he told her his mum "would probably kill him" if she found out they were talking.
Intelligence was submitted to police that the IP address used in the chat linked back to an internet account in Gaunt’s name.
A warrant was carried out at his house on January 18 and Gaunt was arrested on suspicion of attempting to cause or incite a child under 13 to engage in penetrative sexual activity.
Several devices belonging to him were seized and submitted for forensic analysis, but were found to have no illegal files on them.
In police interview, Gaunt admitted being the author of the messages and knew that he was talking to a child. He told officers he knew that what he said to her was wrong.
Gaunt admitted the offence at Peterborough Crown Court on August 18.
DC Scott Bowden, who investigated, said: "It’s clear Gaunt poses a risk to children and his behaviour was completely inappropriate towards a 12-year-old girl.
"Using the internet to target young and vulnerable girls will not be tolerated and thankfully Gaunt was stopped and arrested.
"Protecting young people from harm is one of our top priorities and we will continue to work tirelessly to keep our communities safe."
Gaunt was sentenced at Cambridge Crown Court on Friday September 11) where he was handed a total of 28 months in prison.
He was also placed on the sex offenders’ register for 10 years, and made the subject of a Sexual Harm Prevention Order (SHPO) for the same timeframe.
Anyone who is concerned someone may have been convicted of a sex offence, and could be posing a risk to someone, can apply for disclosure information through Clare's Law and Sarah’s Law.
For information and advice about child abuse, including sexual abuse, visit the force’s dedicated child protection web page.
Anyone who has concerns about child abuse should contact police on 101 (or report online at cambs.police.uk/report), children’s social care or the NSPCC. If a child is in immediate danger always call 999.