Coca-Cola has been forced to withdraw a Twitter advertising campaign after a counter-campaign by Gawker tricked it into tweeting large chunks of the introduction to Hitler’s Mein Kampf.

For the campaign, which was called “Make it Happy” and introduced in an ad spot during the Super Bowl, Coke invited people to reply to negative tweets with the hashtag “#MakeItHappy”.

The idea was that an automatic algorithm would then convert the tweets, using an encoding system called ASCII, into pictures of happy things – such as an adorable mouse, a palm tree wearing sunglasses or a chicken drumstick wearing a cowboy hat.

In a press release, Coca-Cola said its aim was to “tackle the pervasive negativity polluting social media feeds and comment threads across the internet”.

But Gawker, noticing that one response had the “14 words” white nationalist slogan re-published in the shape of a dog, had other ideas.

The media company’s editorial labs director, Adam Pash, created a Twitter bot, @MeinCoke, and set it up to tweet lines from Mein Kampf and then link to them with the #MakeItHappy tag – triggering Coca-Cola’s own Twitter bot to turn them into cutesy pictures.

The result was that for a couple of hours on Tuesday morning, Coca-Cola’s Twitter feed was broadcasting big chunks of Adolf Hitler’s text, albeit built in the form of a smiling banana or a cat playing a drum kit.

The bot made it as far as making Coke tweet the words “My father was a civil servant who fulfilled his duty very conscientiously” in the shape of a pirate ship with a face on its sails – wearing an eyepatch – before Coca-Cola’s account stopped responding.

By Wednesday, the campaign had been suspended entirely. In a statement to AdWeek, a spokesperson for Coca-Cola said: “The #MakeItHappy message is simple: the internet is what we make it, and we hoped to inspire people to make it a more positive place. It’s unfortunate that Gawker is trying to turn this campaign into something that it isn’t.”

The statement concluded: “Building a bot that attempts to spread hate through #MakeItHappy is a perfect example of the pervasive online negativity Coca-Cola wanted to address with this campaign.”

Coca-Cola is not the only company to have noticed pervasive negativity online. Twitter chief executive Dick Costolo wrote in an internal memo to staff that he was embarrassed by the company’s failure to deal with online trolls.

“We suck at dealing with abuse and trolls on the platform and we’ve sucked at it for years,” reads the memo, which was obtained by the Verge on Wednesday.

“I’m frankly ashamed of how poorly we’ve dealt with this issue during my tenure as CEO. It’s absurd. There’s no excuse for it. I take full responsibility for not being more aggressive on this front. It’s nobody else’s fault but mine, and it’s embarrassing.

“We’re going to start kicking these people off right and left and making sure that when they issue their ridiculous attacks, nobody hears them.”

Coca-Cola is not the first corporate Twitter user to run into trouble over an automated bot created for advertising purposes. In November 2014, the New England Patriots were forced to apologise after an automatic bot was tricked into tweeting a racial slur from the official team account.