Getting Started with Spark API's for Non-Coders

Once considered the domain of the technical elite, application programming interface or API's are now more open and available than ever but it's not the API's themselves that are increasing viability. It is an ever increasing ecosystem of platforms that are helping us plug API's into, together and around us that have changed the way we look at how we can get stuff done and allowing the average user access to the forbidden fruit.

When I recently presented at a conference in Seattle I wanted a group of non-coders to realize that API's are something worth taking a closer look at. I thought what makes more sense than to categorize their use into ever increasing levels of complexity. I come up with four levels.

Level 1 - Easy peasy lemon squeezy (that is British for, "yes, its f@#$%^ easy")

Level 2 - A little harder but my 10 year could still work it out

Level 3 - I might need some help, please standby

Level 4 - Please help me I just had a brain hemorrhage

Level 1 is base level, can't get any simpler out of the box. While most of you might overlook the fact this is using API integrations the Cisco Spark Depot is simple easy to use click and go API and bot integration. There is no coding, you can access it straight from the Spark application from within a room and there is not too much to think about.

Level 2 is getting a little harder by using a API broker. Now when I say harder I mean you have to go outside the application and visit a website. So in reality not too hard. But there are some steps to get you integration working but sites like IFTTT and Zapier make it pretty easy to get your applet/zap/whatever you want to name it working.
  • IFTTT - This is the easier of the two examples to work through. If This Then That makes setting up integrations pretty simple with click and go work flows.
  • Zapier -  Along the same lines as IFTTT but allows more complex work flows and trigger scenario's.
Level 3 is more complex but not beyond the skill level of most IT pro's. While the works flows at level 3 are a mix of drag and drop and there is some coding to create more complex scenario's and integrations. If you want to take a look at some try:
  • Gupshup - This site along with hosting your chatbot across multiple platforms has the ability to also host Javascript code to perform more complex API interactions. While the hosting and initial integrations are taken care of most of the hard work will be done with your hosted code.
  • api.ai - Now part of Google this cool NLP platform has a lot of prebuilt NLP domains for you to use to get you started. It also has the ability to host the integration to Spark to leave you to do the business logic which it has the ability to integrate with using Webhooks. This is close to a level 4 but seeing as it does some of the hosting work for you it's making your life easier getting it a level 3.
  • Built.io - This is an interesting platform that does drag and drop integrations along with the ability to host custom code. It makes your life easier by doing the hosting for you and providing some nice drag and drop integrations. 
Level 4 is custom code. The most complex of the 4 levels that requires a in depth knowledge of programming although you would be surprised what you can write with less than expert knowledge. Some of the interactions with technical non-programmers over the last year or so have highlighted the fact that people just don't know where to start when it comes to this level. If you have never tackled programming before it is a challenging endeavour but not impossible. The fact there is so many paths you can take can put some people off but sticking with it will in the end bring results. Some of benefits and challenges are:
  • Ultimate in business logic customization
  • Ability to use open source frameworks and platforms (Nodejs, Node-Red, Spark Flint, etc.)
  • Access to all sorts of API providers (Google, Facebook, Salesforce, etc.)
  • Language and platform flexibility (Javascript, Python, .net, Java, etc.)
  • Lots of hosting choices (AWS, Heroku, Azure, etc.)
  • Too much choice leading to analysis paralysis.
Having choice of course is a good thing and while level 1 and 2 are much simpler you would be surprised what sort of integrations you can create. Give it a go and it may inspire you to move on to levels 3 and 4.

VoIPNorm

Using IBM's Watson Conversation API with Cisco Spark in Node.js

IBM's Watson has a number of APIs but the one I am dealing with in this post is the Conversation API which has some interesting features. Even though IBM are clearly still adding features to this fairly new API it is pretty easy to work with once you understand how context can be used. I am not going to go over the basics of the API which if you have never worked with Watson before there are a million You Tube videos on the basic's. Seems even a 13 year old can put a video together on how to use Watson. I did watch this video BTW and its a handy starting place for the basics but one thing that is missing from all the videos is how to use the context data to get information back and forth from your bot to Watson. The video's mention it and the Watson documentation talks about it but it is a little confusing to start with.

