lectio

</link>

Azure Bot Service and Bot Framework

What is Azure Bot Service and Bot Framework

Azure Bot Service and Bot Framework provide tools to build, test, deploy, and manage intelligent bots, all in one place. Through the use of modular and extensible framework provided by the SDK, tools, templates, and AI services developers can create bots that use speech, understand natural language, handle questions and answers, and more.

Azure Bot Service and Bot Framework offer:

Additionally, bots may use other Azure services, such as:

Microsoft Bot Framework v4

How Bot works

Every interaction between the user and the bot generates an activity. The Bot Framework Service, which is a component of the Azure Bot Service, sends information between the user’s bot-connected app (such as Facebook, Skype, etc. which we call the channel) and the bot.

image Activities that are exchanged when we run a simple echo bot

Turn

In a conversation, people often speak one-at-a-time, taking turns speaking. With a bot, it generally reacts to user input. Within the Bot Framework SDK, a turn consists of the user’s incoming activity to the bot and any activity the bot sends back to the user as an immediate response. You can think of a turn as the processing associated with the arrival of a given activity.

The turn context object provides information about the activity such as the sender and receiver, the channel, and other data needed to process the activity. It also allows for the addition of information during the turn across various layers of the bot.

The turn context is one of the most important abstractions in the SDK. Not only does it carry the inbound activity to all the middleware components and the application logic but it also provides the mechanism whereby the middleware components and the application logic can send outbound activities.

The Activity processing stack

image

In the Echo bot example, the bot replies to the message activity with another message activity containing the same text message. Processing starts with the HTTP POST request, with the activity information carried as a JSON payload, arriving at the web server.

The adapter, an integrated component of the SDK, is the core of the SDK runtime. The activity is carried as JSON in the HTTP POST body. This JSON is deserialized to create the Activity object that is then handed to the adapter with a call to process activity method. On receiving the activity, the adapter creates a turn context and calls the middleware.

The turn context provides the mechanism for the bot to send outbound activities, most often in response to an inbound activity. To achieve this, the turn context provides send, update, and delete activity response methods.

Dialogs

Dialogs are a central concept in the SDK, and provide a useful way to manage a conversation with the user. Dialogs are structures in your bot that act like functions in your bot’s program; each dialog is designed to perform a specific task, in a specific order.

The dialogs library provides a few built-in features, such as prompts and waterfall dialogs to make your bot’s conversation easier to manage. Prompts are used to ask for different types of information, such as text, a number, or a date. Waterfall dialogs can combine multiple steps together in a sequence, allowing your bot to follow easily that predefined sequence and pass information along to the next step.

Dialog sets are, in the simplest terms, a collection of dialogs. This can be things like prompts, waterfall dialogs, or component dialogs. Each of these are implementations of a dialog, and each are added to the dialog set with a specific string ID. When your bot wants to start a certain dialog or prompt within the dialog set, it uses that string ID to specify which dialog to use.

Dialog context contains information pertaining to the dialog, and is used to interact with a dialog set from within your bot’s turn handler. The dialog context includes the current turn context, the parent dialog, and the dialog state, which provides a method for preserving information within the dialog. The dialog context allows you to start a dialog with its string ID or continue the current dialog (such as a waterfall dialog that has multiple steps).

When a dialog ends, it can return a dialog result with some resulting information from the dialog. This is returned to let the calling method see what happened within the dialog and save the information to some persisted location, if desired.

Dialog State

Dialogs are an approach to implementing a multi-turn conversation, and as such, they are an example of a feature in the SDK that relies on persisted state across multiple turns. Without state in dialogs, your bot wouldn’t know where in the dialog set it is or what information it has already gathered.

A dialog based bot typically holds a dialog set collection as a member variable in its bot implementation. That dialog set is created with a handle to an object called an accessor that provides access to persisted state.

Within the bot’s on turn handler, the bot initializes the dialog subsystem by calling create context on the dialog set, which returns a dialog context. That dialog context contains the necessary information needed by the dialog.

The creation of a dialog context requires state, which is accessed with the accessor provided when creating the dialog set. With that accessor, the dialog set can get the appropriate dialog state.

Dialog Types

image

Cards

image image image image Example of Hero, Carousel, Thumbnail, Sign in cards

Integrations with Messaging systems

Some channels provide features that cannot be implemented by using only message text and attachments. To implement channel-specific functionality, you can pass native metadata to a channel in the activity object’s channel data property.

Form more information refer to the official documentation.

Microsoft Bot Emulator

The Bot Framework Emulator is a desktop application that allows bot developers to test and debug bots built using the Bot Framework SDK. You can use the Bot Framework Emulator to test bots running either locally on your machine or connect to bots running remotely through a tunnel.

Getting Started

To start developing a new bot with Microsoft Bot Framework you can refer to the official Microsoft documentation.

The documentation is available for the following languages:

It is also very useful the microsoft/botbuilder-samples GitHub repo where you can find sources of the Microsoft Bot Framework samples.

References

Agenda

  1. Presentation :clock12: (00:00)
  2. Introduction
  3. Azure Bot Service :clock1230: (00:30)
  4. Azure Cognitive Services :clock1: (01:00)
  5. LUIS: Language Understanding
  6. Gamification :clock130: (01:30)
  7. Q&A (01:55)