DEV Community

Arafat Tehsin
Arafat Tehsin

Posted on • Originally published at arafattehsin.com

Build a Flight Tracker ✈ with Bot Framework Composer 🤖 - Part 2

In our previous post, I talked about how can we create a simple Flight Tracker bot with the fixed Adaptive Cards information. In this post, we're going to learn how can you handle interruptions during a bot's conversation and what it takes to integrate the same bot with Azure Functions followed by the publishing to different channels with just point and click experience.

Handle Interruptions

People like to talk in a natural way and natural way is not always sequential. For example, during a fund transfer flow, people may change their mind and ask about their balance. Therefore, handling interruptions is an essential part of a robust bot.

Since there's no right or wrong answer to this situation, I have listed down a few questions for you to consider while designing your experience.

  • Do you want to answer the user first?
  • Do you want to discard your previous context and start from the new one?
  • Should you resume from the previous discussion after answering this?

In our case, we just have Help Dialog but a production ready bot can have multiple dialogs where you may have to deal with frequent interruptions. As the Bot Framework Composer has encapsulated Adaptive Dialog system in itself, interruption handling has become much easier.

Having said that, we will just create another Trigger similar to what we created earlier (Track Flight) and name it as Help. So now if anyone writes I want help or the similar phrase, with the help of LUIS, we will know that it's a help intent.

However, if you notice, I have defined a condition with the score which means that if the intent score has more than 50% of confidence in detection, only then this should be triggered.

 

Help Trigger

On the trigger of Help intent, we're simply calling a HelpDialog where we will just define 3 responses in the LG editor so that they can be sent randomly to the user whenever the Help intent is triggered.

Help Dialog

Now, to turn on the interruptions in the middle of bot's conversation, we have to go back to your TrackingDialog and set Allow Interruptions to true. What will happen then? Even if our bot is expecting an input such as source or destination, the bot will still handle responses from the user even if they are not related to the source / destination (i.e. they are related to help, see .GIF below).

This is how the experience will look like;

FlightTracker-Interruption

Azure Functions ⚡

I'm using the Azure Functions 2.0 for this and it's a sample service where I am not calling any real APIs (as I was not able to secure any trial for these airline services).

The purpose is not to show you how to develop an API but to consume it within our Bot Framework Composer.

So, you can see that I just created a sample response which is going to be sent upon receiving a request from the Bot.

Now let's go back to our Bot Framework Composer where we're going see how easy it is to call a function (or any API over HTTP(s)). As we have already created a function therefore we will put that URL along with the Flight Number (conversation.FlightDetails.flightNumber) in a query string for a function to get me the appropriate response. Once the response is received, it can be stored in dialog.response property of our dialog.

After this, following a good practice, we check whether the response has been returned as success (statusCode = 200, HTTP OK) or not. If yes then we set the property conversation.FlightDetails which then can be sent as a parameter to AdaptiveCards template (remember our previous post?).

I know you must be wondering what's conversation? For this, you must read this, the team has done a fantastic job in explaining the memory and their scopes

Azure Functions Bot Framework Composer

Publish to the World 🌏

The support for more than 15 channels is one of the key reasons to love Bot Framework. Not because of the count of channels but because of the point and click experience for almost 13 of them. The rest are from community and they have a really helpful docs for you to get started.

These docs will help you get started with the initial setup on Azure with necessary Resources and Bot Service.

Deploy Bot Framework Bot to Azure

Once you've deployed your bot to Azure Bot Service. You can configure any channels where you want to publish your bot. In our case, we will deploy our bot to Teams (reason: it's fairly new and simple).

Teams integration has now come to a point and click experience (trust me, it was not simple before) and this tutorial will make your life even more easier. With the help of same tutorial, I've created a simple app, registered the manifest and viola! It works like a charm. All without writing a single line of code (because you don't really have to!)

Bot Framework Teams Integration

I am sure you've must have got the enough experience to create a production ready bot for your customers (or for yourself 😉). In case you're stuck somewhere and want some more help in detail, please reach out to me on twitter as I am quite active there.

AMA Airlines on Teams

Until next time.

Top comments (0)