The days of carrying around house keys are numbered. Rejoice! In this tutorial, we’re going to walk you through how to build a connected home lock with a couple really cool APIs — Typeform API and PubNub Functions. By the end, we’ll have an Envoy-style login form that houseguests can use to check into a business or residence.
We’ll also explain how our sample model house was built and how we used an Arduino Yun to power servo motors that open and close the front door. Lastly, we will discuss how we used the Slack API for authentication on whether the door should be open or closed.
Have you ever been to a business and seen one of these kiosks asking you to sign in?
The goal of this tutorial is to showcase how you can use both Typeform and PubNub Functions to create a simple IoT door lock. To see the process on how we created the model house, check out this blog post.
Typeform is free to try to out, and allows you to create beautiful looking form interfaces that you can customize for your application. Below is what the user would see on the kiosk on the front door of a business or home.
Once the user clicks the Start button, they have to fill out a variety of information that we setup in the Typeform dashboard.
When the user fills out the entire form, and click the submit button, a REST API call is made to a PubNub Function which is coded below. The PubNub Function is using the OnRequest event type to listen for an event from Typeform.
Once the form has been submitted, the PubNub Function sends the information filled out in the form, and sends it over to Slack’s API. We use a web-hook to ping Slack and send a message to the users in the Slack Channel that someone is at the front door.
To learn more about how to create your own Slack Incoming webhook, check out the documentation here. In order for the front door to open, a user in the Slack channel has to click the Yes button.
Once a user in the Slack channel clicks YES, Slack will send a message to an addition PubNub function. If the action.name of the request is equal to open_door, the PubNub Function will send a message to the pubnub_iot_house channel telling the IoT house to open the front door. Additionally, the code will send a response to Slack to display to the user that the door has been opened.
The front door is now open on the IoT house once Yes was clicked on Slack!
It’s really that easy to setup a fully working IoT demo with Typeform, PubNub Functions and Slack. Make sure to go register for a Typeform account so you can start implementing custom forms in your application. If you have any questions about this demo, contact [email protected].
Originally published at www.pubnub.com.