Stop Bugging Me: My life Hack Continues

It has been nearly a month now since I first started my journey and I thought it was time for some reflection on my progress or lack there of (if you would like to skip all this and go down to my summary of what is working go for it). It is an interesting journey that has seen some ups and some downs to be sure but it is mostly positive. Just making a cold turkey change and ignoring all my distractions was a stupid thought I had. I gave up smoking that way but this is far more challenging. Its more akin to getting back into physically working out than giving up smoking.

The Mental Workout

I spent a number of years in the military as a much younger me where I was very physically active. I competed in triathlons, cycled competitively at least at a club level and worked out generally around 12-14 hours a week. I kept a workout journal so I know this is pretty accurate. This matched my military role where I was a electronics technician. Keeping fit is expected and encouraged. I managed to maintain that for a number of years after leaving the service but over time it dwindled. Now I probably do somewhere in the range of 3 hours a week, not including walking for golf etc. Could I go back to 12 hours a week, probably. But it's not something I could do rapidly. It would take time to build up to that level especially with any intensity. (Funny side note at the time I followed a training program put together by disgraced cyclist Lance Armstrong to build up to my 12 hours a week minus the performance enhancing substances. Ah memories.)

Why is this important? It is the same sort of buildup that I am realizing that I need for my mental work outs/focus/deep work (you choose the term). Short bursts of focus or long bursts of focus only provide marginal productivity if I slide back into my old habits which I find myself doing. Its a constant struggle of self-correction. I have been doing a lot of reading on various techniques to improve though and one which seems to be helping me is writing. Writing this blog, writing notes while reading material, writing down ideas etc. seems to be helping build focus. It is such a great creative outlet I really forgot what it can do for me.

Evolving Life Style Challenges

No screen Sundays as I have termed it have been a great success. I am rededicating myself to activities I had pretty much halted like gardening. I really look forward to Sundays and planning what I am going to do now. Whereas before it was nothing special. I think it has helped me feel more refreshed as well for the upcoming week.

Using Alex to wake me, remind me of upcoming meetings and also track my focus period lengths has proven to be very useful. Right now 35 minutes is optimal for focus periods before giving in to the distractions. Who knew 35 minutes could be so long. While I celebrate the 35 minutes which is a 15- minute improvement from my original 20, it's still pathetic. This needs to be much higher with back to back focus sessions. I am incrementally moving the needle 5 minutes at a time and its working. I recently read an interesting post by Cal Newport's Study hacks blog on taking deep breaks, something else I am looking at incorporating into how I extend my focus.

Having a variety of reading material on hand has been very helpful. I have a pretty good selection of reading material and am reading around 4 different books at the same time. I slip focus sessions in between meetings on different material as often as I can. I find studying a broad set of topics is keeping me more motivated than just focusing on one. This may be in part because of how I have previously managed my time. I do find activities such as building a new bot where I can stay focused for hours which is great but that is not going to expand my base knowledge to enjoy greater success.

My mind still wonders but I am finding it easier to pull it back on track. Seems like this has been my whole existence throughout my life I just didn't realize it. I have read a lot of different material on why things bore us. I have come down to two reasons for myself. One which comes from my reading is not challenging the creative side of our minds, obvious. Secondly is my own theory of, am I really bored by the material or task or has a distracted life style persuaded me to think anything that takes extended concentration as boring. Classifying it as boring makes it easy for me to justify not doing it and continue the skimming the web lifestyle. Truly challenging your intellect becomes a tiresome task which is easy to classify as boring. Producing something worthwhile also takes time and focus. It would be easy for me not to triple read my blog post for errors but no one wants to read something carelessly put together (I really had to make sure that there were no errors in that last sentence, it could have been super embarrasing (yes the spelling mistake in embarrassing was on purpose, it is a joke (please don't point out other errors in this post I am a work in progress ( fuck, I am lost in all my brackets)))) .

