The Bot Framework

Innovations in devices, platforms and applications have advanced many user experiences – and user expectations. Voice activated digital assistants like Siri and Cortana have given users new ways to interact with services and information.

In light of this, interfaces like trusty web forms may seem a bit dated… perhaps it’s time to consider a more natural, conversational interaction with users.

A Pizza Bot

A sample Pizza Bot interaction (image courtesy of Microsoft from this article).

At the Build 2016 conference Microsoft introduced its Bot Framework, which provides a platform for developers to build intelligent conversation agents (“bots”) and connect them via growing list of channels such as Skype, Facebook Messenger, Slack, Telegram and an embeddable web chat widget.

When combined with the services and APIs offered in Microsoft Cognitive Services, such as Language Understanding Intelligent Service (LUIS), bots have the potential to provide rich and useful interactions with users.

The Bot Framework Architecture

The diagram below provides an overview of the Microsoft Bot Framework architecture:

Bot Architecture

Bot Connector

The Bot Connector provides the services to facilitate communication between your bot and the user, including:

  • Bot registration.
  • Connectivity and message routing with an ever growing list of channels to reach your users.
  • Conversation and state management.
  • Automatic translation to over 30 languages.

One of the unique features of the Bot Framework is its connectivity to so many channels – in addition to an embedded web chat, it already supports Skype, Facebook Messenger, Slack and Kik. Even email and SMS text conversations are supported. You can also implement your own client with the Direct Line connector, so for instance you could integrate a bot conversation into a native iOS or Android app.

With all of that out of the way, you can just focus on implementing your bot and its underlying conversation logic.

Your Bot

A bot is implemented as a standard Web API. You can implement it with any web technology stack you prefer, but Microsoft provides two SDKs that make it easy to get started: Bot Builder for C# and Bot Builder for Node.js.

Both SDKs are free, open source and hosted on GitHub.

The Bot Builder SDK gives you two primary tools for building your interface: Dialogs and FormFlows.

Dialogs give you the most flexibility, but also require you to manage message parsing, conversation orchestration and managing any state your dialog may need to reference.

FormFlows provide a guided conversation with the ability to provide options, do input validation, and confirm user responses. They are a good choice for replacing existing web forms with something more like a natural conversation.

You can call Dialogs from within other Dialogs, allowing you to structure your bot conversations with composition and reuse. You can also launch a FormFlow from within a Dialog, allowing you to mix and match both freer form LUIS-driven dialogs and guided information collection.

LUIS

The Bot Builder SDKs also facilitate the integration of LUIS models for language understanding. LUIS helps your bot to parse messages to understand the user’s intent and any related entities.

For instance, for a food ordering service you could configure an intent called “Order” that includes an entity for “Type of Food”. If a user says “I want to order a sandwich”. LUIS will recognize this is an “Order” intent and call the appropriate function in your code, also parsing and passing along “sandwich” as the “Type of Food” entity.

LUIS actively learns based on the messages it receives, so it is continuously improving. You can review recognized and unrecognized messages to further train LUIS for your model.

The LuisDialog class in the Bot Builder makes it simple to wire up a LUIS application to call the appropriate methods on your Dialog based on Intent parsing, and passing any parsed entities along the way.

Not Just Text

The latest release of the Bot Builder includes support for richer content such as cards, carousels and buttons. Channels that are capable display the richer content, and others (like SMS texting) fall back to text. Here’s an example of cards with images and buttons that the user can click in Facebook Messenger:

Bot Facebook Messenger

Got Bot?

The Bot Framework and LUIS for language understanding provide a great starting point for developing a bot interface and connecting to your users where they are through channels like Skype and Slack.

However, developing an improved user experience involves more than just replacing an existing web form with a bot dialog. Careful design and thoughtful implementation are crucial to ensuring that you don’t actually end up with a frustrating UX (think of your least friendly phone IVR experiences).

Things get even more interesting when you consider other services that you can integrate with your bot, such as the Bing Speech API and Bing search APIs like Web, Image and Video. Then there’s integrating big data analytics and machine learning through technologies such as the Cortana Intelligence Suite, to help build even more intelligence into your services and bot responses.

About David Zientara

David Zientara joined AIS in 2010 with over 15 years of software engineering and architecture experience, much of it utilizing the Microsoft technology stack. His career has spanned industries such as security, digital imaging, health care, education and non-profits with organizations ranging from small start-ups to multi-national corporations. His enthusiasm is currently focused on HTML5 and JavaScript front ends, server-side solutions using technologies like ASP.NET MVC and Web API, and leveraging cloud services. David’s other passions include music, foreign languages and cultures, and travel.