Candy Strips and Graph Traversals

March 11, 2013 / Posted By: wotio team

Bipio lets you create cheap dynamic endpoints quickly and have them perform some complex task, so when our LaunchRock page failed after a recent account migration (they were super helpful in debugging, no love lost) it seemed like a perfect opportunity to build a similar email capture widget using the toolset already baked into our API. Time to Eat Our Own Dogfood, as it were, as a simple exercise I could fit into a saturday morning between breakfast coffee and brunch coffee. Great!

The requirements for the widget were, at their core, very simple - for every user that arrived at the home page, I wanted to create a temporary, single use endpoint which took an email address, passed it to a data store and sent a thankyou message. Maybe later I can render this syndication into excel files containing batches of 100 leads for onboarding (because we can), but for now, just keep it simple. Don’t want to be late for brunch. Enter the Candy Strip. It’s a little dynamic call to action widget that you can find on our home page, and it took all of 30 minutes to set up. Fun Fact : Although the website itself is a blocking architecture PHP/Zend stack, creating these endpoints takes ~10ms across our DMZ to the API, a barely noticeable hit to application performance and we get a bunch of functionality that can be easily extended at no cost to application complexity.

So, we can create these endpoints right out of the box with HTTP Bips, with all the normal characteristics of a Bip including temporary lifespan, authentication scheme, dynamic naming and a predictable data export. To have that bip send an email and store some data, I just need to create a simple Hub (graph) with two channels (vertices) which are to send a transactional Email (email.transaction), and list email addresses to a List Syndication (syndication.list).

To create the syndication, just POST /rest/channel a little packet pointing at the Syndication Pods ‘list’ action. The list action is perfect because it gives me the option to render everything we’ve received to a CSV, TSV or Excel file down the track. Channels are re-usable across Hubs, so this Channel could now act as a datasource for a different hub sitting outside this email capture workflow if I don’t want to add more actions to the pipeline.

{ "config": { "write
mode": "append" }, "action": "syndication.list", "name": "Signup Reservation List" }
Done! The data store gets created, and every line item we get in this list is appended to the store

Just black holing content into a syndication isn’t very useful, so I wanted to send an email to the early adopter thanking them for their interest. I used the email template we already had for LaunchRock so didn’t have to don my Marketing Hat before lunchtime. Bonus, only 10 minutes in so far!

{ "action": "email.transaction", "config": { "template": "betaregistered", "from": "Bipio Signups ", "subject": "A quick update about your beta invite" } "name": "Email Capture Receipt" }

email.transaction is a special Email Pod action we have for sending pre-baked transactional messages, you won’t find them in the API just yet, sorry!

We now have two Channels for processing the capture, so in the website controller code, I’ll just make a call out to the API when the page renders and assemble these Channels onto a Hub with a POST /rest/bip. The name of the bip matches the session id in our application, they’re single use or naturally expire after a day. Together between the size of our capture syndication, and the number of created http bips, I can also figure out a rough conversion rate. The ‘
repr’ attribute in the POST /rest/bip response payload tells the widget which endpoint URI to send the email address to in our eventual AJAX request. _repr means the string representation of the object, all REST resources in Bipio have this decorator, harking back to the systems Tornado roots.

If I hit the website, I see a new HTTP bip in the ‘’ account dashboard whose name matches my session id, so its working. The graph for my temporary bip renders like so :


Now to expose the widget in the view and slap it some lipstick courtesy of cameo & ycc2106 @ colourlovers :



And we’re done :)