I found the biggest hurdle to overcoming the boredom challenge is finding where to start. So many of us feel overwhelmed by the volume of a topic that it's so hard to find where to start you just don't start at all. Funny thing is its not until you engross yourself in the environment that you find the right paths to follow. It is okay to not know where to start. Its the acting of beginning the endeavor that will lead you along to find the right path. BTW the person that said follow your passion is full of horse shit. No one ever got their dream job because of passion. Most people don't even know what their dream job is untill they are in it and are experts at said job.

Things I Need to Change

Planned focus time on the morning. Seems most people want to meet earlier rather than later. I just cannot escape that morning routine to clear my inbox either. I do not find this overwhelmingly tiresome but it is not a good habit either. Having filters on my email has certainly helped a great deal. Anything CC'd is in a separate folder and in my mind I have already categorized this as less important so therefor spend less time looking at it. I glance at it and move on typically rarely responding. Probably this is one of the best changes I have made. I spend less than 25% of my time responding to email and messages. This is down by at least 20%.

 I have found my early evening time works best (note - I have no kids) for free time but it is also the lowest energy I have during the day. Afternoon naps are certainly not out of the question but then I find I lose to much time getting functional again after the nap if its to long. So I haven't found the right solution yet.

Realizations and Improvement -

Thinking I could just become some mind ninja overnight - It is a constant struggle to do what is not easy.

Finding the right time to focus - Still working on this part. Is it early morning, late at night or a combo? I haven't found my rhythm yet.

Linking my success to lifestyle change - I have made all these changes when do I see the pay off.

Better planning - I started off doing a good job of this but it seems to have fallen off. I need to better plan my daily schedule. I have fallen back into some old habits of checking email etc. when I could be pursuing something more worthwhile.

Successes -

Writing - I have a bunch of note pads around I am continually scratching in but I have a special note pad for ideas and planning. I just feel good writing. Side effect, my spelling and grammar is improving immensely in general correspondence.

Alexa time management - Now I understand why having a personal assistant is so cool. Thank you Amazon.

Email and messaging management - Getting this under control is key.

Screen free Sunday - Turning off all screens for a day is something to enjoy.

Blogging - Although related to writing, its helping me formalize my plan and ensure continued commitment. Hopefully you will see me add some interesting topics in upcoming posts, that is not to say you will read them but interesting to me at least.

Thanks for reading about my life hack.


Working with the Cisco Spark Flint Framework .hears Method

If you don’t like looking at code then you probably wont like this post much. There is a bit of a art of working with the .hears method in the Flint framework. Nick Marus has done a fantastic job of documenting its many uses but I thought it might be helpful to give some coded examples using JavaScript. In saying that of course with code there are a million ways to do this. I am not saying I have done this the right way or wrong way its just the way I worked out how to do it. Feel free to send me your own examples. I am always looking for more ways to do things.

Hears Function Filtering Process

 Flint processes each of the hears function calls sequentially, testing the received web hook messages against each of your .hears functions. So there are a few ways to handle processing the incoming web hooks. I like to break out my hears functions into individual pieces of code. I have heard of others and tried my self using the switch command to derive the different commands being feed to the bot to lower the amount of code. Personally I like to see each command broken out for processing. I also like to mix my bots with natural language processing(NLP) and slash commands. While users may like to use NLP to ask questions and make requests, as an admin I like the ease of a slash command to perform tasks like broadcasting to all the rooms the bot is in.

Bot Welcome Message

 This is a great way to introduce your users to your bot. This is not using the hears function but actually the spawn event I thought it was worth a mention.  As the room is spawned and your bot enters this provides a welcome message to your users or a way they can get help for your bot. I have tried more extensive bot introductions but users complained it was to much. Just a quick hello here is how you get help is enough. Seeing as your bot may be in one on one or group rooms you may want to address each a little different. Remember bot accounts in a room only receive a web hook message if @mentioned.

Slash Commands

This is the bread and butter for a bot. Slash commands are actually pretty easy to handle. Nick has already taken care of removing the @mention when a /text is seen by the bot. This makes this type of command pretty simple to take care of. If the command itself is the only thing being processed you are ready to provide your bot logic and return your response using bot.say function. If you actually have text following the command you may want to strip the command out before more processing. The broadcast command example further along in the post provides an example of removing the base slash command. The example below also introduces the use of the trigger object to extract information from the incoming message. In this case the trigger.roomId. This is maybe something that your users are not to interested in but its a great way to quick grab your roomId when doing some development and testing.