What is Context?

Context is a pretty commonly used phrase in natural language processing(NLP) systems, it allows you to pass information back and forth between your bot and the NLP processor, in our case Watson. It does this using a JSON format which can include basically any attribute you want to put into it. Watson does have its own tracking with the conversation_id but tracking of the user and the conversation the user is currently in is up to you. I like to think of context as a cookie that gets passed back and forth. If you are working with a chat app in the browser the browser can take care of the cookie for you. But in our case with Cisco Spark you have no such luck. You as the developer have to track context which is included with every response from Watson. Watson will update the context with information from your users and information Watson uses to track the conversation. Without the mechanism to track the conversation context Watson assumes every transaction is a new conversation and the conversation_id is reset to a new value.

Building a Cisco Spark Bot with Watson

I recently built a Spark bot that started out using an array to track context but I quickly moved to MongoDB database (I wanted some persistence on restarts of node) . Seeing as Watson's context is already formatted in JSON it is easy to slip this straight into Mongo. Below is an example of some of the attributes I add to the context parameter before I send my message to Watson. Email, roomId, user and orderComplete (it is a pizza bot) are all created and added before the first message is sent to Watson. The combination of email and roomId from a Spark point of view makes every conversation unique as well as giving me some handy attributes. I, as a person can have multiple conversations with Watson in either a one-on-one room or multiple participant room so having a way to track that is important.

{ _id: '',
  email: '@cisco.com',
  roomId: '
  user: 'Christopher Norman',
  orderComplete: 'true',
  conversation_id: 'af4487c4-5543-4bf8-ab9c-f4611b3498bd',
  system: 
   { dialog_stack: [ 'node_9_1475525825835' ],
     dialog_turn_counter: 9,
     dialog_request_counter: 9 },
  pizzaType: 'vegetarian',
  hackerNumber: 5 }

PizzaType and hackerNumber are appended during the conversation by Watson, which I will cover in just a bit. Obviously there are some other attributes Watson will add like what node it is up to in your conversation with node_9 as an example. This is its own tracking system and as long as you relay this back to Watson during your conversation it will keep your place in the dialog exchange. The exception to the this is a flat dialog structure where every node in the Watson dialog is a conversation entry point. In this case you don't care where the conversation is because the dialog has no depth. A FAQ bot where every question is the start and end and there is no follow up question as an example. I was going to say data collection as well but you can still make context updates even in this more simple dialog structure.

Below is a sample of what I used to build the context request using the Node.js Watson module. You may notice this is different than the example from the module. That is because the module example doesn't show you how to pass context through your conversation, this does. Watson's Node.js module is pretty useless without a way to collect and pass context. I worked this out by looking at this code, go look its worth the time. Stefania is an IBM dev evangelist, she has written some great examples over on Github that helped me a great deal. Just remember you have to save the returned context and retrieve what you have saved to send back a reply when your user responds to Watson. Watsons NLP engine will append entity information to context as you dictate but your still need to save it.

If you are interested in what I did to write my context to a MongoDB see my gist below. I am not going to cover it blow by blow but some might find it handy so I have included it for completeness. There is nothing to complicated in there as I replace the previous context Watson sends me rather than update the one in the database. There are quite few fields that require updating in every transaction so replacing context was just simpler than updating fields in the stored JSON record. If you prefer another database go for it this is just a quick solution I put it together in a couple of days. I didn't have weeks to explore the perfect database or why one option may be better than another or even put much thought into the data structure. I am just throwing JSON data chunks into the MongoDB and retrieving them later. I only mention this after reading this article while doing some research. It is not so much the article, which is interesting (although not sure I agree with), but some of the comments. The blogger should have mentioned to check your ego at the door before writing your comment. Is it just me or are people on the Internet snarky? lol.


