Hi everyone! I’m Dan, a software engineer at Interlay. I decided to share our Typeform API use case at Nicolas Grenie’s suggestion, in the hope others might find it useful.
Background
Interlay’s goal is to allow Bitcoin users to invest, earn and pay with BTC on any blockchain. We’re currently trying to launch a Bitcoin bridge to the Polkadot ecosystem, which entails having our community temporarily lock funds into a “crowdloan”. Due to technical reasons, there is only a limited number of projects that can launch Polkadot. An auction system is used to determine who gets to go live: each available Polkadot slot is won (temporarily leased) by the project that locks the most funds.
Since we’re asking our community to lock funds into our crowdloan for two years, we want to encourage them to first read up on our product. Decentralized Finance, being unregulated, tends to attract lots of scams which we’re trying to protect our users from. To achieve that, we started to focus on creating educational content - and endeavour the community helped us greatly in, having shared lots of beautifully designed infographics and videos on their social media.
How Typeform fits in
In trying to incentivize crowdloan contributors to read up on Interlay before contributing, we’ve set up a Typeform Quiz that evaluates essential knowledge. Besides the base rewards our contributors receive, we offer a bonus to those who also successfully answer all quiz questions. Users can retry the quiz as many times as they like until they get it right, the point of it is learning. The quiz is also a starting point for those who are interested in our product but don’t find the motivation to read up on it. Once you open up the documentation to answer questions, it’s much easier to keep browsing through it.
Why Typeform?
Besides having a beautifully designed UX, the Responses API allows to check who completed the form in real time. This is crucial to our Crowdloan website UX flow, where users scroll from the quiz to the actual contribution section in a matter of minutes. By the time users actually contribute, the data pertaining to their Typeform entry must be already updated, so users can see that we validated their quiz bonus.
The Architecture
Since our time budget was very tight, we wanted the solution that offers the best trade-off between implementation time and data “freshness”. We created a Node.js stateless service that pings the Typeform Responses API every minute to see if new responses were recorded. The data is stored in-memory, so service maintenance and scalability are not a problem. The service fetches all new responses since the last response read (see code here), and only requests the two relevant response columns. This means that memory requirements are low, and once started and “synced”, the service is very fast to respond to queries.
Next Steps
The obvious extension is to have the Webhooks API push data to our service, which would update quiz participation data instantly. I stopped at the Responses API because of a lack of time, but since I now have a Typeform setup that works, it will be much easier to extend this skeleton next time.
Most of our code is open source, so feel free to take a look and use it for your own projects. Feedback is appreciated!
Looking forward to suggestions or thoughts, thanks!