Quantcast
Channel: SurveyGizmo » How-To Articles
Viewing all articles
Browse latest Browse all 32

Order Up! (How We Hacked Our Survey API to Create a Food Ordering System)

$
0
0

The topic of this article is a bit off the well-beaten path for a survey tools blog. It just goes to show the cool and random things you can do with survey software that has an open survey API once you get to know it.

We don’t like to talk about ourselves this way, but survey software is really just a glorified web form with a backend. (I’m on vacation this week, so the sales team won’t be able to take revenge on me for saying that on our blog.)

What that means is if you are clever you can use our tool to solve a large number of office issues. The one I want to tell you about is what we call our “Order Up” system for Pancake Thursdays at SurveyGizmo.

Every Thursday we cook eggs, bacon, sausages, and pancakes (with chocolate chips in fun patterns) for the entire company. We started doing this recently, and given that there’s about fifty of us in the office now, the first time we had Pancake Thursday it took almost 6 hours to get everyone served! So the next Thursday morning we had an idea: we would send out a survey to get everyone’s order and create a simple widget using our API to show the orders as they come in. As an added bonus, it would notify each employee with an email once their order was ready!

We call it the “Order Up” system – and we can’t live without it.

The survey was pretty simple. We have just two survey questions: “What’s your email address?” and a checkbox question for what items from the menu you’d like to eat.

We also created a hidden field to flag if the order has been completed or not. The respondent never sees it – we flag it through the API when the order is ready for pickup.

We then used the survey API to create the cook’s screen. Michael is inevitably the cook each week (it was his idea). So he has a laptop set up in the kitchen which refreshes and shows him the orders as they come in. The Order Up Survey also tallies how many strips of bacon, eggs, etc that have been ordered in real-time so he can cook in bulk.

The entire system only took about an hour to set up, and it’s been a fun and easy way to make Pancake Thursdays work and get it down to only two hours of cooking. (Not to mention we’ve been hiring…so there’s that).

I mention this just as a suggestion to everyone — keep your eyes open for neat ways that a data collection tool can be used to optimize all the little internal processes at your company. If you have an idea or have an unconventional way you’re using our survey software in your company, let us know!

If you are curious, here’s the (very dirty) PHP code that we used to build the order-up dashboard! Passwords and SurveyIDs have been changed to protect the innocent (and our pancake orders).

//----  start code (don't judge us on code style)


function makeapicall($url)
{
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
		curl_setopt($ch, CURLOPT_VERBOSE, 0);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_POST, 0);
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		$buffer = curl_exec($ch);

		if ($buffer === false) {
			return false;
		}
		curl_close($ch);
 	
 	return unserialize($buffer);
    
}

if(isset($_GET['orderup']))
{
	$uri = "http://restapi.surveygizmo.com/head/Survey/555555/SurveyResponse/{$_GET['orderup']}.pson?_method=POST&user:pass=hehe@acme.com:12345&data[4]=Yes";
	$results = makecall($uri);
	
}

//get orders

$uri = "http://restapi.surveygizmo.com/head/Survey/555555/SurveyResponse.pson?user:pass=hehe@acme.com:12345&filter[field][0]=status&filter[operator][0]==&filter[value][0]=Complete&limit=500";

$results = makecall($uri);
$orders = array();
$orderups = array();


foreach($results["data"] as $result)
{
	if($result['status'] != 'Complete')continue;
	
	if($result["[question(4)]"] == "Yes")
	{
		if($result['id'] == $_GET['orderup'])
		{
			mail($result["[question(2)]"],"Your Pancake Thursday order is ready!","Come and Get it!!!!",null,"-fchristian@sgizmo.com");
		}
		$orderups[] = $result;
	}
	else
	{
		$orders[] = $result;
	}
}

Photo courtesy of Andrew Currie – Flickr, Creative Commons (Attribution)


Viewing all articles
Browse latest Browse all 32

Trending Articles