Grooving with Toggl and Slack

Who am I?

My name's Ben and I interned at Spantree this summer. At the beginning of the summer, I chose to work on a Slackbot that integrated with Toggl. Slack's one of my favorite apps and after reading articles like this, I was raring to play around from Slack

Full UIs are time consuming to build and require a lot of tough design choices - I once spent nearly 30 minutes picking my favorite shade of purple (incidentally, it's rebeccapurple), making them impractical to develop for every use case.

Luckily, alternatives, such as the Slack Real Time Messaging (RTM) API are beginning to emerge. This allows the development of a chatbot that can perform basic functions for you. Here's a few things I learned this summer from developing a Spring Boot chatbot for Spantree that integrates with Toggl to catalogue billable hours.

1. Groovy rocks

Since my first computer science class, I haven't touched Java, preferring languages like R and C# that aren't so... annoying. So when I learned that I was going to use Groovy, a JVM based language on this project, I wasn't too thrilled. However, I found Groovy to be an awesome language to use. It brought my favorite syntactical goodies from C# (for example, logical use of the == operator) and integrated it with the strong Java community (like the Toggl API wrapper JToggl that I used for this project).

2. Chatbots are fun!

There's something magical about the first time that your bot posts to a Slack channel saying "Hello World!". 'Nuff said.

Hello World!

3. ...but they're not humans

There's a strong perception that chatbots need to be gods of natural language processing able to answer all your questions and make sassy comments at the same time. Maybe Siri will learn that in 10 years but for now, there'a a lot of value that simple bots that aren't omnipotent. For example, the Toggl bot sends team members who have uncategorized hours a DM every week with a list of uncategorized tasks. However, it can't process messages like "Can you change the description of the task from last Tuesday?" - but it doesn't need to in order to provide value to the team. A bot is just a different type of UI - it's not AI.

4. Databases aren't that complicated

I've never worked with the traditional client -> server -> database architecture before. The server -> database part of the equation is a bit intimidating on the face of it. However, I found that setting up a PSQL database in Docker (for the local build) and AWS (for the production build) and configuring the application to work with it was incredibly easy. I just had to add a few simple annotations to the domain class

@Entity
@Table(name="toggluser")
class TogglUser{

    String apiKey
    String firstName
    String lastName
    String slackUsername
    String email

    @Column(unique=true)
    String slackID

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    long id

and the application automatically created this row in the table for me when I instantiated TogglUser and added it to TogglUserRepository:

PSQL is easy!

(secret variables obfuscated in the image)

5. Development environment is important

In the past, I've always had an obvious choice for my development environment. Web development? Sublime Text. Java? Eclipse. C#? Visual Studio. In this case, I was working in Groovy, a less popular language of which I didn't have deep knowledge. I started this internship coding in Visual Studio Code, commiting to Github and using the automatic deploys on Heroku to deploy to production for every single change (protip: don't do that). Then, I moved onto a Docker Container with a Postgres database but I was still in Visual Studio Code running ./gradlew bootrun. It wasn't bad - but I couldn't take advantage of niceties like breakpoints. Finally, I ended up in IntelliJ with a local and production build - which is where I should have started.

Moral of the story: spend time metacognating on how to approach a task. Your development environment will directly affect the ROI of all your future effort: it's worth taking the time to make sure that you get it right.

This has been a great summer - I'm glad I had the chance to make my own contribution to Spantree. The bot should be freely available on Github soon so keep an eye out for that!