Adding a PHP bot to Slack using Azure

Our software team at ActiGraph is in the early stages with Slack. In the first week it's helped keep everyone in the loop about all software products in process. We integrate with several of our development tools. Including: GitHub for commits, TeamCity for build notifications, and Google Docs to show documentation. While looking for other tools that work with Slack, I found a large list of community built plugins and integrations.

Being a .NET developer, I checked out the C# items available. There are some interesting API ports and implementations. As I scrolled through the list, I found a PHP bot that generates random GIFs in your Slack channels.

gif bot

There are two PHP bots that have similar functions. They both use Giphy's gif search to find images based on a search term. The one I'm demoing also allows you to find a random gif without a search term.

Step 1. Sign up for Azure. It's free to sign up and you get $200 to spend on their services.

Azure trial

Once Azure has finished setting up, you'll need to create a new PHP website.

Step 2. Click the "+ NEW" button at the bottom right of the dashboard.

azure dashboard

Step 3. Select "WEB SITE" from the "COMPUTE" items.

web site

Step 4. Select "FROM GALLERY"

gallery

Step 5. A list of items will pop up available for Azure. Select "PHP Empty Site"

PHP empty site

Step 6. Give the site a name. I'm using slackgifbot.azurewebsites.net. You'll need this later when hooking up support in Slack.

site name

Step 7. Once the site finishes setting up, click on the site in the dashboard.

site

Step 8. That will load a quick start guide to help set up the site. From that page, select "Set up deployment from source control."

source control

Step 9. Time to enter the location of the source code. The easiest way is to link directly from the gifbot GitHub repo. You could also clone the repo and link to it from your GitHub account if you want to customize it. I'll show you the direct approach.

Select "External repository"

external repository

Step 10. Enter repo URL

repo site

Step 11. Wait for site to deploy!

Step 12. Once deployed, it's time to integrate with Slack. Go to your service integrations in Slack.

Step 13. Add a new outgoing Outgoing WebHook

webhook

Step 14. Add integration settings for the Outgoing WebHook. Make sure the URL is pointing towards the azure website you entered.

fill it out

Step 15. Time to use the gifbot! Go to one of your Slack channels and type "#gif <search_term>" and get a related gif. Or, you can type just "#gif" and a random gif will appear!

gif test

Show Comments