Quantcast
Channel: VoIPNorm's Collaboration Blog
Viewing all 158 articles
Browse latest View live

Cisco Spark Bot with IBM Watson Conversation API

$
0
0
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


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

$
0
0
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!





Working with the Cisco Spark Flint Framework .hears Method

$
0
0
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

Stop Bugging Me: My life Hack Continues

$
0
0
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

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

$
0
0
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

Getting Started with Spark API's for Non-Coders

$
0
0
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

XMPP to Spark Bot - Presence Upgrade and Simplification!

$
0
0
Last September I first published my XMPP to Spark bot based on Nodejs that I created to consolidate my collaboration tools. Over the holiday break I made some upgrades and also simplified or I should say reduced the amount of code and modules required. The official Cisco Spark SDK is pretty large and bulky for the purposes of this bot so in the new version I have created a couple of simpler methods to enable its removal. This bot doesn't use webhooks and a bunch of other Spark API's so it was much easier to just create a couple of new methods. This bot is about getting others to use Spark versus a migration or integration tool but with expanded development it could be made to serve both of those purposes as well.

Below is the main server file. I haven't done a lot of commenting inside my code but you will notice I have a bot monitoring service for some experimenting. I am just monitoring and posting my cloud containers CPU up-time to a bot account in Spark. Eventually I am thinking about sending these updates to another monitoring service which posts updates and alerts on bot issues. You will also notice that I have added the ability to translate presence from Spark into XMPP. It is simple and readable. Presence only updates if my Spark presence/activity changes.It is defaulted on startup to "inactive".

This is a simple and fun personal bot to experiment with. Presence is new inside the Spark API and if your building a personal Spark bot the easiest way to get access is through the "get my own details". The "status" label gives your current presence.

Have fun coding!
VoIPNorm

Cisco Spark bot for monitoring Spark bots. Say whaaat!

$
0
0
The last few weeks I have been working on and testing a new Cisco Spark bot that monitors all my other bots using a RESTful API. Its a relatively simple bot and thanks to an existing Nodejs project from Qawelesizwe Mlilo that was built  to monitor websites I was able to make a few simple changes so it is now a Spark bot that monitors other bots using a RESTful API. Qawelesizwe original project is called node-ping and is posted on GitHub. It has a number of files but the main module is node-monitor which is its own node module available on NPM. I made changes to a couple of the files on the original project with the largest change being removal of the email module to replace with my own Spark message module.

How it Works
This bot works by monitoring a website through the HTML status codes which it pings using a time interval(this is set in the websites.json file). This is very handy because if you are using Express with Nodejs all the status codes are taken care of for you, all you need to do is build a new route on your bot to handle the inquiry from the monitor bot(see the code later in the post). The monitor bot looks at the status code response and adjusts the status of you monitored bot accordingly and sends a Spark message when it changes. If you already have an existing website for your bot that is hosted with the same bot application you could use that as well, but I choose to create a new route so in the future I can deliver more JSON data with my response for future features.


Coding the Monitor Bot
The changes I made to the original node-monitor module are pretty minor. I added a new attribute to the constructor to describe the current bot state. I defaulted all bots to down state. Below is a exert of node-monitor file showing the constructor change.

Once this was done I took the rest of the node-ping sample code and added the ability to send Spark messages using a bot account instead of using email(boo, no one likes more email) and also adjusted the events to relay up and down status so when a bot comes back up the monitor bot lets me know and stops sending me Spark messages.

Sending a Spark message instead of an email used the file below. Make sure to place in your own bot token and adjust the events.js file for where you place this file.

The final change for the bot monitor application was adjusting the server.js file to add the new event for when a monitored bot comes back online.

The last change you will need to make is on the bot you want to monitor. If your using Express see below. The change involves setting up a new route to respond to the request from the bot monitor.Seeing as you may or may not use an actual website to monitor I created a REST response. In my case I give a quick JSON response but in future versions I am planning on generating some data to respond with, like rooms configured and up time stats that can be logged.

This is just the start of my monitor bot which as you can see has some rough edges but it works and just today it alerted me to a down bot which I had to address. One thing I want to do in the future is a daily bot monitor report delivered in Spark to let me know how my other bots are doing. Right now I have no way of knowing if the monitor bot has gone down so a daily report will help there as well, unless I build a bot to monitor the bot that is monitoring all my other bots, but then how would I know if that bot then went down. I know another bot........

