Do you want make your Slack channels more exciting and funny? What about a bot that reads your “feelings” and renders them by automatically posting animated funny gifs from Giphy?

Our Gitphy bot does exactly this. Add it to your website, your Slack channel,… to have some fun with your visitors and collaborators. As seen in the image below, you can ask the bot whatever you feel like seeing and our Giphy bot will automatically find a gif in Giphy tagged with that word and post the animated gif in the Slack channel or a chatbot widget in your webpage. Feel free to play with the bot in this same page!.

Giphy gifs posted to Slack thanks to our chatbot

Building a Giphy chatbot

The bot is built with Xatkit. Right now the bot just takes the first gif returned by the Giphy API but of course, you could easily implement more complex prioritization strategies. The goal of this post is to show you easily you can build a bot like this. And we hope this will push you to start exploring ASAP our open-source chatbot platform!

You can download the full code of the Giphy chatbot. Like all Xatkit bots, it uses our Java Fluent API so you can read and modify the code with any Java editor. Let’s see the core of the bot.

For this bot, we just have one main intent: asking the chatbot to find an image for us

The intent CanYou will be matched any time we write a sentence similar to those listed in the training inputs. The @any keyword will take the concept/action/whatever we want to visualize and store it as part of the request parameter information.

Then, in the main bot state, we will recover this parameter and ask Giphy to return an image tagged with it.

See how we use our API REST platform to simplify the interaction with the Giphy API (though of course, you could use other REST libraries, like Unirest, if you prefer; this is the beauty of using an internal DSL!). In this sample code, the image is printed in the chatbot widget but you could send it to a Slack channel or whatever you want it to show up.

The bot has some other states (for helping the visitor and greeting him), you can see them all in the GitHub repo. But the few lines of code shown in the two gists above are basically all you need to create your own Giphy chatbot.

I’m sure you’ll agree that the actual code of the bot is rather simple. Thanks to our predefined Slack, React, Rest and Giphy platform support, all the complexity of calling and interacting with those platforms is on us. You just need to think of interesting ways to combine them.

Enjoy! And if you create any Xatkit bot let us know and we may even feature it here next!

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Follow all our news around the world of bots, chatbots and digital assistants. Learn how to build your own for free with Xatkit.

You have Successfully Subscribed!

Pin It on Pinterest

Share This