• quiz webhook

Quiz webhook – send data and leads to any software

2018-11-27T16:08:21+00:00Lead generation|
3 min read

We built Riddle to easily connect with any marketing software or CRM tool. Our new quiz webhook joins our existing range of data connection options, from using Zapier to native integrations with AWeber and MailChimp (with more coming!).

The use cases are endless. You can auto segment leads based on their responses, automatically send data to your marketing software for instant email follow ups, and a million more.

Quiz webhook: the essentials

Now we are going to get your inner geek going at full speed and show you how to write your own quiz webhook with just a few lines of PHP.

To get started, it would be good if you have:

  • a good understanding of PHP
  • a bit of knowledge about JSON
  • your own server or a cool place where you can upload a PHP file that is reachable on the web
  • a Riddle Pro or Enterprise account or a free 14 day trial account with all features unlocked

Quiz webhook: getting started

  1. Right, first off – create any Riddle quiz, poll, or other content.
  2. Include a lead gen form using Riddle’s lead form builder.
  3. Go to the integrations tab on the create screen.
  4. Here you paste the URL of the page where your personal webhook code will run. (Something like: http://mydomain.com/riddle_is_awesome.php
  5. Save and publish the Riddle and run through it one time, filling out the form to make sure it all works.
  6. Then create a php file with this tiny bit of code:
 $data = file_get_contents('php://input');
 $req_dump = print_r(json_decode($data), true);
 file_put_contents( 'request.log', $req_dump );


This is the output in the request.log file generated by the code above:

JSON grab from Webhook

As you can see in the image on the right, Riddle’s quiz webhook sends you all data as a nicely formatted JSON string via POST.

All you need to do is grab that POST JSON and process it as you like.

Want to see what quiz data is sent via our quiz webhook?

Check out this nifty site (https://webhook.site)

We used it to generate this code for this sample quiz about San Francisco: https://www.riddle.com/showcase/173491/quiz

Webhook data:

{“riddle”:{“id”:”173491″,”title”:”[COPY] San Francisco: The Locals’ Challenge”,”type”:”quiz”},”lead2″:{“Name”:{“type”:”text”},”Email”:{“type”:”email”},”#222388: Short text”:{“type”:”text”},”#553264: Dropdown”:{“type”:”select”},”#571749: Newsletter_agree”:{“type”:”checkbox”},”#759039: Date picker”:{“value”:”2018-11-25T18:28:30.373Z”,”type”:”datepicker”},”#1037919: Form intro”:{“value”:”<p><span class=\”ql-size-huge\”>Sign up to win two free tickets to visit San Francisco! :airplane::city_sunrise::beach_with_umbrella:</span></p>”,”type”:”intro”},”undefined”:{“type”:””}},”answers”:[{“question”:”What’s the easiest way to annoy the locals?”,”answer”:”Calling San Francisco… ‘Frisco'”,”correct”:”1″,”questionId”:”0″,”answerId”:”2″},{“question”:”What’s the dress code for a big night out?”,”answer”:”A \”I Love SF\” hoodie”,”correct”:”0″,”questionId”:”1″,”answerId”:”3″},{“question”:”Where’s the roughest part of town?”,”answer”:”The Tenderloin”,”correct”:”1″,”questionId”:”2″,”answerId”:”1″},{“question”:”Where you can most often find the ‘Tamale Lady’ for an awesome late night bite?”,”answer”:”Zeitgeist (in the Mission)”,”correct”:”1″,”questionId”:”3″,”answerId”:”2″},{“question”:”What’s the nickname for the fans of the local football team?”,”answer”:”The Fog Bank”,”correct”:”0″,”questionId”:”4″,”answerId”:”1″},{“question”:”What tourist attraction will locals only visit under duress?”,”answer”:”Ferry Building”,”correct”:”1″,”questionId”:”5″,”answerId”:”0″},{“question”:”Best local race?”,”answer”:”Mission to Market Street fun run”,”correct”:”0″,”questionId”:”8″,”answerId”:”1″},{“question”:”What color should you never, ever wear to a Giants game?”,”answer”:”Oakland A’s green”,”correct”:”0″,”questionId”:”7″,”answerId”:”1″}],”result”:”4″,”resultData”:{“scoreNumber”:”4″,”resultIndex”:”4″,”scorePercentage”:”50″,”scoreText”:”Your score: 4/8″,”title”:”You’re from the ‘burbs”,”description”:”Hey there – you’re definitely no tourist, and have even been to SF enough to know your way around. But we can tell you don’t live in the city, and can stand to brush up on a few things. Only one thing to do – pick up sticks and move to our little pocket of paradise!”,”resultId”:”1″},”embed”:{“parentLocation”:”https://www.riddle.com/showcase/173491/quiz”}}

Quiz webhook: wrapping things up

The sky is the limit of where you can go from here. You can write your own code to:

  • push the Riddle data to a CRM of your choice
  • write it all into your own database
  • build your own personal Riddle dashboard
  • and dozens of other use cases

Need help or custom code? Reach out to us via hello@riddle.com and we’re happy to help. Basic questions are easy and free – but we’re also available for hire to write your own webhook if you don’t have the code background).

The code above is just a starting point. Use this improved PHP code to process the data sent through to your hook if you know your way around PHP (as you will see below, this code is just a starting point. It does not really do anything with the data yet)

Don't know where to start coding your own Riddle script or quiz webhook?

No worries, we got you covered.

Check out our Github repository for cool sample scripts.

This website uses cookies and third party services. Ok