If you want to check out the original Monitor module here is a blog post that describes it. Also here is the GitHub site.

VoIPNorm

Introducing Stormy the Cisco Spark Weather Bot!

$
0
0
If you want your daily forecast delivered to your Cisco Spark Space this might be the bot your looking for.


I have been working on Stormy for the last month and its been a fun little project but I now believe its time to release Stormy into the wild. While Stormy is not terribly sophisticated he does deliver the weather daily with access to over 200,000 cities world wide. Thanks to openweather.org Stormy has access to your favorite cites.
Now, I don't believe for a second Stormy is about to change the world but its one of those handy bots that you can use to get your daily forecast delivered or as the example above shows simply ask a quick weather question. He knows no math, nor can he create a meme but he knows weather!
I am currently in the final testing stages for Stormy if you would like to try it out before it goes into the depot. Just search for Stormy inside of Spark and add it to a Spark Space or add stormy@sparkbot.io to a conversation. He is simple to setup and just requires you to provide a city using the /city command. If you are in a Space versus a 1:1 make sure to @ mention Stormy to set your city or chat with him. See below for setting the city in a Spark Space:
If you would prefer to see temperatures in Celsius use the /unit command to update your room settings to metric. To change it back to fahrenheit use the same command with the imperial key word. The city and unit settings are on a per Space basis so if you want daily forecasts for multiple cities you can create a team and add Stormy to rooms for each city you want to see a forecast for.

This is version 1.0 of Stormy so please feel free to request features or make comments here on the blog or use the /feedback command in a room with Stormy to provide feedback. He will from time to time be unavailable for questions as I work out the final kinks (nice way to say bugs) but that should be limited.

 In future blogs I will talk more about what makes Stormy tick.

VoIPNorm




Video Blog - Intro to Stormy the Weather Bot!

More on Troubleshooting Intelligent Proximity

$
0
0
Some time ago I wrote a post on this subject which BTW still applies today. Especially the use of the SpectrumView app on iOS. This is the most useful tools to troubleshoot Proximity issues as it give a clear indication of signal strength along with any interference that is in your environment.

Recently I was involved in some troubleshooting that on the surface seemed pretty straight forward but after some time looking a little deeper showed a reoccurring issue that went beyond the initial scope. While I am not going to go to far into the details there are some important things I learned around both how Proximity works but also interacts with other devices using Windows 10.

Turning Proximity Off:

The Proximity soft switch on the touch 10 does not disable the Proximity signal it only prevents clients connecting, see screenshot below of the Touch 10 interface switch. This is especially important if you end up with two Proximity capable devices in the same room. You will need to either turn Proximity off inside web interface or via SSH to stop the signal.

The easiest way is using the web interface to turn off the Proximity Signal. Go to Setup>Proximity and select the mode drop down and select Off and save. See below. Signal is now off.


 User Reported Issues:

Don't assume only one user is having the issue because no one else has said anything. Most of the time users will just grab the HDMI cable and get what they need done and move on. Users will mention it more to each other than you and some issues are harder than others to discover and seem limited but are much more far reaching. The only way to work this is out is test in multiple rooms with the same PC/MAC device experiencing issues. Do not immediately jump to it "must be a codec issue".

Windows 10 Audio Driver Issues:

This is pretty tricky to diagnose. The symptoms can vary quite a bit from dropping a Proximity session midway to not connecting to a codec via Proximity after coming out of hibernation. This is due to the way that Windows 10 shares access to Audio drivers and devices. Although I saw this predominately on Surface Pro and Surface Book devices other Windows 10 devices had some of the same issues. This means that it is more than likely a Windows 10 issue regardless of the hardware.

To change the exclusive-mode settings of a playback or recording device:
  • Right-click the speaker icon in the notification area, which is located on the right side of the taskbar, and select Playback Devices or Recording Devices. (As an alternative, run the Windows multimedia control panel, Mmsys.cpl, from a Command Prompt window. For more information, see Remarks in DEVICE_STATE_XXX Constants.)
  • After the Sound window appears, select Playback or Recording. Next, select an entry in the list of device names, and click Properties.
  • After the Properties window appears, click Advanced.
  • To enable applications to use the device in exclusive mode, check the box labeled Allow applications to take exclusive control of this device. To disable exclusive-mode use of the device, clear the check box. In our case we want to disable exclusive mode.
  • If exclusive-mode use of the device is enabled, you can specify whether a request for exclusive control of the device will succeed if the device is currently playing or recording shared-mode streams. To give exclusive-mode applications priority over shared-mode applications, check the box labeled Give exclusive mode applications priority. To deny exclusive-mode applications priority over shared-mode applications, clear the check box. In our case we want to deny exclusive mode applications.
