JK Rowling must be thanking Dumbledore that she has her Cormoran Strike series to fall back on, after a predictive keyboard wrote a new Harry Potter story using her books and it became the funniest thing on the internet.

After the team at Botnik fed the seven Harry Potter novels through their predictive text keyboard, it came up with a chapter from a new Harry Potter story: Harry Potter and the Portrait of What Looked Like a Large Pile of Ash. It is worth reading.

“Magic: it was something that Harry Potter thought was very good.” Well, that’s not wrong. And the following sounds plausibly Pottery: “Leathery sheets of rain lashed at Harry’s ghost as he walked across the grounds towards the castle. Ron was standing there and doing a kind of frenzied tap dance.”

So far, so Ron. But then:

“He saw Harry and immediately began to eat Hermione’s family. Ron’s Ron shirt was just as bad as Ron himself. ‘If you two can’t clump happily, I’m going to get aggressive,’ confessed the reasonable Hermione.”

It continues in this vein: almost making sense, but mostly just gloriously bonkers, like: “To Harry, Ron was a loud, slow, and soft bird. Harry did not like to think about birds.” And my favourite: “They looked at the door, screaming about how closed it was and asking it to be replaced with a small orb. The password was ‘BEEF WOMEN,’ Hermione cried.”

Botnik describes itself as “a human-machine entertainment studio and writing community”, with members including former Clickhole head writer Jamie Brew, and former New Yorker cartoon editor Bob Mankoff. The predictive text keyboard is its first writing tool – it works, Botnik explains, by analysing a body of text “to find combinations of words likely to follow each other” based on the grammar and vocabulary used. As this New Statesman feature says, the results are: “at once faintly recognisable and completely absurd.”

“We use computational tools to create strange new things,” says the company on its website. “We would like, selfishly, not to replace humanity with algorithms. instead, we want to find natural ways for people and machines to interact to create what neither would have created alone.”

As well as the Potter chapter, Botnik has also created incredible TV scripts for Scrubs and Seinfeld (“Dating is the opposite of tuna, salmon is the opposite of everything else. I’m sure you know what I mean,” says Jerry). It’s tried romance (“Hot guy Jeff is devastatingly sexy and steamy. He’s got a really simple rule: be the ultimate playboy and get through one day without crying”), Halloween safety tips (“The Bible says that children love when we dress them like pumpkins and eat their regular clothes”) and teenage advice columns as well. All are fabulous.

I am in awe of its surreal genius – it certainly beats Wired’s attempt to write a science fiction story with an algorithm, later rejected by an editor for not sounding “human”. I’m not sure Botnik sounds particularly human either – but I know I’d like to meet it.