A Little Webhook Can Go a Long Way

The following is a guest post from Larry Silverman, CTO, EVP, and Co-founder of TrackAbout. TrackAbout wrote an open source service using SendGrid’s event webhook to relay email delivery failure events to a HipChat chat room. Learn more about Larry and TrackAbout at the bottom of this post.

How TrackAbout Uses Email and Why We Chose SendGrid

Our web applications, like most, send email. They send email to employees at TrackAbout, to our users, and to people of our users’ choosing.

Getting email delivered is significantly harder than most would think, largely because you have zero control over the whims of the receiving email server. One ill-configured, over-zealous “network security device” on the other end and your email gets eaten and your IP address lands on some global blacklist, impacting deliverability to all your other customers.

About a year and a half ago, we decided to outsource the sending of email to someone who was doing it right, SendGrid. Prior, we’d been sending email through a basic SMTP mailer service. It provided little visibility into drops and bounces and did nothing to help us understand if we were on blacklists. It also wouldn’t DKIM sign our email, which is an important ingredient in ensuring successful delivery. We could have built up capabilities around our existing SMTP service or chosen a new email server, but we’re not in the business of writing email tools or managing email servers. SendGrid is.

It was very simple to switch to using SendGrid. We just changed our application configuration to send mail to a different SMTP endpoint.

Even with SendGrid, the mail doesn’t always get through. When it fails, SendGrid gives us some really nice reports to determine the cause of various kinds of failures like bounces and blocks. Often, a user has fat-fingered an email address, and it’s just not routable. That mail will never get there.

We recently had a situation where an employee of TrackAbout configured a demo instance with a fake but routable email address, which caused us to send gobs of email to an unsuspecting company, to a user/mailbox that doesn’t exist. It’s a great way to get blacklisted for bad behavior. I don’t recommend it.

We’ve also had users set up email alerts in our application that trigger based on some event happening with their tracked assets. When the intended target leaves their company, the email starts to fail. Again, pounding an innocent mail server can get you blacklisted.

Having a member of our Support staff monitor SendGrid reports is one way to stay on top of these kinds of email failures. But a push notification system would be much nicer.

How We Used SendGrid’s Webhook and HipChat to Notify Us Of Email Delivery Failures

We learned that SendGrid, in addition to having a comprehensive REST-based web API, has this wonderful feature called a “webhook.” The gist is that you can make SendGrid call a URL of your choosing when email is processed, dropped, deferred, delivered, bounced, clicked, opened, unsubscribed from, or marked as spam.

We use Atlassian’s HipChat as our chat room solution at TrackAbout and we love it. We’re in there all day. How nice would it be to get notified in HipChat when mail delivery fails? Very nice indeed.

What we wanted was a lightweight service to receive webhook calls from SendGrid and transform the posted data into a HipChat message to a particular chat room. There are some nifty companies out there that hook various cloud services together. The two big ones I’ve come across are If This Then That (IFTTT) and Zapier. Neither supported the exact scenario we wanted, and besides, this isn’t a terribly hard problem to solve by rolling your own. So we did.

It took us about a day’s worth of effort to create a webhook listener using Node.js and the Node Express framework. We deployed the code to Heroku from GitHub and we’ve open sourced the solution using an MIT license here:

(We make no representations or warranties regarding this code. It works for us. Use it, fork it, pull requests are welcome.)

Today we have a member of the Support team monitoring our HipChat room for email issues. We’re tackling mail events as they arise instead of being surprised by them hours after the fact. In addition, we plan to integrate this webhook listening service into our trouble ticketing system so we can improve traceability of handled issues.

Thanks to SendGrid for providing such a great API and specifically, webhooks. Every SaaS company should think about adding webhooks to improve their offering.

Larry Silverman is the Chief Technology Officer, Executive Vice-President and Co-founder of TrackAbout. TrackAbout is a software-as-a-service solution that tracks, manages, maintains and optionally rents portable physical assets. TrackAbout’s customers have huge investments in their assets and TrackAbout helps them maximize the utilization of those assets at every stage of their lifecycle. TrackAbout got its start in a niche vertical market called packaged gas distribution and has expanded into other markets such as home and durable medical equipment. For more information, visit trackabout.com.