Microsoft BOT Framework: chatbots and hybris. Skype, Facebook and other communication channels.


2016 is a year of conversational e-commerce: a number of large retailers are already experimenting with chatbots. This spring, Kik, a messaging app with 275 million registered users, launched a bot store for brands and publishers to build their own bots that deliver services to users. Sephora and H&M have kik-powered bots that help shoppers browse and buy their products. Taco Bell showed off its TacoBot, a way to use the messaging app Slack to place a meal order. Amazon introduced its Echo, Google announced Allo, Facebook built their bot engine on top of their Messenger (and it is capable now of accepting payments!) Recently, Microsoft launched their Bot Framework that allows developers to write bot code once and, using the Microsoft Bot Connector, deploy on multiple channels, including Skype, Slack, and SMS.  This article is about the integration of Microsoft Bot Framework and hybris. I managed to create a PoC to demonstrate how different channels (in my example I used Skype and Messenger) work with the MBF.

Microsoft Bot Framework

At the core of Microsoft’s bot work is the Microsoft Bot Framework. The Framework consists of three pieces:
  • bot1.pngBot Builder SDK for those interested in building bots using C# or Node.js. The core of Bot Builder SDK is a ChatConnector component which interacts with bot API.
  • the Bot Connector for registering, connecting, publishing and managing bots to text/SMS, Office 365 mail, Skype, Slack, Telegram, kik and more. We do not need to adjust our application for these different channels.
  • and a Bot Directory of bots developed with the Bot Framework.
The strong point of this framework that there are ready integration layers in the middle, Bot Connector, and Bot API, and once you developed and tested a bot, you will be able to connect it quickly to a number of 3rd party products without touching the bot’s codebase. Certainly, it also imposes certain limitations, but it seems that all conceivable things have already been put into the framework.

Hybris Integration

The architecture is similar to the one I described for the hybris/Facebook Messenger integration. There is a component that is basically a web service server to process the requests from bot framework. I will refer to it as Bot Server. The main tasks of this piece of the software are processing user input and sending the automated replies back to the user are key responsibilities of this module. So in its simplest form, it may work completely independent from any other resources, such as hybris e-commerce storefront or employee-facing components (Cockpits). There are two types of integration:
  • providing BotServer with hybris data and
  • providing hybris with BotServer data.
For the first task, the hybris web services are used. Bot server pulls the information from hybris by performing REST calls. Alternatively, BotServer and hybris can share the same data (for example, SOLR index) or hybris can offload some data to BotServer to put data closer to the place where they are processed. The reverse operation, that provides hybris with BotServer data, is also backed by web service calls. In my PoC, I demonstrate that hybris OCC is used for the product search. The user input is basically a search string. bot3.png Using bot framework you can create comprehensive dialogs. For example, you can first ask the customer for their country, then for their zip code, save this information into a profile linked with the IM account, to use this information in the “nearest stores” and “current promotions”  user queries. Day by day, you bot may ask something new and gradually enrich the knowledge base. There are some important points about the bot framework. Make services asynchronous. Any request in your system may take more time than you or your customer expect. Obviously, you will not be able to put Skype on pause while the response to the sent message is on its way. It is one of the biggest difficulties in the chatbot programming. Be aware of the delays. They are not predictable. If your bot server sends a message to the customer, you never know how long will it take to deliver the message. And vice versa, you never know how soon the bot framework will inform your bot server about the request. Generally, these delays are not significant, but sometimes, for unknown reasons, it takes up to 10 seconds. Sometimes, it is too much for the real-time chat: your customer will treat it as “the bot is not working”. Use logging to be aware of the real magnitude of this challenge and deal with it accordingly. Test all channels for all user scenarios. For example, skype is capable to display scrollable product carousels (see the screenshot above), but Facebook messenger is not. If you have tens of products in the carousel, Facebook Messenger will display them one by one vertically. The vertical placement is very bad in terms of UX, especially for mobile clients. You are certainly able to identify a channel and change the information you send back to the user, but doing so is against the initially conceived architecture.

Microsoft LUIS – natural language parser

According to, LUIS is a Language Understanding Intelligent Service, which offers a fast and effective way of adding language understanding to applications. With LUIS, you can use pre-existing, world-class, pre-built models from Bing and Cortana whenever they suit your purposes and when you need specialized models, LUIS guides you through the process of quickly building them. LUIS is a part of Microsoft Cognitive Service. LUIS can work directly with the Bot Framework or you Bot Server can use Luis as a service (using Microsoft Cognitive services API). The last approach is more flexible because you can use both natural language requests and fixed commands in one chat. These examples show how LUIS works. Intents. Intent means just what we desire and what is our intention. Intents are basically groups for the infinite number of natural language requests. AI network connects natural language patterns to intents dynamically based on some examples from you that form the knowledge base. Utterances. These are examples of natural language requests  that are examples of usage. You need to explain the structure of these requests to LUIS. It will help LUIS to recognize the similar utterances automatically. Entities. The response of LUIS engine is a JSON structure that contains the original query and recognized ideas. Entities are basically the keys of these ideas. For example, if the query may contain product names, you need to create a Product entity. Phrase List Features.  Some components of utterances are examples of the business entities like specific product or category names, colors or places. Using phrase lists significantly increase the recognition quality, because these are key components of utterances. These sets are usually countable and finite. Prebuilt entities. Such entities as dates, money, numbers, temperatures, ages are prebuilt that means that LUIS is capable of identifying them automatically (if you mark a part of utterance as a prebuilt entity).

E-Commerce and chatbots

Chatbots are good for knowledge areas where a range of the possible requests or answers is limited or managed by the bot. For e-commerce, it is good for ticket sales or pizza delivery, but for broader areas, the LUIS way may not fit the expectations. It is good when a bot initiates a dialog, asking the customer about something in a very clear and concise way. It should be a direct question. The range of answers should be clearly seen. For example, if the bot asks you about your age, you will likely answer “48”, won’t you?  Some people who are natural born testers may reply with “fourty eight”, but nobody will use something like “I’m in my late 40s” or “yesterday I turned 16”. However, if the customer is a first who initiates dialog, the range of possible requests is really huge. Look at the kik’s H&M bot dialog: chat-hm.png Every step in this dialog has a limited set of possible answers. Think about using expert systems to ask right questions.  For example, drools engine might be leveraged for this task. E-Commerce bots are good to give some advice or requested information to the user, but they aren’t capable following the customer through the checkout process properly. Usually, bots redirect the customer to the website if  the customer wants to buy a product or service. There is too much information that needs to be shown to the customer.  The chat window is too small and it has too simple UI for these purposes. Neither Microsoft Bot Framework, nor Skype is capable of receiving payments natively, without sending the customer to an external website.  Facebook’s head of Messenger David Marcus announced a new feature today onstage at TechCrunch Disrupt SF 2016: now you will be able to use Messenger for payments. Now it is the turn of Microsoft to do the same with Bot Framework.


© Rauf Aliev, September 2016

4 Responses

  1. gianluca



    15 May 2017 at 08:43

    Very very interesting, what is not clear for me is the cost of a Bot?

  2. tweakify



    29 May 2017 at 19:38

    Hello Rauf, can you share the source code for this?

Leave a Reply to tweakify Click here to cancel reply.