So now we have covered how to build the context but what else can we do with it? Obviously I am going to use the classic pizza bot example, doesn't everyone. As you build out your dialog you can use Watson to pick out and update information in the context as well as create some more complex logic for dialog decision making. In the first dialog box even though you can not quite see it, I am checking the content of an attribute in my context using $orderComplete.contains('new'). This allows me to see if this person has ordered yet. If they had that same attribute "orderComplete" would have read true and I could have put them in a different thread.


In the first dialog box we ask the user what Pizza type they want. In the second box we are accepting their response, relaying it back and prompting for more info. But first we must record their response in our context. In our case it is the pizza selection using NLP we identify with entities(sorry I never covered this earlier. Now is the time to go read about intents and entities on IBM's Watson documentation site if you don't know WTF I am talking about).

Quick tip. If you need access to info in your context at any stage to respond to your user, using $ will get it for you. Below I added $user to grab the user name attribute from my context to add a personal touch to the interaction but this can be anything stored in the context.

Watson has a very interesting NLP engine that is actually pretty easy to work with once you get past the initial knowledge gap. Not to say there are not a load of other possible alternatives such as api.ai etc. or a node module that does NLP this is just one engine. If you have tried others feel free to comment about it. Always interested to check out new stuff especially if you have done NLP using a node module.

Thanks for reading.

VoIPNorm

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.

VoIPNorm

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 cisco.com 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 api.ai 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.
VoIPNorm

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.

VoIPNorm

Stop Bugging Me – A Post for the Truly Distracted

If your from Seattle this is not an advertisement for a local pest control company (Stop Bugging Me) we have all come to love or despise (sorry Marshawn Lynch,  I promise I am in the first category). This is about constant interruption that now plagues our ability to think. While I admit I am part of this problem as I blog and tweet my way into your phone, inbox or desktop, this is about how I plan to change and lead a more focused life.

Why this revelation you may ask? Well I am glad you asked (I actually know your not really asking). There are really two reasons I have come to this cross roads in my life. I am endeavoring to learn a new complex skill(programming) and secondly just to lead a more fulfilling work life . Even though I have given into a distracted life style I have some how made progress with my new skill although the pace of improvement seems awkwardly slow. My work life however generally feels unfulfilling and not because of my job but because of this struggle between being super connected and actually getting stuff done. In my mind things like meetings, email and messages don’t feel like really getting stuff done although they can be important for sure. The difference between me responding right now and in a couple of hours, lets just say its not as big of a deal as I would have myself believe.

My Typical Day

My general day consists of waking in the morning and before getting out of bed checking my email from my phone. I am a remote worker (and of late a road warrior) so I get breakfast and head straight to my home office to check more email for follow up and also my messaging app’s for more messages and chatter. I may also check Twitter for some more chatter and tweet a few invaluable thoughts. Through out the day I find my self slave to pop up notifications from email and messaging apps. Not that this is the fault of the applications, its just the habit I have formed from years of living inside those types of applications.  This is my day doing work being constantly interrupted by emails and messages while trying to learn complex systems and architectures to be prepared as a engineer.

Oh, I forgot to mention the meetings. Lots of meetings. The value of all those meetings well that’s a whole other blog post. Admittedly I work in sales (but of course I don’t like the sales tag as an engineer) so I am expected to be somewhat responsive and at meetings. I can’t go days without checking in so to speak, I would get fired. What this all ends up being is an extremely fragmented day. In all of this fragmentation none of it typically takes much real deep thought.To me it feels… kind of empty. I have no way to measure my own personal productivity. What do I tell myself ? Good job, you answered 40 emails today and attended 4 meetings.

Like I said earlier I don’t blame the technology for my own issues and I do attempt to wrangle its behavior. Filters on email, teams in messaging apps but I am a slave to my own success as a knowledge worker caught in notification hell and extremely easy to distract. Even once I walk away from my computer anything and everything can distract me. To the point where if I give myself a simple task such as unload the dishwasher I cannot actually get it done without getting side tracked. It also affects my love of golf where the simplest things distract my attention. At least when I play golf I do commit to putting my phone away but my focus is rarely optimal.

