How an SMS Application Took a Job (i.e. Task)

David Pitt Conversational Apps, JavaScript, Keyhole Creations Leave a Comment

This blog is about a human’s job being replaced by automation. But, before you start composing emails and social media responses, know that it’s a job that I think most folks would gladly allow an automated mechanism to take over.

The “job” discussed in this blog is the need to contact individual users (in this case, employees) when those users forgot to accomplish a required task.

In this blog, we discuss a conversational application solution used internally at Keyhole Software for automated SMS text messaging features surrounding time tracking. The solution, implemented with conversational application platform KHS {Convo}, allowed for time entries to be submitted via text and automated, schedule-based notifications.

The Need

Here at Keyhole, we earn income by providing our clients with software development services. We help clients in a number of ways; providing developers for project plans, isolated software development projects, and pure-play consulting and training. Our employees track and report all hours worked on a weekly basis so that they can be fairly compensated for every hour that they work.

It’s the role of our accounting department to make sure time is entered and billed properly. Since many of our consultants work daily on client sites or on a remote basis, invariably folks forget or may not be at a location where they have access to our computer-based time tracking system. When timesheets aren’t submitted by the weekly deadline, polite phone calls and emails are sent out to folks reminding them to enter their time.

If someone can’t get their time entered, we can work through it due to the size of Keyhole. (Though it does still delay accounting.) However, in large corporations, delays can gum up the works which can lead to a stressful situation for the person doing the “Please enter your timesheet” notifications.

Requirements

There are two overarching takeaways with this situation, and we know we’re not the only company with these requirements:

  • Employees must create & submit timesheets to include their weekly hours.
  • Timesheets needed to be submitted to our accounting department by a set deadline.

We sought to find a novel way for our employees to submit timesheets quickly and conveniently when they didn’t necessarily have access to our web-based time tracking system.

Building a native mobile application was our first thought, of course, as we have built many for clients. But, there are only so many apps user can have installed on their devices.

Conversational applications have appealed to us lately, as we built KHS {Convo}. There is no need to install or download apps, or pop open a browser and type in a URL; with a SMS conversation application you can just have a conversation through your texting app. Bonus: no need for user training, application downloading, or application updating.

See Also:  Improving Performance in React Applications

Enter KHS {Convo}

We used the KHS {Convo} conversational SMS platform to help remedy these manual tasks and provide a convenient utility for timesheet entering,

Our internal timesheet system has APIs that drive the SPA/JavaScript user interface. The KHS {Convo} application uses these APIs to create an SMS application utility.

We used the KHS {Convo} Node-based middleware (which is newly open sourced, by the way), to allow users to add their timesheet via SMS conversation.

Adding A Timesheet

Employees can text “Add” to our Twilio-based phone number. It uses Twilio SMS Services to route to our KHS {Convo} instance.

The incoming number is checked against a list of registered phone numbers to ensure it is from an employee phone. The employee ID is looked up. The conversation goes like this:

The employee texts “Add”….

The employee can text “N” for a new Entry or “P” for the latest previous entry.

The employee can confirm the entry for current day. Alternatively, they can change Client, Hours, or Day, and then enter notes for the time.

The entry will be confirmed and the employee can choose to enter another timesheet.

Event Module State Definition

The best part is that the KHS {Convo} conversational platform makes it easy to create this type of SMS-based interaction.

Here is the event module state definition for the timesheet SMS conversation.

….
module.exports = function (events) {

    var event = {};

    event.states = [
        {reply: "Handle timesheet / add call and start the flow.", desc: '0', transition: begin, state: 'begin'},
        {reply: getNewOrPrevious, desc: '1', transition: newOrPrevious, state: 'newOrPrevious'},
        {reply: getClientList, desc: '2', transition: newClient, state: 'newClient' },
        {reply: getDay, desc: '3', transition: newDay, state: 'newDay'},
        {reply: getHours, desc: '4', transition: newHours, state: 'newHours'},
        
        {reply: getLatestTimeEntry, desc: '5', transition: changePreviousEntries, state: 'changePreviousEntries'},
        {reply: getHours, desc: '6', transition: changeHours, state: 'changeHours'},
        {reply: getClientList, desc: '7', transition: changeClient, state: 'changeClient'},
        {reply: getDay, desc: '8', transition: changeDay, state: 'changeDay'},

        {reply: getNotes, desc: '9', transition: newNotes, state: 'newNotes'},
        {reply: addTimesheet, desc: '10', state: 'addTimesheet'},
        {reply: emailError, desc: 'Email Error', state: 'emailError'}
    ];

    event.isAuth = false;
    event.description = "Timesheet Entry";
    event.threash = 10;

    event.words = [{
        word: 'timesheet',
        value: 10
    }, {
        word: 'add',
        value: 5
    }]

    event.run = function (request) {
        return new Promise(function (resolve, reject) {
             return resolve(StateService.doStates(event, request));
         });
     }
….

The entire conversation is implemented in a single module. All API interaction with the timesheet system is defined in the function calls, defined in the state object.

See Also:  One Router to Rule Them All: React Router

KHS {Convo} uses Node.js for the server-side implementation and React for an administrative dashboard implementation. Here’s a link to the project on open source project on Github:

https://github.com/in-the-keyhole/khs-convo

It has a lot of features with many easy-to-use examples. Check it out, it’s free to use.

Schedule-based Notification Bot

KHS {Convo} also has a schedule-based notification system that allows messages via SMS, email, or Slack to be sent to users on a particular schedule.

Here’s a picture of the Notification UI where a scheduled notification can be defined.

Time events can also be defined with JavaScript modules. KHS {Convo} will upload and execute these events based upon the interval scheduled in the module.

Here’s an example Hello World event that will execute forever on an 8-minute interval.

'use strict';

var log4js = require('log4js');
var logger = log4js.getDefaultLogger();

module.exports = {
    config: { 
        timerName: 'Hello World Timer',
        callbackDelay: 8000,
        callbackMaxRun: 0
    },

    process: function() {
        logger.info('   helloworld.process() called');
        module.exports.sayHello();
    },

    sayHello: function() {
        logger.info('   helloworld.sayHello()');
    }
}

You can see and run this example in the Github repository.

We use this capability to ping employees with an SMS text message when their timesheet is due. This eliminates the need for our accounting employees to have to do this. This is the task that they no longer have to perform manually.

Final Thoughts

So while we didn’t eliminate an entire job role, we gave a job task to our KHS {Convo} platform. Our accounting folks are pretty excited.

SMS (Short Message Service) is a ubiquitous feature of mobile phones. Virtually everyone knows how to use and access SMS. It’s a great way to easily provide value-added features to mobile applications — without having to build and deploy code to application stores, have users install apps, or keep them updated. They simply have to text.

Check out this blog for a deeper dive into using SMS text messaging in conversational applications.

What Do You Think?