Simple Reply

This example is basically the "hello world' for a bot. But it does show another important attribute of the trigger object. personDisplayName and personEmail are two handy attributes for dealing with bot hear function requests. We will take a look at the use of the personEmail attribute a little further on.

Broadcast and Restricted Commands

 This is a really handy bot command for event bots. Now you may be wondering what I am talking about. I have been to a number of conferences recently where bots have been used to provide information and encourage attendees to get involved with whats going on. I personally used a very simple bot at the TechCrunch hackathon to work with attendees and let them know when pizza was served. The thing with this command is you don't want everyone to have access to it. Last thing you need is some prankster letting loose with something obscene message to every room the bot is in. In my case I am using email to restrict the use of this command but you could take this further and include roomId as well. Another thing you can also use this method for is to restrict down who can interact with your bot to a domain. So if I use Cisco as an example I can build a bot just for internal use and say anyone with a email address is good to go and everyone else gets a unauthorized access message.

NLP Processing

The NLP hears function I like to be the last hears function as a catch all after all the slash commands and everything else has been tested. The trick to this function though is that if you don't have a method to remove previously processed hears functions it will process them all over again.  I like to use the match function to test if commands had previously been used. Although this leads to having to edit a hears command function and this catchall function every time you add a new slash command I am sure a smart developer can work out how to fix that. This is just the way I worked out how to get around it. The whole idea of this function is to be able to send the request to a NLP engine for further processing and then use the response from Watson or etc. to send back your response to your user. Now if you do use the NLP response or do something else with the response from an NLP engine is totally up to you but this is the best way I found to capture the needed info from the user.

Posting Markdown and Files

Not really a hears function but still important is you want to make use of markdown or posting files using the Flint Framework using the bot.say function. Nick has changed this method a little between versions added the markdown JSON object. Pretty easy to understand once you see the example below.

Please comment if you have found more inventive ways to use this function.

XMPP to Spark Bot - Sorry Jabber, Thanks for the Memories!

This is a small post because its a small program! Okay that's just a terrible joke. But I have had a lot of interest in this little bot I wrote internally at Cisco. I haven't published this anywhere else so call it a VoIPNorm exclusive if you will but here is the code to my "I am leaving you Jabber for a better place bot!" To long?

You can basically run this bot in any Nodejs environment. If your familiar at all with Jabber you will know this is just a XMPP client connecting to the WebEx Messenger service but this could be any XMPP client/server platform. Feel free to change up the messages and also what you present as your presence status. This bot will log on to Jabber as you, update your presence and send any communication from Jabber back into a one one one room in Cisco Spark.I did have an issue with dropped XMPP connections shutting down the service but fixed that by creating a function that could be used by the closed event to reopen the connection to the XMPP service.

I wrote this bot for a bit of fun and education, it is a hack to be sure. I never intended it as a mass production application but when people see it and try it I always get requests for the code. So if you love to hack and write code just for your own personal enjoyment this should be right up your alley. Enjoy!

Cisco Spark Bot with IBM Watson Conversation API

Recently I attended TechCrunch Disrupt in San Francisco as part of the Cisco Spark team. TC puts on a great hackathon before the main 3 day event that most would know for the Startup Battlefield shown on the HBO series Silicon Valley. This year over 1000 hackers participated in a 24hr hackathon in San Francisco. In preparation for the event I created a simple Cisco Spark bot skeleton written in Javascript for Nodejs.

My aim for the bot skeleton was not to show any mastery of Javascript, far from it, but to enable the hackers to be able to quickly assemble and deploy a chatbot for Spark. This would allow the hackers to focus more on their project’s use case versus having to work out the particulars of the Spark API. There is plenty documentation around for the various pieces but to bring a bot like this together getting it altogether in a quick format without the research is a little harder. I wanted something quick and easy for the hackers that if needed I could quickly help them get it going.