Tools of Distraction

Email, business messaging app’s and the like it would be easy for me to point my finger at those things and lay blame. But its not their fault. I finally understand the business messaging app presence liar (pick your tool Jabber, Skype etc.). You know that annoying person that is always set to away, do not disturb or worse yet offline but you know they stalk your own presence for you to turn green. You know that’s how their conversations start “I have a qq”. All the meanwhile your thinking why is your presence still saying away when your pinging me. They stalk and message all the while rejecting the norm to go “online”. I don’t blame them, these liars of technology. Polluting my notification space in the top right hand corner of my desktop screen. I want to be one of them. But my own set of personal ethics wont let me. If I am honest and trusting and I use these tools I should show my true presence. Yes I am “online”, damn it.

Then there is the multitude of tools. I have tried to limit this down to two main tools, neither of which now carry the traditional presence people are used to in typical Unified Communications products. Email and Cisco Spark. That’s right I am rejecting presence, I don’t want people to know I am online (even though Spark has this its much more subtle. Its not a big green dot). I want to control how, when and with whom I communicate. I don’t mind if people know I have read their communication but I want better control on when that happens. I feel like Spark has given me back that control and with new notification settings I have a better handle on what grabs my attention. How I made this transition to Spark I will outline a little later.

Getting Past Being a Whiny Little B….

So far this has been a pretty whiny post. I just needed to get that first part off my chest. How did I get here? My first revelation was a blog post I read by a programmer. If you don’t go read it here is the short version. Learning to program isn’t hard, deep thought/work is and to learn programming takes a lot of deep thought. Deep thought is uninterrupted (90 minutes or more) thought on one particular subject typically without distractions. In this post he mentions a book, Deep Work by Cal Newport.This is an excellent book. If you have ever caught your self in the same situation I have this book is worth a look. At least go read the free pages on Amazon and I guarantee you will end up making a purchase. Cal explores many of the techniques of the great thinkers of our time and how they managed to do what they do. Many of modern day thinkers for instance reject our easy access society which means no or limited email and especially no social media. I obviously don’t want to go that far but changes need to be made.

Not sure why it took reading an article and reading a book to realize my problem but sometimes that is what it takes. My wife takes quite delight in pointing out its obvious, “you needed a book to tell you that!”. Well, yeah.

The Plan

I have a plan. Its quite honestly still evolving in my mind right now but I know if I blog about it I will be forced to commit to something. I do have some first steps which I have already implemented to the displeasure of some of my coworkers and the delight of others. My action items I have identified start the moment I arise in the morning. 

Don’t put the phone beside the bed, have Alexa wake me instead – Less sleep interruptions from flashing screens and less chance to look at notifications first thing. Alexa can wake me with the gentle sounds of the sea in a relaxed state of mind. I have become quite fond of Amazon Alexa and the echo in my office. My Echo purchase for the bedroom is arriving today!

Deep work in the morning – This can be both from a reading and activity standpoint as long as the interruptions  are zero and I focus on a single topic. The act of programming is a deep work activity for sure. Seems like a lot of meetings I need to attend happen in this period so this may alter to more flexible scheduling but my hope is 90 minutes in the morning.

Resuming regular blogging- While I do not consider most blogging activity deep work, this has a two fold benefit. Its good practice on a light activity that does require some focus and it will help me get back to something I enjoy. 60-90 minute blocks of activity to help me get back on track should work. The plan is to blog at least twice a month but if more should happen that’s great. I don’t plan it to be some bullshit blog posts either. Deep technical thinking the kind of stuff that I started with.

