Project Overview and Demo

I built a custom Slack bot with a Google Apps Script while I was working at Move Your Metal to help speed up our team’s workflow. A video demonstration of the bot’s functionality can be seen below, and the code can be found here.

About

Why

When I worked at Move Your Metal, my coworkers and I spent a lot of time in AdWords making tweaks to campaigns and settings for every account we oversaw.

We used Slack as a hub for all the different services we used, so naturally we had a channel set up for documenting changes we made to AdWords. It was helpful to see what changes other team members were making, so that everyone else could ask questions or bring up suggestions or concerns while the changes were still fresh.

Unfortunately, using account names as keyword searches in Slack to find all the changes made to that account was inefficient and clunky.

I set out to solve that problem with a Slack bot and a Google Apps Script.

How

I spent a few evenings reading through Google’s documentation for their Google Apps Script platform, and set up a personal Slack team to play with Slack’s bot creation tools in a test environment.

After doing some testing and fixing some frustrating bugs, I had a working prototype that added account changes to the bottom of the appropriate Google Doc with custom formatting and the user’s name, as well as a timestamp.

Writing changes in the #history channel using the format Account Name - something that you changed; something else that you changed; more changes; would automatically add those changes to the appropriate document.

If the Account Name part of the message matched an existing document, changes would be appended to that document, and if it didn’t, a new document would be created with those changes.

The bot would then reply to the message to confirm that the appropriate Google Doc was updated (or created), and insert a link to that Google Doc.

Future revisions

I built this bot right before I began my final year of university, and I quit my job to focus on my fourth year, so there are several refinements I would make to this somewhat clunky implementation of the idea if I had more time to test it in a live environment.

One of the biggest problems with this bot is that it has fairly strict requirements for understanding commands. In order to make it more dynamic, I would make the bot capable of accounting for missed semicolons and mispelled (or differently formatted) account names.

I would also revise the calling of the bot. Slack bots can also be acessed with a custom command written like /command, and the calling command can be hidden from other users. Instead of having two posts in the channel, one after the other, it would be better to just have the bot's post show up.

If the bot were implemented this way, it could either say "Daniel made changes to Account Number 823" with a link to the Google Doc, or it could say something like "Daniel made the following changes to "Account Number 823: " and then list the changes.

Several other minor tweaks could also be made to the code to make it more scalable and robust.