VoIPNorm

Parsing Inbound Cisco Spark Webhook Bot Mentions using Node-Flint

$
0
0
A while back I wrote a post on parsing inbound Cisco Spark webhook data using the hears method with the node-flint framework by Nick Marus. After much thought and general improvement in skill as a developer I have created a much simpler way that could be potentially used with other frameworks. This allows the parsing of slash commands and fallback to a NLP processing service.

Below is a conversations module that can be used with flint. Rather than have multiple flint.hears methods for the event I now have just one using the switch method. Switch allows me to test the contents of my request string variable using regex. A much better solution than multiple flint.hears methods that has limited control over when to stop processing. Once you hit a match using switch it stops processing and performs the function in the return statement.
VoIPNorm

Cisco Telepresence CapsetFilter Setting - Disabling H.239/BFCP

$
0
0
This is a not very well known setting going by how long it took me to find. The CapsetFilter setting available in TE and CE firmware on Cisco Telepresence endpoints can be used to change the layout of streamed content and video channels. Most modern video experiences call for separate video and content channels to allow local video layout customization and better content resolution. But what if you want content and video in the main video stream. This is negotiated usually but if you need to force this behavior CapsetFilter setting is how you do it. Disabling H.239/BFCP will force content and video into the main video stream.

Either SSH or using the web interface into the codec:

Disable H.239/BFCP using xCommand:
xConfiguration Experimental CapsetFilter: "H.239Ctrl"

Admin interface:


VoIPNorm

Cisco Spark Node-Flint Support Space

$
0
0
Nick Marus and I have opened a Cisco Spark Space if you require support, share code or find issues for the Node-Flint Bot Framework for developing Cisco Spark Bots and Integrations developed by Nick. Please feel free to follow this link and join the Cisco Spark Space by entering your email on the page. I have also added the link in my gadgets space so if you need it at a later date its available.

VoIPNorm

Introducing Cisco Spark Nettools Bot

$
0
0


This is a new Cisco Spark bot I created to help with troubleshooting DNS and Cisco Expressway issues. Let me know what you think.

Thanks to John Howell who created this great video to help promote the bot.

VoIPNorm

NetTools Cisco Spark Bot now on Github

$
0
0
If you would like to run your own version of netTools bot for Cisco Spark please check out this Github repo.

https://github.com/voipnorm/netTools

A couple of points.
  • This bot uses a websocket library and websockets for bots is not supported by Cisco but it does work well. If you prefer webhooks just remove the websocket configuration and library.
  • Flint-node configuration and conversation files broken into their own files and imported into other files that need them.
  • Switch statement used to sort conversations which is different than the Flint-node examples.
  • Watson used for logging throughout. Use .env file to up date to production to turn all logging off.
  • .env file required for all Spark token settings unless you care to change of course!
Enjoy!

VoIPNorm

Presence and CE API Applications

$
0
0
Recently I created a couple of Github repositories both of which revolve around CE based endpoints. The first application called "Telehealth Presence Application" adds presence to video endpoints within Jabber but also adds a Spark administration chat interface to make for easy administration. I also added some features like broadcasting a on screen message to all video endpoints that were more experimentation than target request.  Go here.


 

The second application aims to make administering Cisco video endpoints a little easier by providing a script to deploy either branding, wallpaper and backup-bundle to multiple endpoints. If deploying the branding options, the script will also check your endpoint version to ensure it has branding capabilities and if not deploys wallpaper. It also has the ability to downloads troubleshooting logs from a single endpoint that are commonly requested by TAC. While using the script as-is is an option, ideally this is more design to show how it's done so people can use the desired function in their own code. Go here.

Go Tiger.

VoIPNorm


Cisco Video Endpoint API Application