Use Alexa for reminders of up coming meetings – Like I mentioned earlier Alexa has proven to be very valuable. The ability to set easy reminders has already helped me to stay on course for up coming meetings but now I can use Alexa and my Echo to help coordinate my focus time and still make my meetings. A voice enabled electronic assistant can prove to be very helpful and fun.

Breaking Free of Presence –  No more presence liars and no more being “online”. I built a Cisco Spark/Jabber bot about 6 months ago that allowed me to move away from a presence client (jabber) as an experiment, little did I know at the time how it would help enable me to change my behavior. Originally it was to help limit me down to just one messaging client but unknowingly it was helping me move away from presence stalkers. The code I built for my bot is not something I have released on Github but if your interested please let me know and I can share the code. Its written in Nodejs and is a pretty simple bot. I am not sure whether I will add more capabilities to the bot yet but I have been incrementally improving its stability at least. Building bots is a great way to learn programming BTW. Another topic for another post.

Filter email for everything – I do already do some filtering of email distribution lists, which I rarely read already but I am taking this one step further. I am filtering all cc’d emails to their own folder. This makes only email’s that have me in the to field notification worthy. Not sure if I can stick to this. I notice a lot of people put me in the cc field but still expect me to do something. But the plan is to check only cc emails once a day. I have also noticed that I now keep checking the cc folder. So this one might be a bit of a failure.

Sundays are screen free days – No screens at all. No TV, no iPad, no phone App usage. This is plan but I feel okay with allowing a little TV time Sunday night. I do have shows I enjoy like GoT but my days should be mostly screen free except for phones calls. I still need some accessibility.

Fridays are focus days - Deep work on important topics, new projects and concepts such as programming. Although meetings will break this up I am doing my best to keep this as a true work day not a meeting/email day.

Break email and business messaging app checking into blocks – This means less of allowing these applications to be a constant interruption. The plan is to set aside time to address this type of work and when the time is up move to the next work block. I have found when I am in a meeting I keep sliding into the typical fading focus as email and messages grab my attention. This is not a great behavior and if a meeting is that unimportant to me I shouldn’t be there. So if I make the effort to attend that means being there in mentally as well.

Rate my focus performance to help track improvement with a moving schedule – I need a system to rate my focus time to ensure I make progress on focusing. The scale is A-F. A being the best for awesome and F being the worst for fucking wasting my time. The focus time is rated on ignoring interruptions, staying on track and quality of work completed in that time set. Initially I had set amount of work, but that’s not a good measure, I want quality not quantity.

I am also scheduling every minute of the day to activities but on a moving schedule as work allows. So if a meeting goes long I adjust as it happens. This reminds me of Whiterose from My Robot. All we have in the end is time! I am sure she said that.

Establish shutdown process – No new work email after 5pm will be processed and by 5:30pm I should be done with the days work till the next day. There will be exceptions to this of course like when I travel or time zone issues but for most part I think this is achievable. This has been hard to stick to I have noticed but I am working at it.

Write my rules on a whiteboard – I need to live and breath these rules till they become habit. I am not going to enforce these rules with obsession but its about changing for the better but still able to make exceptions when I need to.

My experience so far

This is by far one of the most challenging endeavors I have ever undertaken. Making life style changes no matter what are always difficult. Exercise, giving up smoking, eating better are life style changes that seem obvious to make but changing your digital lifestyle doesn’t seem so obvious especially when we don’t understand the effect it is really having on us. Cal’s book really helped me but even he points out that there are those that disagree with his and other points of view on the effects of social media etc.

On thing I have found to be true as the day moves a long your will power drains from you like power from a battery. My focus quality also significantly lowers as well in the afternoon but I noticed it improves again in the evening. This was previously less obvious because of the constant flow of distractions. Unplugging from the constant stream of notifications is something I had never believed was hard to do but when in front a computer and you know the internet is just a click away its very hard to resist. Constantly looking at the time for when my focus block will be over. Its so easy to give in to those distracts.

