It’s every entrepreneur’s dream to set up a firm of her own. But there are lot of hurdles to it. We require an office space, authentication system for the office and so on. It would have been great if you could cut down something from this huge list of necessities to reduce the overall expense. One thing that you could do is to build an authentication system by yourself which is very economical and that too employing the technology you love the most. Yes, you are right, with nothing other than Salesforce. Let’s see how we can build an employee check-in system with Tessel and Salesforce.

I want to build this! What do I need?

For building an authentication system of your own, all that you would require are –

What’s this Tessel?

Tessel is a microcontroller and I call it a next-gen prototyping board. Now say the RaspberryPi, it is like your motherboard but in the size of a credit card but that’s not what a Tessel is. It’s a microcontroller and not a microprocessor. Every prototyping board understands a language that you would use to tell what it needs to do, how it needs to interact and so on. In case of Tessel it understands Node.js. That’s one good aspect about Tessel. Think of Node.js like your JavaScript on steroids. You are not really learning anything new here. Another very good aspect about the Tessel 2 is that it has an on-board Wi-Fi and this is very helpful. It’s very reliable too. In case of RaspberryPi you would have to run to find a good Wi-Fi Adapter to connect to the Internet or you would have to resort to a LAN. And wait that’s not it. With Tessel 2, you have lot of plug and play modules.


How it works ?

We have a 4 x 4 Membrane type Keypad connected to the Tessel. Say you pressed the keys 1014*. This will be interpreted by the Tessel. Tessel waits and scans all the keys that you pressed until it encounters a * or a #. Now if it ends with a * it’s basically a check-in and if it’s a # then it’s a check-out. Once when we have the key sequences scanned completely, it makes a GET request to a set of custom Apex REST Services. Now if it’s ending with a * then that means we are doing a check-in and the Apex REST Service upon receiving the request creates a record with the current date/time stamped on the check-in time field. If it happens to be a # then that means, we are doing a check-out. The Apex REST Service would spot the recently logged check-in record and update the checkout time with the current date/time.



How do I setup my SF Account ?

Back in Salesforce it’s all very simple. We just have 2 Custom Objects and an Apex REST Service that will be invoked from the Tessel. These Apex REST Services are then made public via Sites.

I have named the Custom Objects as Employee and Checkin History. The Employee object will hold all the Employees Names and their Ids. The Checkin History object will hold the check-in/checkout date/time. The Checkin History object contains a Master-Detail relationship to the Employee object. This means that it’s the child of the Employee object. It also contains two Date/Time fields Checkin Time and Checkout Time to hold the check-in and checkout time respectively.


Back in my Apex code, I have an inner class called Response which has member variables status, message and statusCode to hold the status and message of the Http requests.

I then have a HttpGet method called ‘authenticate’ which would receive the keys entered by the employee as URL Parameters from the Tessel and interprets them. And if a * is encountered, it calls the check-in method and if a # is encountered, it calls the checkout method.

The checkin method which is private, receives the Employee Id and the check-in time as parameters. It queries for the Employee record with respect to the Employee Id received as the parameter. Once when we get the record, it then creates a new Checkin History record with the check-in time received as the parameter related to the queried Employee record. And once this is done, it returns a response with TRUE status. If it receives an invalid Employee Id in the parameter, then it returns a FALSE with a message saying ‘Invalid Employee Id’.

Now in the checkout method which is also defined as a private method, receives the Employee Id and the checkout time as the parameters. Just like before, it then queries for Employee record with respect to the Employee Id received as the parameter. Once when we get the record, we query for the Checkin History record in which the checkout time is NULL, the Employee field is related to the queried Employee record and the one in which the check-in date is of today. Once when we get the Checkin History record, we update the Checkout time with the checkout time that we received in the parameter. And if that was done successfully, we return a TRUE status. And if we received an invalid Employee Id in the parameter, then it returns a FALSE with a message saying ‘Invalid Employee Id’.

Have a peek at the Apex Code right below:

I then exposed my HttpGet method as an Apex REST Service which will generate a REST Endpoint and then I made it public via Sites in order to make a request to it from outside of Salesforce without any authentication.

How do I configure my Tessel 2?

Before you head further below, I would recommend you to configure the Tessel by reading through this getting started link –

The Tessel uses basic HTTP Requests to communicate with Salesforce. At first, I have referenced 3 libraries – ‘Tessel’ to interact with the Tessel device, ‘Request’ to make the GET Requests to Apex REST Services and the ‘Tessel Async Matrix Keypad’ to interface the keypad with the Tessel.

You can download the NPM libraries in the following link:

I then specified the keys available on my Membrane Keypad and I also specified the pins that I have used to connect the same to my Tessel. Now for the working, I have bound a function to the keyup event. In that, I am logging a message on to the console whenever a key has been pressed. Then I collect all the keys pressed by the user and whenever I encounter a * or #, I make a GET request to the Apex REST Service which I have made public via the Sites. On a success, I will blink the LED for like 3 seconds. That’s it.

Here is the Node JS code:

Can you show me how it works ?


What’s next that you can expect?

What I demoed here was a simple implementation. But you can really get creative. The very good thing about Tessel is the different plug and play modules that it offers. One such module is a RFID Card Reader. With that you can setup a fully fool proof authentication system for your office or maybe use CloudBit to do something more creative on a successful login.

This project was presented at JDF’17 and here is the link to the slides that was used for the session –


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s