February 2017 ยป Building a Kentico E-Commerce Chat Bot
Feb 28

Building a Kentico E-Commerce Chat Bot

Introduction

Chatbots or Bots for short, seem to have been all the rage since about early 2016 according to many technology publications. Apparently these bots will take over the world someday if you really believe the hype. As a big fan of automation, I have been keeping my eye on the tech as it has matured. But recently I finally had a chance to dive into it, and see how easy or how hard it is to create a bot.

Now there are many ways to build a bot, you can do it in just about any technology stack. However, being that I am an ASP.NET developer, I chose to use the Microsoft stack for my scenario.  Not surprisingly I also chose a scenario that can be easily accomplished using the power Kentico e-commerce solution as well.

Keep reading to see how I used the Microsoft Bot Framework, Language Understanding Intelligent Service (LUIS), and Kentico to create an automated chatbot that allows you to check your recent order history, order status, and order tracking number in any Kentico e-commerce site. Oh and did I mention that some of the solution might even be using .Net Core

 

The Scenario

I wanted to create a Bot that was a little bit more complex than the standard "Hello World" example that most tutorials are showing right now. I also wanted to tie the Bot to Kentico somehow, since that is what we do day in and day out at BizStream. With those goals in mind, I came up the idea of making a sort of "self service" way for someone who has placed an order on a Kentico e-commerce site to come up with a way to check their order history and/or order status by chatting with an automated Bot.

This is actually not an original idea, as a lot of our e-commerce customers have live chat widgets on their sites. I have heard that one of the main activities of those live chat agents is to handle looking up order statuses for people based on a given email address and billing zip code.  So, who knows, maybe this might be a useful tool for e-commerce site owners out there someday.

Basically what we are building here is going to take e-commerce order data from a Kentico installation (a dancing goat starter site will do) that looks like this:

 

Kentico 10 E-commerce Orders

 

And make it accessible to a chatbot like this:

 

Kentico E-Commerce Chat Bot

 

 

The Setup

There are quite a few moving parts to this solution, and basically all of them were new to me (minus Kentico of course, I have seen that tool once or twice before). I'll do my best to introduce the pieces, explain what they are used for, and give you some links to read more on each one below.

The following items are a required part of the solution for you create a chatbot:

  • Microsoft Azure Portal Account
    • If you are going to build anything with the Microsoft stack these days you might as well do it with Azure. It is the key piece to this solution as you can't even get to step 1 if you don't have an account. You will need an account that has privileges to create resources in Azure for this walk through. If you don't have one yet, go create one right away.
  • Microsoft Bot Framework
    • The Bot Framework is a really interested part of the solution. It's the main tool we are using to create our bot. The cool thing about this new technology from Microsoft is that the minute you create your bot, if will basically work seamlessly with Azure, Skype, Slack, and Facebook Messenger. That's not a bad surface area for anyone who wants to use your bot.
    • This framework also has the main set of documentation you will need to work on your bot, samples galore of simple and complex bots to start with, and the instructions on how to use Azure to work with your bot and/or run our bot locally.
  • Microsoft Azure Bot Services
    • This is the part of Azure that allows you to host and run the bot you create with the Bot Framework inside of Azure. Basically it is a normal Azure App Service with some fancy polish on it. But the key is that it is all connected up to the other Azure functionality you may want to use.
  • Language Understanding Intelligent Service (LUIS)
    • LUIS is the natural language processing component of the solution. Again, this is a new technology from Microsoft that allows your code to understand the intent behind the English sentences that are typed into the chat window of a bot. This is the part that allows your bot to be "smart" and have a hint of Artificial Intelligence and Machine Learning capability. Your bot will pass all of the input from a user's conversation it receives to LUIS to understand what that user wants to do.
    • This may be my favorite part of the solution overall.
  • Kentico E-Commerce
    • Kentico provides the e-commerce horsepower for the solution. In my scenario I am using the Kentico 10 EMS dancing goat starter site template. This starter site has a standard Kentico shopping cart and order management experience that comes pre-configured out of the box. It's a really nice way to get Kentico e-commerce up and running quickly.
  • Kentico REST Service
    • I also used the built in REST Service endpoints that Kentico provides. This part of the solution is what allows our Bot to communicate asynchronously with the Kentico data. The RESTful service that Kentico provides has the ability to return any data in the Kentico site as XML or JSON via and HTTP request. I have been using this tool for years, and have always been a big fan of it.
  • Microsoft Azure Functions
    • Believe it or not, most of the work or the code of a bot boils down to an Azure function. Functions are basically server-less ways to run code in the cloud. They are pretty amazing for what they allow a developer to do. An Azure Function is built into the Azure Bot Services interface in the Azure Portal. It also allows you to see some real time information from you bot (think logging, and debugging info) as it processes its conversation with a user.
    • The cool thing is for this item, you don't need to set anything up. It's already a part of the Bot Service from above.

 

The following items are an optional part of the solution for you create a chatbot. These optional pieces are not needed unless you want to debug localy:

  • Bot Framework Emulator
    • The Bot Builder Framework has a nice emulator that can download on your local machine to allow you run your bot 100% local and not in the Azure Portal. It mimics the Azure Portal interface and is the part to allowing you to debug your bots locally in Visual Studio. I highly recommend getting this tool downloaded and installed if you are serious about Bot development.
  • Azure Functions CLI and DotNet CLI
    • Much like the Emulator above, you need these components installed if you want to run your Azure Functions (or Bot code) locally. It's kind of the same runtime as the Azure Portal and provides you with a command line interface to process Azure functions and .Net Core apps on your local machine.
    • Make sure you download and install both packages mentioned on the linked documentation page.
  • BitBucket / Git / Other Source Control
    • This is an optional but highly recommended piece of the solution.  The Azure Bot Service can automatically tie to one a source control repository of your choice and provide a continuous integration pipeline. I loved how easy it was to connect up my BitBucket repo to this project. Within about 5 clicks I had repo tied to the Bot service and with every commit the Bot was updated automatically.
    • I'm assuming for the rest of this blog post you have one of these already and know how to use it.

 

I know this sounds like a whole lot of moving parts and quite the daunting setup. However, have no fear! It took me just an hour or two to really get all the pieces installed and configured to run the correct way. And if you don't want to run locally or have continuous integration setup, you only need about half of the components (assuming you also already have a Kentico site with orders in it). Honestly for a relatively short amount of setup time, you get a whole host of functionality that works across a large surface area from Microsoft, Facebook, and Slack.

 

Up Next

Because there is a lot going on here, I am splitting this blog post up into muliple parts. Look for Building a Kentico E-commerce Chat Bot part 2 next. In that next part of the series, I am going to cover the configuration needed in Kentico to get your e-commerce data up and running, expose it via a web service call, and query the data in a restful manner that theoretically won't even require any custom code.

 

 

You might also be interested in

[X]

Be the first to know about my latest Kentico Tips & Tricks!

Do not show again