I have completed my first Sunday with no screen, well mostly. I did in the evening spend 30 minutes watching TV but aside from that there was very little compromise in my commitment. I was surprised by the amount of stuff I was able to do by not watching TV which is my usual Sunday.  According to Cal’s book the average male adult aged 25-35 spends somewhere between 15-28 hours a week watching TV. I fit into that category so I am making a strong effort to change.

My first focus session was pretty much a failure, I was never comfortable, my mind kept wondering to an earlier notification I had seen on my phone and I was constantly thinking it must be close to an hour. At best it was 20 minutes of focus out of an hour of twitching and mind wandering. I give myself a C- and that was being generous. The fact I could only go 20 minutes of true focus was a little surprising but so far it seems to be my limit. I have the focus of a three year old. Fuck me. But I am trying and it does seem to be improving.

Engagement seems to be a big factor in maintaining that focus. The more engaged in an activity I can get the more focus and for a longer period. So reading and absorbing programming right now seems a struggle if just reading from a book. Combining it with actually programming makes it much more engaging but I fear by engaging with the MAC it lowers my focus opening me to distractions.

Overall I must admit that even though I am only at the beginning of my lifestyle change I see encouraging signs. Thoughts are clearer, focus is improving even only after a week and my energy is higher than its been in a long time.  I feel like I can accomplish more with my day and I am stretching my mind further than I have in a long time.

Sorry if this post was all about me but if you read this far there must be something you relate to. If not than why are you letting me distract you, get back to focusing fool….

VoIPNorm

Cisco Spark JavaScript SDK Updated with more ES5 Examples

Last week the official  Cisco Spark JavaScript SDK went though a version update to 0.6.3. This included bug fixes with some new ES5 examples added to the readme incase you haven’t seen it yet. NPM has updated the package description and when you update the Node module the new readme contains all the updated examples. See an example from the readme below for creating a room and posting a message.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';

var assert = require('assert');
var ciscospark = require('ciscospark');

var message1, message2, room;
return ciscospark.rooms.create({title: 'Messages Example'})
  .then(function(r) {
    room = r;
    return ciscospark.messages.create({
      text: 'Howdy!',
      roomId: room.id
    });
  })
  .then(function(m) {
    message1 = m;
    return ciscospark.messages.create({
      text: 'How are you?',
      roomId: room.id
    });
  })
  .then(function(m) {
    message2 = m;
    return ciscospark.messages.list({roomId: room.id});
  })
  .then(function(messages) {
    assert.equal(messages.length, 2);
    assert.equal(messages.items[0].id, message2.id);
    assert.equal(messages.items[1].id, message1.id);
  });

VoIPNorm

Cisco Spark API with NodeJS: Getting Started

Last post I talked about getting started with Tropo’s NodeJS module. What I failed to mention is that there is also a Spark NodeJS Module. Using Spark with NodeJS is just as easy to work with and opens up a great deal of opportunities to integrate your work processes into communication channels in Spark.

But before we jump into code the best place to start is with the Spark Developer site. https://developer.ciscospark.com/.

There are a couple of reasons to visit the developer site besides the documentation for the various Spark API’s. Its also an easy way to grab your Spark access token so we can do some simple code examples without getting to hot and heavy with authentication. Once you login to the site on the far right click on your avatar to get your access token which we will need to do our first code samples.

image

Pretty simple so far. Now to make use of access token probably the easiest way is to set an environmental variable when you start your Node application from the terminal or cmd prompt. Below is the command to use to start you node app with your access token.

$CISCOSPARK_ACCESS_TOKEN=<your developer portal token> node ./server.js

Also don’t forget to install the NodeJS Cisco Spark Module. Check it out here https://www.npmjs.com/package/ciscospark. To install using npm:

$npm install ciscospark –save

One of the most basic examples is to request a list of rooms. I recently integrated an application I was building to log error output to a test Spark room but before I could do that I had to find out the room ID.  This simple example is a great way to do that.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// Fetch your 5 most recently created rooms
//
// Run with
// CISCOSPARK_ACCESS_TOKEN=<your developer portal token> node ./1-access-token.js

