Gifbot for Slack
Gifs for your Slack channel.
Do you find that you cannot properly and completely express yourself unless it's done in animated form? You're not alone! Gifbot is here to help.
What is Gifbot?
Gifbot is a set of integrations for Slack that allow you to easily post animated gifs to your Slack channel using Giphy's excellent gif search API. It'll take a search term you provide and use that to try to find the most appropriate animated gif related to that term. It'll then display that gif directly inside your Slack channel.
How does it work?
Once installed, simply type
/gif followed by a search term and instantly see a fantastic animated gif:
Sometimes they're exactly what you wanted, sometimes they're not, but they're always entertaining. And if you ever really want to take the entertainment up to 11, you can type in just
/gif to get a completely random gif.
Alright, I NEED this. Like, NOW. HOW DO I GET THIS INSTALLED??
Woah, woah, slow down there tiger. You'll need a few things to get this up and running:
- A Slack account and team, obviously. If you don't have Slack yet, get on it. It's great.
- A webserver that can run PHP 5.3.x or higher and upload access to that server.
- A little bit of familiarity with setting up Slack integrations (and permission to do so).
All set? Good, let's set up your very own Gifbot!
Slack Integration Setup
Let's start by setting up your Slack integrations to work with Gifbot. The first thing we need to set up is the command you'll use to trigger Gifbot, called a Slash Command.
- Head on over to Slack and add a new integration
- Scroll down to and add a new Slash Command
- Fill in the information under "Settings".
- For command, enter in '/gif'.
- For URL, point it to wherever you'll be hosting the gifbot.php file from this repository.
- The other two don't really matter.
- Save the integration.
Next, we need to set up an Incoming Webhook, which will handle displaying the gif results from the Giphy API in your channel.
- Head back to the integrations and add another new integration
- Scroll down and add a new Incoming Webhook.
Make sure you choose incoming, and not outgoing.
- Choose a default channel for the webhook. Honestly, this option won't really matter since Gifbot will read the channel the slash command goes out to. The best option is to choose @slackbot so that it'll work with DMs with the Slackbot.
- Add the webhook.
- Note and set aside the url under "Your Unique Webhook URL". We'll need this in a second.
- Scroll down to Integration Settings and expand it.
- Click on the link to "change the icon" and give it a custom icon, like this one: https://github.com/Giphy/GiphyAPI/raw/master/api_giphy_logo_sparkle_clear.gif. This is completely optional, but it'll make your bot look extra cool.
- Save the integration.
Congrats, Slack is now setup to work with Gifbot! Now, let's get your Gifbot set up on your server.
- Open up the
- Change the value of the
webhook_urlproperty to be that "Your Unique Webhook URL" we set aside earlier.
- Upload the contents of the repository to your web server. Make sure the URL you specified to Slack when setting up your Slash Command points to the gifbot.php file on your server.
That's it, you're done! Head on over to a Slack channel, type in "/gif thumbs up" (without the quotes) and see what happens. Happy gif'ing!
Optional Configuration Settings
config.php file has a few extra options you can change:
(Boolean) Whether to use the Translation API (the default) or the standard search API. If you opt out of the Translation API, gifbot will use the normal search API to get the top 25 results from Giphy and choose one from those at random. More information about the difference can be found on Giphy's API docs: https://github.com/giphy/GiphyAPI#translate-endpoint
(String) The name displayed in Slack for the bot. Defaults to 'gifbot'.
(Boolean) Whether or not to show the name of the Slack user that requested the gif after the botname. Eg. 'gifbot :: joe'.
Giphy API key. Defaults to the public Giphy API key but if you run into their usage limits you might need to register for your own.