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