var ciscospark = require('ciscospark');
ciscospark.rooms.list({max: 5})
  .then(function(rooms) {
    console.log(rooms);
  })
  .catch(function(reason) {
    console.error(reason);
    process.exit(1);
  });

Using lodash we can then find the rooms you are after. In the example below we are call the Spark API to list our rooms and using using lodash to sort the JSON response to console log one room. If you haven't noticed yet the Spark Node SDK is making use of promises. Our examples are being kept pretty simple promises make working with the API a lot easier versus using callbacks.Also note our example uses a process.argv to access the command line and room name you enter when starting your node process. Also don’t forget your access token if you not authenticating using another method.

$CISCOSPARK_ACCESS_TOKEN=<your developer portal token> node ./server.js <room name>

If you

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Fetch your five most recently created rooms and log the first one with the title specified on the command line
//
// 1. Run npm install --save lodash
// 2. Run with
// node ./server.js <room name>

var lodash = require('lodash');

if (process.env.NODE_ENV !== 'production') {
  require('dotenv').config();
}

var ciscospark = require('ciscospark');
ciscospark.rooms.list({max: 5})
  .then(function(rooms) {
    var room = _.find(rooms, {title: process.argv[2]});
    console.log(room);
  })
  .catch(function(reason) {
    console.error(reason);
    process.exit(1);
  });

Our last example fetches the five last created rooms. Lets pause here for moment to cover that a little better. When you use the list rooms it calls your last created rooms not your last updated. Its an important distinction to make as you may have to pull a much larger list of rooms to get the room you require. Once we get our rooms we list the messages of the room with specified title.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Fetch your five most recently created rooms and list the messages for the first room with the specified title
//
// Run with
// node ./server.js <room name>

var lodash = require('lodash');

if (process.env.NODE_ENV !== 'production') {
  require('dotenv').config();
}

var ciscospark = require('ciscospark');
ciscospark.rooms.list({max: 5})
  .then(function(rooms) {
    var room = _.find(rooms, {title: process.argv[2]});
    return ciscospark.messages.list({roomId: room.id});
  })
  .then(function(messages) {
    console.log(messages);
  })
  .catch(function(reason) {
    console.error(reason);
    process.exit(1);
  });

I hope you enjoyed our first look at the Spark SDK. Thanks to Ian Remmel for supplying the examples listed. Over the next few weeks and months I will be posting more examples of working with both Tropo and Spark SDK’s and API’s.

If you have built a Spark application let me know about it. I am excited to see what people are building in this exciting new era of communication API’s.

VoIPNorm

Going tropo with Cisco Tropo and NodeJS!

I have been working on a number of projects lately that have put me deep into API’s. Over the next few blog posts I am going to start sharing some of the stuff I have been up to with the new Spark API’s and also Tropo which has been around much longer. Both platforms are incredibly fun to work on experimenting with. While I make no claim as a software developer I will post code I have written hopefully not offending any real software developers out there.

For the last year or so I have been down the learning path of gaining some software development skills. This has not been easy. My purpose for these new skills is to be able to build prototypes and demonstrations for the use of Cisco’s API stack. Programming is a skill I have long thought I should have at least some ability in but to my dismay I never really knew where to start. So I took the traditional path of going to college. I won’t say it was a complete waste of time but after three or four programming classes I came to the realization that the University of Phoenix is not the right environment to learn programming. I can read a book and create crappy applications without paying $2K dollars a course on my own without UoP.

So after a lack lust UoP experience I was not sure what direction to head. I did have some web design skills but on the backend I was pretty sure learning another language outside of JavaScript was not what I was after. Luckily I have a peer that actually has extensive programming knowledge that suggested I take a look at NodeJS. He had been pushing me that way for a while but I was so engrossed in learning Java at the time I just never got around to it.

While I am not going to give a lesson on Node (there is already a ton of info on Node out there) most of the JavaScript code I have written or examples I will post on VoIPNorm are written for the Node framework. But before we head down that road let’s review:

