Using azk, ngrok and containers to test webhooks


Webhooks are awesome.

While I was working at SendGrid, most of the API demos I and the other evangelists did involved using webhooks. For example, I had a GIF demo (GIFs are also awesome), my co-worker Yamil had a Pokémon demo, and both of them used SendGrid's Parse Webhook.

These demos were really fun to do as they involve participation from the audience, but running them usually takes a little bit of work. If you wanted to try and run the demo yourself for example, you'd have to go to my demo's github repository and then:

That's a few steps, and that's also considering the user has installed whatever node/Ruby/Python version your application is using. So, I decided to grab a few of these demos and add azk to it, to show how it can help new users set up a project and also make sure it's gonna run in their machines. (no more "but it works on my machine!")


If you don't have azk installed, head here first: http://docs.azk.io/en/index.html


I wrote a little bit about azk in my previous post, but basically it's an open-source CLI tool that you can use to easily orchestrate development environments in your machine. It uses VirtualBox and Docker under the hood, and it gives you a simple JS file to describe what kind of systems you need (node 0.10, Ruby 2.3, redis, MongoDB) and how they connect to each other. Here's a quick GIF showing it running:

You can check out a SendGrid Giphy demo, a SendGrid Pokémon demo, a Twilio-Giphy MMS demo, or a Twitter demo that I modified to use azk. (Thanks to Yamil, Greg and Andy for those). They should be as simple to run as:

Two of them use node, and the other two use Ruby, but you won't need them installed in your machine to run it. ☺ After that, you should see an output similar to this in your terminal:

To access the project, just open the URLs you see in your terminal output. For the example above

After that you can easily set up a webhook (SendGrid/Twilio/Twitter) by pointing it to your POST route and using ngrok's URL!

The steps I had to follow with the projects (and which you might use to add azk to your projects) were usually:

  1. Running azk init to create an Azkfile.js
  2. Opening Azkfile.js and making sure I had the correct version of the language/framework (for example, node:010)
  3. Changing the project setup to use the environment variable HTTP_PORT instead of PORT.
  4. Adding any extra systems, like Redis, or ngrok.

I found that this was a good way to easily set up a project, run it together with ngrok, and test out webhooks. What do you think? ☺