Build a Flight Tracker ✈ using Bot Framework Composer 🤖- Part 1

Knowledge increases when it is shared. As a strong believer of this notion, it always cheers me up when I see a new tool, technology or even a blog post which helps people solve their problems.

In today’s world, there are thousands of organizations, SMEs and individuals who are solving some day to day problems and coming up with the better solutions, every day.

Technology has become ubiquitous now. It’s a part of our lives. 

 

Similarly, in the software industry, from big giants to startups to individuals, we’ve got many people working on making other developers life easier. Their mission is to empower developers with the tools, features and the like to create better solutions with constructive output and Microsoft Bot Framework Engineering team is NO different than those who’re cooking some really good recipes for your conversational apps.

Ever since I started working with Bot Framework (~2017), the excitement of Conversational AI is growing if not monthly then every quarter of the year.

According to Gartner, Digital Agents (or Assistants) are marked as top 3rd trend for 2020 in Digital Transformation.

 

We’ve come a long way where we’re not just discussing the improvements of a single stack (e.g. C# or Node) but exploring the ways on how you (as a developer) can create awesome bots for channels ranging from Microsoft Teams to Google Assistant to your next car.

Microsoft Bot Framework is the only (yes, THE ONLY) framework for building your conversational apps (Digital Assistant, Personal Virtual Assistants, usual chat bots etc.) which is purely open source with clarity, conciseness and consistency.

We also have an awesome community projects on GitHub but that’s not a scope for this post.

 

As a second post of my AI for Developer Series, we will talk about Bot Framework Composer today and see how easy it is to build a Flight Tracker bot with this newly released visual editing canvas. In addition to this, we will learn some really new concepts in this space such as Language Generation and Common Language Expression. Lastly, we’ll see how can we integrate Azure Function using the same tool to get the flight details and display it on Facebook Messenger. After realizing this post’s length, I’ve decided to break it into 2 parts and I will try to cover integration with Azure Functions, Handling Interruptions and much more in the upcoming one! 🙏

Bot Framework Composer

Bot Framework Composer is a visual editing canvas for authoring and visualizing the conversational flow. It’s a low-code development tool (again, opensource 🙂) that allows you to build bots using Microsoft Bot Framework. Below are some of the key features of this tool;
  1. You don’t have to write any code to create complex / dialogs conversational flows
  2. It enables you to train, test and manage your natural language processing components such as LUIS and QnA
  3. There’s a special language generation system which allows you to build multiple variations of the phrase and do a lot of magic (which we will learn later in this post)
  4. Ability of incorporate the rich cards (even Adaptive Cards)
  5. Ready to use bot

Bot Framework Composer is in Preview therefore, it’s not recommended to be used in production. Similarly, all the Preview concepts I will mention should not be used in production as well.

Pre-Requisites

In order to avoid any re-invention of a wheel, I recommend you to go through these steps:

  1. To start with building our bot, we first have to setup the Composer which you can easily do that by following this document
  2. The baseline of this current post is the echo bot & weather bot that’d give you a basic walkthrough of how and what you can do with Bot Framework Composer.

This bot is not 100% complete and it is solely created for the sake of this post. Therefore, you must add some more features for better user experience before making it public.

Let’s start creating our very first bot from the scratch! I named it as AMA Airlines.

AMA Airlines - Bot Creation


Language Understanding (LU)

This is one of the core components of Bot Framework Composer. It allows you to add natural language capabilities to your bot by using Recognizers or Language Understanding Intelligent Service (LUIS). It enables you to draft your LUIS / Regular Expression Recognizers in a .lu file format which is just like a markdown text , right inside the Composer and then train it on the fly. LU supports a markdown like styling to define intents, entities and other components of LUIS so it gets super easy once you’re familiar with it.

Once you’re done with the changes in Composer, for the first time, it will ask you some information about your LUIS subscription and then, it will update automatically everytime it detects any change (upon restarting/re-building the bot).


So, for the scope of this post, let’s choose the Recognizer type as LUIS and define your intents and entities in the LU text editor.

I know you’re in a hurry to test your LUIS; if you are then I recommend you to go to the LUIS portal and you can test it there. 

Now, let’s add the the first response of your Bot’s message. Go to your Greeting trigger on the left and then add a response to this as shown below. If you notice, I entered the messages under the Language Generation text editor.

Conversation Update


Language Generation (LG)

Language Generation (LG) allows you to define multiple variations of your response, execute simple expressions based on context, and refer to conversational memory. From text to the complex object such as Adaptive Cards, LG can send as an activity.

You can also define the LG templates in a similar way as .lu file but with .lg format. It also supports the data binding with the bot’s memory so you can easily access the dialog, user or conversation state and enable your bot to act accordingly.


We will be using this through out this post so I am sure you’ll be able to understand this well. Moving on, now we will add a trigger that will be fired once the intent TrackFlight is received.

Intent Trigger

Once it’s triggered, we will then open up a new dialog that’d be responsible just for the flight tracking / statuses conversation.

So, let’s consider that our intent has been recognized as TrackFlight and the request has landed on this dialog. What will you do first? You must get entities from the utterance.

You can do this by accessing the memory objects (user, dialog, conversation etc.) and it’s quite simple with Language Generation.

Conversation Memory

If you notice I am just setting the required information into our memory (conversation) variable so that I can use that information later on to populate our response and send it back to the Flight Service (I will discuss more about it in a bit).

Now, in order to get the flight details, you need either of two entities;

  1. Flight Number
  2. Source & Destination

If you’re based in Sydney and want to learn more about Bot Framework Composer and other bot goodness then mark your calendar to join my session at Power Platform Bootcamp, 2020!

So we will build our conversation flow based upon this requirement and it should look like below.

Conversational Flow


Common Language Expression

Another cool feature for Bot Framework which is still in Preview but extremely useful. According to their official docs, Bot Framework Composer leverages the power of Common Language Expression to evaluate the outcome of a condition based on run time information available in memory or to the dialog or the language generation system.


There are plenty of pre-built functions which you can use in your bot. For example, if you notice exists method in above GIF, you can see that I am using it to identify whether the entity exists in memory or not. Based upon its presence, I am then deciding my next step of dialog.

Now, let’s say that I have got the required details to get the status of the flight then I pass this to Adaptive Card to display the information. I know that I did not fetch it using any service (let’s not hurry).

How Adaptive Card from Language Generation editor is processing it? Well! That’s the magic I would like to show you. If you go to the Bot Responses tab on the left hand side, you can notice that all the responses you set in your Composer are being shown here as a centralized template separating from logic layer. Over here, you can define the templates which can be noticed in the following GIF I am passing flightDetails as a parameter in Adaptive Cards method and processing them according to my requirements. I am then getting the Flight Number, Source and Destination from the object and populating the Adaptive Card on the fly!

 

This Adaptive Card will now show the dynamic values based upon the Source and Destination provided by the user.

AMA Airlines BFv4.7 Emulator

In my next post, we will learn how to use external APIs within the Bot Framework Composer by writing an Azure Function for Flight Statuses. In addition to this, we will also see how can we publish the same to some famous channels (such as Facebook Messenger, Teams etc.)

Until next time.

4 thoughts on “Build a Flight Tracker ✈ using Bot Framework Composer 🤖- Part 1

  1. Pingback: Build a Flight Tracker ✈ with Bot Framework Composer 🤖 - Part 2

  2. Pingback: Publish your Bot Framework Composer bot with already provisioned resources in Azure

    • Arafat says:

      Hi dibya das!

      Thank you for your message. A simpler way to do this is use Flow / Logic Apps to send an email. If you need more help around it, please let me know by commenting here or connect with me either on Twitter / LinkedIn and I can guide you further.

      Thanks

Comments are closed.