What is Tropo?

From the FAQ on the website”":

With Tropo you can build nearly any voice application you can imagine, including speech-driven IVR, VoIP solutions and voice mashups. The code you write also works over text messaging. Check out our documentation and sample apps at: http://tropo.com/docs.

What to do first?

To get up and running in Tropo to develop your first app you will need to sign up for a developer account. Its pretty simple and painless. From there you can start either using the scripting engine to write some applications or dive right into using the WebAPI which once through the initial setup is a very powerful tool.

image

Topo has of course a bunch of examples in Node for use with the WebAPI (and other frameworks such as Ruby) on it documentation website. Some are a little dated but generally they all still function. Below is a basic answering a call on NodeJS using Tropo.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
var http = require('http');
var tropo_webapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {
	
	var tropo = new TropoWebAPI();

	tropo.say("Welcome to Tropo!");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 

To have this function you either need a working node server or some form of cloud container running Node. To make things easy Tropo does have its own NodeJS module that is available on NPM and examples on GitHub. If you are familiar with NPM its pretty simple to grab the module to install in your project:

~$ npm install tropo-webapi

If you plan to develop in Cloud9 to run your application from the cloud you will need a URL for your Tropo WebAPI app. Cloud9 gives you this which makes using Cloud9 a great way to develop Tropo applications. The Node workspace in Cloud9 uses the Express framework which is best to stick with the default template and strip out what you don’t need like SocketIO.

I am becoming a big fan of Cloud9 even though I still have NodeJS and Webstorm installed locally.

If you are looking to give Tropo a spin and are just after some simple demos using the Tropo Scripting API is a good place to start. The Scripting API is almost always where everyone starts out.

1
say("Welcome to Tropo!");

The JavaScript Tropo script example above produces the exact same results as the previous NodeJS example but of course you lose the flexibility of importing modules to extend Nodes functionality.

Tropo Scripting API versus WebAPI

Using the Scripting API is a great starting point but inevitably you will want to do more and link you application to other services such as Google, Box, Spark  and dare I say Slack or any other platform with API’s out there. The great thing is the Tropo WebAPI allows you to do that but it comes with doing more work to get a environment setup to start developing, but its worth it.

My environment for NodeJS with Tropo

I am using the following components/tools to develop with Tropo and NodeJS:

  • Cloud9 IDE using the NodeJS Express template. This is a great development environment with very little setup required. Each workspace you create in Cloud9 has its own unique URL which works well with Tropo.
  • Tropo WebAPI that is enabled for voice and SMS. To be enabled for outbound SMS Tropo requires you to lodge a ticket with their help desk. Just follow the process on the website.
  • Locally installed Webstorm IDE and NodeJS for quick development of utilities like a Google Places search or a ZIP code look up tool that you can embed in your Tropo application as you need them. Although Cloud9 is a great tool, sometimes you just need to build a small piece of code you will embed in a larger app later. I like using a local environment to do this.
  • Sublime Text is another handy tool I like to use although I am not an expert at using it. I know a lot of developers that like to work with Sublime instead of an IDE like WebStorm.

Of course my intent is not to build production like code (although in the future who knows) so your tools may vary but this is the tool set that got me working the fastest with NodeJS and Tropo. There are endless options though and I just noticed Visual Studio has a text editor that works with Node. So use what ever works for you if you already have some preferences.

I know with the explosion of API’s that are coming from Cisco and others in the industry that getting up to speed will be a steep learning curve. It was and still is for me which is why I am posting these lets get you started blog posts. I recognize that I am not a expert developer by any standard, I just stand on the shoulders of other that are. In saying that there are ways to do cool and fun projects without being a total dev geek. This is what I will be covering in follow up posts as I explore this myself. Feel free to post comments on code, tools or other things you find fun in the API space because there is a lot to learn and a million ways to do basically anything you can dream of.

VoIPNorm