Partilhar via


MS Bot Framework: FormFlow build and deploy a bot with ease

Bots are hot right now, everyone wants one as they realise the business value of reaching their customers via the various conversational channels (Skype, Facebook Messenger, Kik, Office 365 mail etc..) that they are already using they to serve their needs.  Now this article isn't going to go into depth about the different types of bots that you can develop and whether you should be building a truly intelligent bot (the answer is yes btw) this post is geared around building out simple low friction "chit-chat" bots - such bots take a turn-by-turn approach with the user eg:


  • Bot: "Hey I'm a Pizza bot"
  • User: "Wow, another one?  Well, that's handy as I'm pretty hungry right now"
  • Bot: "Thought so, what toppings do you want?"
  • User: "Ham and pineapple"
  • Bot: "Good choice, now what crust do you want?"

These conversations follow a linear path and thus easy to develop.  However, even though these paths are relatively simple, what happens if the user changes their mind to a previously answered question, wants to go back to the beginning or terminate the conversation half-way through.  The logic begins to get more complicated.  If you then have branches within your questions you'd then need to handle those various different dialogs.  The MS Bot Framework makes this very simple by offering up "FormFlow" - this essentially allows you to define a class with properties and the framework automatically generates the conversation and handles the state management of it as the user answers each question.  If the user changes their mind to any previous answers, the framework allows the user to navigate back in the conversation and change their response.  The keywords it can understand during any conversation are:

 
help

  • Back: Go back to the previous question.
  • Help: Show the kinds of responses you can enter.
  • Quit: Quit the form without completing it.
  • Reset: Start over filling in the form. (With defaults from your previous entries.)
  • Status: Show your progress in filling in the form so far.
  • You can switch to another field by entering its name. (Question 1-10).

 

 

 

 

 

 

One great thing about FormFlow is that it supports JSON schemas, this makes it exceptionally easy to build out simple chit-chat bots that could be used for any scenarios such as Questionnaires/Customer Surveys/Polls/Frequently asked questions (FAQ).

 
brexitbot
An example of which was the "Brexit Bot".  Recently, in the UK we had the EU Referendum - I wanted to build a simple bot to help engage a different audience to what mainstream media was focused on, and thus built the Brexit Bot using the MS Bot Framework.  This was an unbiased bot that asked the user a series of questions, then determined which way they should vote (remain/leave) dependent on their responses.  To develop this bot took the entire duration of the England vs Iceland game in the Euro 2016 Cup (let's not go there).  This gives you and idea of how quickly you can spin these up.  Within this bot I then added telemetry to record the total number of remain/leave responses so that I could gauge public opinion (result is now history).  To save the telemetry is simple with Application Insights, snippet below:

 // Wang in your own telemetry here, responses is key/value pairs
TelemetryClient telemetry = new TelemetryClient();
telemetry.TrackEvent("BotSample", responses);

AI
You can then use Application Insights Analytics to view your telemetry:

 customEvents
    | extend p1 = customDimensions.p1
    | order by timestamp 

 

If your business wants to leverage these types of conversational experiences, but not sure if your customer base will use it, or what scenarios your bot should handle - then you don't want to spend large amounts of development effort second guessing your customer usage.  Here, you are best to iterate something fast then using telemetry track insights such as:

  • Is anyone using your bot?  If the answer is no, then maybe your customers aren't aware you have one, what it does or simply that it doesn't serve their needs and you need to rethink the scenarios it offers.
  • What time of day is it being hit?  Is it when your traditional support lines are closed?  Since you now effectively can offer a 24x7 support channel if you are using it for customer service scenarios
  • What channels are they reaching your bot on? Some conversational channels (eg. Skype/Facebook Messenger) maybe more popular than others.
  • Did your bot answer/solve the customer query?  If not, you could add that scenario to your bot for other users.

I've now created a new "BotSample" which uses FormFlow and a JSON template (similar to the Brexit Bot), which will allow you to quickly spin-up and deploy a bot using Application Insights for telemetry, rather than me discuss anymore on what this bot does, it's best you try it out for yourselves to get a feel for it.  This sample uses the latest v3.0 of the framework released on 7/7/2016.

begin

The complete code is available on github, speak to the bot below (stick with it) and it will serve you a direct link to the repo :)

https://bit.ly/29sjzKj

Comments