Ever thought about how to make your Slack channels more exciting and funny? What about a bot that reads your “feelings” and renders them by automatically posting animated gifs from Giphy?

The first chatbot in our examples repository does exactly this. As seen in the image below, you can ask the bot whatever you feel like seeing and theĀ  “Giphy to Slack” chatbot will automatically find a gif in Giphy tagged with that word and post the animated gif in the Slack channel.

Giphy gifs posted to Slack

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. Our goal is to show how Xatkit helps you to easily merge and mix separate platforms, Slack and Gliphy in this case. Right now, these two platforms are part of the xatkit coreĀ though we will be soon moving all the platforms to separate repositories to make it even easier to decide what platforms to use in every scenario.

Let’s take a quick look at this Giphy-to-Slack chatbot. As all Xatkit bots, the bot is defined in two main files: a file to define the intents the bot should match and a file to tell Xatkit what to do in response of each matched intent.

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

intent CanYou {
	inputs {
		"Can you (Request:request=@any)"
		"Have you seen (Request:request=@any)"
		"Do you know (Request:request=@any)"
		"Do you like (Request:request=@any)"
		"Any thoughts about (Request:request=@any)"
		"What do you think about (Request:request=@any)"

The intent CanYou will be matched any time we write in the Slack channel the bot is listening to a sentence similar to the ones 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 Requests context information.

Then, we just need to say in the execution file that every time we match a CanYou intent we should ask Giphy to return an appropriate image for the request parameter saved in the matching process and post a message in Slack with the gif image:

on intent CanYou do
	def res = action GiphyPlatform.GetGif(search : context(Request).get("request"))
	action SlackPlatform.Reply(message : "Sure! <" + res + "|Look>")

I’m sure you’ll agree that the actual code of the bot is rather simple. Thanks to our predefined Slack 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