The bot skeleton consists of a number of node modules. While all the modules provide some important function the main module responsible for Spark functions such as webhooks, posting messages and emitting bot events is the Flint framework. Flint is being constantly updated by it creator Nick Marus. Nick has done a great job on creating an easy to use framework. Once you have done the setup once or twice creating new bots is a matter of minutes project.

The skeleton I created also contains a simple integration to IBM Watson’s Conversation API. Unfortunately the documentation on the Conversation API for the node module is a little low on details. I am hoping to in follow up post to go more into depth around using context with Watson’s Conversation API. There is some good info and examples out there from a few of the IBM folks which I am using right now to build out a more complex bot integration. There are a lot of high level demo’s and videos out there but there isn’t much informaiton on doing something a little more complex. If you are looking to do a Spark bot or a bot on another platform, the Watson context object is critical to get complex dialogs working but for now lets look at something a little simpler.

Spark Bot Information

A lot of the info below comes from the readme on my GitHub repo but I have extended some of the details here in case you need some extra help.

Required accounts

  • Spark user/developer account – Pretty simple. Download the mobile app or go to the web and signup for an account if you don’t have one already. Once complete sign into the developers portal using the same account details.
  • Spark bot account – Once you are in the Spark developers portal head to “My Apps”. Its right next to your avatar. Creating the Spark bot account is very simple just fill out the form. The hardest part is finding the right avatar. Once you filled everything out and saved your bot don’t forget to grab the bots access token from the page. you will need it a little later.
  • IBM Watson credentials – Rather than rewriting the great work of others at IBM, here are some quick pointers to info.
  • Cloud 9 hosting (optional)

IBM Watson Conversation API's

For those of you that are actually at any of the TechCrunch hackathons there are alternatives obviously to Watson but you don’t have a chance of winning any prizes if you use them. This is just the start of integrating with Watson’s Conversation API’s, in a follow up I will talk more about using MongoDB to track conversation context based on room and email ID’s. This simple use of the Nodejs module will get you started but for more complex interactions you need context. But for now here is a little more help:
  • IBM Watson Conversation API provides a natural language interface to help automate interactions for chatbots.
  • IBM provides a web interface to help create Intents, Entities and Dialogs along with an extensive nodejs module which is used in this skeleton.
  • API calls are made to the Watson service via the Nodejs Watson module.
  • Great demo from IBM Watson Team

Cloud 9 hosting by Amazon

This is one of the coolest development cloud IDE’s out there. You can use a variety of languages and the Cloud 9 team have done a great job at making it easy to add additional components to a container. Its integrated with Github Oauth to make it easy to signup and sign in.
  • Cloud 9 is a cloud IDE/hosting platform
  • Cloud 9 hosting documents
  • Cloud 9 Introduction Video
  • ***Ensure to upgrade the default version of Express if using Cloud 9 per the dependencies below which is also in the package.json file. The default version of Express if using the predefined workspace is below the requirements for the Flint frame work. So make sure to run the “npm install express –save’’ after removing the old Express version from your package.json file.

Dependencies for Spark Skeleton-

  • "async": "~0.2.8",
  • "body-parser": "^1.15.2",
  • "express": "^4.14.0",
  • "fs": "0.0.1-security",
  • "node-flint": "^4.1.1",
  • "path": "^0.12.7",
  • "watson-developer-cloud": "^2.2.0"
Note – there is a later version of the Flint framework (4.2) but I have not tested it with this Skeleton.

Setting up config.example.js

 Below is the config example file from Github. To enable this file on your real project make sure to fill in all the expected access tokens and keys and rename the file to config.js. Pretty simple really but I thought I would highlight it as some people may not realize this needs to occur.

Running the server with debug

DEBUG=flint,bot,sparky node server.js 

Helpful Links

I am working on Using MongoDB to Capture Context right now so I will publish a follow up in the near future along with an expanded explanation of how to use the flint.hears method. This is the main method used by the framework to capture text for by the bot to perform its duty.