Transform your resume into a cognitive bot

Instead of handing out a piece of paper with your resume to a prospective employer, wouldn’t it be cool if you could just point them to a URL, give them an SMS text number, a Facebook @address, or Skype address and tell them to “chat” with your bot to learn about you? They could ask your bot questions about you, your work history, your skills, your certifications, etc., it would parse them inquiries using natural language processing (instead of forcing them to enter pre-canned text), and then reply appropriately. With that in mind I set to work building one!

Bots and AI are the hottest things in the industry right now and I combined both of them into a way to showcase your resume. I decided to use Microsoft’s newly announced Bot Framework since it allows you to plug into multiple different channels instead of being locked into a single platform. You have a choice of Visual Studio with C# or Node.js as a development environment and I decided to go with Node.js since it seemed more lightweight and I am more familiar with Javascript. Incidentally Visual Studio Code is an excellent editor for Node.js and general Javascript development. It’s easy to get started, just create a new folder, and then run

npm init

npm install --save botbuilder

npm install --save restify

then create a file named server.js add the following 2 require statements for the modules

var restify = require('restify');
var builder = require('botbuilder');

When it came time to building the logic for the bot I didn’t want to search for text keywords or use regular expressions to figure out what the user is asking for so I decided to use Microsoft natural language processing service LUIS (Language Understanding Intelligence Service). LUIS works by allowing you to define intents and entities. In my case I defined intents for “Work Experience”, “Education”, “Strengths”, “Certifications”, etc. Then I trained LUIS by issuing utterances (phrases) and associating them with the correct intents until it had learned enough to make good predictions.

Screen Shot 2016-05-05 at 3.49.32 PM

Once you are satisfied, you publish your LUIS model and use the URL endpoint in your code to create a LuisDialog for interacting with the user. Basically in your code I simply emit a corresponding static text response when a user’s input matches an intent. For example, if LUIS determines that the user is asking about my current job title, I simply return that string of text like this:

// Create Luis Dialog
var dialog = new builder.LuisDialog('https://api.projectoxford.ai/luis/v1/application?id=________&subscription-key=________');

bot.add('/', dialog);

dialog.on('Title', builder.DialogAction.send('I am a senior software engineer as well as technial evangelist with IBM Analytics'));

If you need to perform more sophisticated interactions like asking the user to pick from a list of options then you can use methods in BotBuilder like a choice method. Alternatively if you need to perform a longer interaction you can use a waterfall by chaining multiple functions in the closure inside an array. The results of each function interaction can be passed to the subsequent function and stored in session variables. Each “dialog” is encapsulated inside Node.js routes that are added to the main bot variable using

bot.add('/order_pizza',function(session) {

//add your logic here

});

In my case I did not have complicated interactions so it required just a list of intent matches on the LuisDialog object. Finally you create a server object just like a regular Node.js application and listen to POST requests

// Setup Restify Server
var server = restify.createServer();
server.post('/api/messages', bot.verifyBotFramework(), bot.listen());

// Serve a static web page
server.get(/.*/, restify.serveStatic({
 'directory': '.',
 'default': 'index.html'
}));

server.listen(process.env.port || 3978, function () {
 console.log('%s listening to %s', server.name, server.url); 
});

Now you can run node server.js from your command line to test your bot. Microsoft provides a test harness called the Bot Framework Emulator that lets you test your functionality. Unfortunately it only runs in Windows. I tried the version of the emulator that runs in Mono on OS X and it would crash all the time so I recommend the Windows version (which is a GUI so it looks better too).

connector-getstarted-test-conversation-emulator

The emulator shows you the JSON message payloads so it can be very helpful when debugging. When you are happy with the functionality it’s time to deploy it. The easiest way is to push your project to your github then set it as the deployment destination for your Azure web site. Instructions to set up your Azure web site are found here. We still have to register our bot though with the bot framework using these instructions. When you register you will give it a name and point it at your bot which is hosted in Azure web sites. Once you are done registering you will get a default channel which is web. This allows us to embed a web chat client into our web page. Create an index.html file in your github repository for your bot and add the bot by clicking on “Get Bot embed codes” in your channels page. Open index.html in your browser and you should be able to chat with your bot! You can chat with my CV bot on my Azure website here. Ask it about me, my work experience, my skills, my strengths, certifications, etc. Bear in mind this is a proof of concept and has a limited corpus or intents and responses.

Screen Shot 2016-05-05 at 4.16.08 PM

In addition to being embedded in a web page, you can also add additional channels such as SMS, email, Facebook Messenger, Slack, and Skype. It is quite a hassle to configure Facebook Messenger, but once you do anyone on Facebook can start a conversation with your bot.

channels

You can also interact with my CV Bot over SMS (message me for the phone number, I don’t want to post it publicly).

sms

 

Or you can go to my Bot’s Facebook page and start messaging with it.

Screen Shot 2016-05-05 at 4.20.37 PM

I even created a Slack bot so the CV Bot can be invited to your Slack channels, not that it would make an interesting conversation partner!

slack

I hope that gives you a good idea of the utility of bots and how to enable them to understand natural language. Now it’s time for you to create your own! If you’re interested in how all the different moving parts interact with one another, this component diagram provides a high level overview.

Screen Shot 2016-05-07 at 12.00.28 PM

Disclaimer: This is a meant as a proof of concept and not a comprehensive bot nor does it offer a detailed representation of my resume. I’m not sure bots are a good interface for every interaction, but they are fun to experiment with.

 

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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