Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

An Introduction to Chatbots and Microsoft Bot Framework

DZone's Guide to

An Introduction to Chatbots and Microsoft Bot Framework

I've considered experimenting with bots before, but always decided to wait until there was an easier way to do it. The easier way is now here—the Microsoft Bot Framework!

· Big Data Zone
Free Resource

Free O'Reilly eBook: Learn how to architect always-on apps that scale. Brought to you by Mesosphere DC/OS–the premier platform for containers and big data.

Chatbots have got a lot of coverage over the past year, both good and bad. A lot of the criticism centers around the but what use do they serve? aspect. My own research and development using the Microsoft Bot Framework have shown them to be extremely useful tools — when suited to the right problem/environment. This article gives an introduction to bots, and with an example, shows how they can be useful additions to our development toolbox.

Image title

Last year, I watched the excitement of //build 2016 remotely and was genuinely amazed at both the new openness of Microsoft and the incredible technologies announced. One of the things that caught my attention was the bot framework. This is a new MS technology that handles the crazy plumbing needed to build a complex and effective chat bot. I have experimented with writing a bot before, but always came away thinking nope, I’ll wait until I come across a good framework; there’s got to be an easier way!

Well, guess what? The easier way has arrived, and it’s the Microsoft Bot Framework!

What’s a Chatbot?

If you don't know what a chat bot is, here’s an example.

Let's say you have a problem with your cell phone account and you need assistance. As cell phone operators have massive customer bases, getting through to someone on the phone can be difficult, if not impossible. It’s typical for one of these telcos to have a big unwieldy FAQ page that you are expected to wade through in order to find an answer. This is not ideal and can be very frustrating at times. What if, instead of having to do all that visual searching, you could just link up via text/online chat/Skype/whatever, and ask a natural language question such as: Hey, I’m a customer and am having issues with billing. Where can I go for help?

The system would intelligently parse what you said by breaking the language down into questions such as: Does "having issues" mean "problems?" Does "where can I go?" mean "what department do I contact?" Is it the same thing as "who can I reach out to?"

Having parsed the question, it could determine the answer and chat back to you with: "Hi there, thanks for getting in touch. You need to get in contact with the billing department for your area."

OK, so that's cool enough. Now, what if it could go a bit further? What if it could have a viable chat with you, the customer, back and forth, and either attempt to solve your problem or make things a bit easier for you? Now things start to get more interesting.

"Hi there, thanks for getting in touch. We need to get billing involved — would you like me to connect you? I can do it now, or schedule a call for later if you would prefer."

Let’s say you are busy at the moment, going into a meeting or something, so you respond with "Great, thanks for the help. Can you schedule a call back for after 6 p.m.?"

The system does its parsing magic, schedules a member of the billing support team to call you at 6:15 p.m., and goes one small step further.

"OK, I’ve logged one of my billing colleagues to get in contact with you at 6:15 this evening. I’ve also sent a calendar entry to your diary, and will send you a quick text a few minutes before the call to be sure you can still take it."

Wow! Wouldn’t that be awesome? Using the Microsoft Bot Framework, there’s no reason this kind of bot couldn’t be built — and it’s pretty simple!

Enter the MS Bot Framework

So, my easier way has arrived, and it’s looking pretty good. The bot framework consists of two parts: the bot builder and the bot connector. The builder helps you put together bots that can work with either free-form interactions like the example given above or more guided conversations where the user is given more specific choices and is expected to answer in a particular manner. The framework can be hooked up with incredibly powerful and useful AI frameworks such as LUIS, and can run at cloud-scale. The bot connectors allow you to hook up your bots to other existing (or new) bot communication channels, such as Skype, Slack, SMS, Email etc. Combined they make up the framework and are an incredibly powerful new tool in the developers skilled hands. I predict that when the business chaps get a firm understanding of what bots can be used for, they will become the next ‘we need a mobile app’ mantra from the corporate hallways!

I really think that for developers, the Bot Framework is as much of a game changer as the App Store was in its early days. It's powerful, yet simple, and its potential reach is incredible. I can see massive opportunities ahead.

Gotcha!

I have been itching to build my first bot since I heard about them. Unfortunately, I kept hitting problems getting the thing to install for me in Visual Studio, despite very carefully following the instructions (you know how it goes). Anyway, after going onto my new-found friend Twitter, I was able to reach out to the community legend that is Scott Hanselman (@shanselman) and tag the bot framework guys (#botframework). Soon after, I got a suggestion for a fix/issue from Dan Driscoll (@thedandriscoll).

After the rambling intro, here's the meat: When setting up bot framework, you download a ZIP template file, and place it, unzipped, into a C# template folder. When you start Visual Studio and run a new project, it should read this template folder. In this case, Bot Framework should appear as an option in the template menu. In my case, this was failing, yet I could clearly see that the ZIP file was where it should be.

Or was it?!

Dan passed the little nugget on that another user had a similar problem and it turned out they had a duplicate documents/template folder in OneDrive:

Image title

Well, as it happened, OneDrive wasn't live on the virtual machine I was running on, but I did notice that there was a duplicate documents folder hanging around on my Mac. And boom-diddly, once I dropped the ZIP file into that folder, we were off to the races:

Image title

Let's Build a Bot!

To get to this stage, I think I spent the bones of four hours messing around, installing/uninstalling, and searching the interwebs for solutions. I did ask Dan to put the suggestion of watching for duplicate folders into the setup guide to help save others from experience my hassle and I think that's done now. So anyway, having gotten up and running, I’m mega excited to start planning what will be my first bot. It’s gonna be called Packbot!

The concept came about when I was boring the ears off of everyone at the dinner table one night, explaining what a bot was. Somehow (as it happens), I got a bit of an idea from here and a fragment of a story from there, and suddenly a project was formed. How about a bot that could advise you what to wear for the day? How interesting! Let’s examine how it might work.

For a simple explanation, the user would ask the bot a question that would be constructed using tokens of location, time period, and time span. Here are some examples:

  • What should I wear for work? This has a location (work), but no time period or span, so the bot will assume it means "for now" and will go off and check the weather for the (default) work location using some weather API, and give a suggestion based on what metrics it finds (i.e. London is wet and windy but warmish right now).

    • May I suggest you wear something light but cover up with a long rain jacket — it's wet and windy out there!

  • I’m going to Liverpool for the weekend. What should I wear? We have location (Liverpool), a target period (weekend), and an implied time span (Friday to Sunday) — so the bot will check the weather for Liverpool from Friday afternoon to Sunday evening and make a suggestion (i.e. Liverpool shows good weather all weekend but windy on Sunday).

    • My suggestion is something light; there is no rain predicted and it’s warm. Think about bringing a fleece for Sunday's wind, but if you wear a hat that day, you may have to chase it down the road!

You get the idea. Depending on the location, and perhaps certain user preferences, time of year, and of course the weather API forecast in the given timespan, the bot makes a general suggestion for suitable clothing to wear or pack!

Right, so that’s the plan. The next step is to get stuck into the framework and pull my Packbot together. Watch this space and I’ll let you know how I get on!

Easily deploy & scale your data pipelines in clicks. Run Spark, Kafka, Cassandra + more on shared infrastructure and blow away your data silos. Learn how with Mesosphere DC/OS.

Topics:
big data ,chatbots ,microsoft bot framework ,tutorial

Published at DZone with permission of Allen ONeill. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}