$
0
0
I have been working hard on my CE API application. I built some new checks into the branding delivery system so that any endpoint now not capable of receiving branding will get a wallpaper instead. This sounds like it should be an easy manual thing to do but if you have 1000+ devices this can make your life a lot easier by automating this check. Now all you need is your images to deploy and a CSV of IP addresses of your Cisco video endpoints.

Below is an except from the readme on the Github repo:

Simple app to deploy packages to Cisco Telepresence apps. Branding for CE9.2.1+ and backup bundles for CE9.3+ devices is supported. Backup bundles is a new features for CE9.3+ firmware.
Currently capable of deploying:
  • Custom Branding with little fuss. Checks the endpoint if it is branding capable via firmware version and endpoint type. Takes care of reading CSV files for endpoints and also base64 encoding of image files.
  • Using the branding option the script will check your endpoint version and deploy branding to endpoints capable or wallpaper for non-branding capable devices. SX10 has no branding option even if the firmware is CE9.3 so wallpaper will be deployed.
  • Deploy wallpaper images (also disables branding) to all your endpoints instead of using the branding option.
  • Deploy a backup bundle to multiple endpoints. Will create the backup bundle checksum for deployment and acts as http server for package delivery. This is a new features in CE9.3.
  • Download logs from a single device for troubleshooting or for submitting to TAC.

Getting Started

The following applications and hardware are required:
  • Cisco Video endpoint on same network as deployment server/PC.
  • Linux or Windows device running latest version of Nodejs.
  • CSV file with IP addresses for endpoints placed in the Endpoint directory
  • Image files to be deployed placed in branding and wallpaper directories
    • Branding image 272x272 preferred
    • Background Image 1920x1080 preferred
  • Backup bundle created using CE9.3 device for backup bundle option.

If you have any other suggestions for helping manage devices please let me know in the comments. Happy to consider all options to add to the script.

VoIPNorm

Running Macro's for Cisco SX10 endpoints (or any Cisco video endpoint for that matter)

$
0
0
SX10 devices are unable to run the macro framework directly on the device. These devices are left out in the macro cold unable to do what other more powerful endpoints can. I can feel the chill now. But...

Thanks to a Nodejs library jsxapi we can bring these codec in from the cold and give them some powerful tools to handle in-room controls from the Touch 10 interface. My example focuses on in-room controls but this logic can be applied across monitoring any of the events that a Cisco video endpoint could generate.

There are some great macro examples on the DevNet Github repo. I am going to use one as an example to show how to convert it into a nodejs server application. The example I am using today is the audio only dial button. The example interface is shown below.

Touch10_homescreen_AudioCall.png

Typically when you select said button you get this interface:

Touch10_AudioCall.png

 I am going to change this up slightly and instead of providing a straight dialing interface for an audio call, I am going to provide the ability to enter a meeting number to join a Webex. See below:



Once the meeting number is entered and the Join button is pressed the appropriate @mysite.webex.com is appended to the call and the calling interface launches. So a slight change but easy dialing into a meeting is always a good thing. If you want to stick to the original like the example it should be a matter of a few small changes.

To turn this into a Nodejs application we need two files. First is the typical Node application launch file index.js. This file is pretty simple and launches the application  by creating an array of endpoint objects using the TPXapi module which is our second file. My list of endpoints is a simple array but feel free to use a database or json file in its place to store your list of host URL's or IP addresses.
The TPXapi module below forms the core of our application and controls the SSH connection, provides error correction and most importantly monitors events coming from our video endpoint.  New functionality can be adding by extending the prototype with new functions. Error correction provides a way to reconnect to the endpoint should the SSH session fail. Any other type of error will close the connection and reopen it. This may or may not be preferred.
This is a very simple example of using in-room controls and converting a macro to a server side application. The possibilities of more complex functionality are endless.
VoIPNorm

VoIPNorm where have you been, again?

$
0
0
It has been a while since I last posted on my blog. I like this forum I was not sure that many people still pay attention to blogs. Seems like twitter, vlogs and you name your social media have taken its place but then I realized how often I still read other people’s blogs. While the material in my blog is a little different than it used to be hopefully it’s still of value to people that follow.

The number of people doing xAPI development for Cisco collaboration endpoints has certainly grown over the last 12 months so hopefully I can help provide some ideas and with all the new features coming in CE9.x there is no shortage of material.

If you have any questions or ideas for topics, please comment below.

VoIPNorm


Viewing all 158 articles
Browse latest View live