A man sent "vile" racist text messages to one of his childhood friends before turning up at his door with a knife.
Daniel Kenwright "swung a knife" towards his long-term friend Curtis Brown before saying he needed a "cup of tea and a lie down" in an incident on October 17, 2019.
The 24-year-old, of Grosvenor Road, Wavertree, was said to have been suffering a mental health episode before launching into the abusive texts, the court heard.
Sentencing Kenwright to 40 months in prison for aggravated burglary, Judge Rachel Smith said the messages were "deeply offensive and they must have been deeply offensive to your victim."
Speaking to Kenwright via video link to HMP Liverpool, Judge Smith said: "After spending the day with your friend texts were sent by you, which were inexplicable to him because they were racist, aggressive and abusive."
The nature of the texts were not read aloud in court, but Stuart Mills, defending, said they were "vile".
After sending the messages Kenwright arrived to Mr Brown's home with a knife.
Judge Smith said Kenwright "swung the knife around" and towards Mr Brown.
Fearing for his life, Mr Brown hid in the bathroom as Kenwright was banging on the door.
Fortunately Mr Brown was not harmed, although Kenwright did cut his coat.
Judge Smith said after hitting the door Kenwright told Mr Brown he "was going for a cup of tea and a lie down" before leaving the address.
Kenwright, of no previous convictions, was described as a good character by a number of people known to him.
According to Mr Mills, his client's behaviour was "completely out of character" and he was very remorseful for the incident.
Reading aloud doctor's reports about Kenwright, Judge Smith said it was concluded he was suffering from a mental episode before as he sent the messages and arrived at his home.
Reading Kenwright's mitigation, Judge Smith said: "This offence was completely out of character and it was inexplicable because they had been friends since childhood."
And although the racist content in the messages was "deeply offensive" Judge Smith said she did not find it to be a racially aggravated offence.
She said: "They [the texts] were inexplicable to him and they must have been inexplicable to you. They are not evidence of racial motivation. They were likely to be a manifestation of your mental disorder you were suffering at the time."
Kenwright was jailed for 40 months and told to pay a victim surcharge of £181.
He was told he will serve at least half of his sentence in prison before he is released on licensed supervision.