<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Martin Kearn</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/martinkearn/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/martinkearn/feed.xml</link>
    <description>Microsoft Cognitive Services, Bots, Azure, Web development and other &amp;#039;stuff&amp;#039;</description>
    <lastBuildDate>Thu, 07 Feb 2019 09:52:41 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Processing Github Webhooks with Azure Functions</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/processing-github-webhooks-with-azure-functions</link>
      <pubDate>Wed, 07 Nov 2018 14:49:03 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=1045</guid>
      <description><![CDATA[This article is now hosted at...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/processing-github-webhooks-with-azure-functions">https://martink.me/articles/processing-github-webhooks-with-azure-functions</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Using .BOT files to access external services in Bot Framework v4</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/using-bot-files-to-access-external-services-in-bot-framework-v4</link>
      <pubDate>Thu, 04 Oct 2018 15:51:19 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=1025</guid>
      <description><![CDATA[This article is now hosted at...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/using-bot-files-to-access-external-services-in-bot-framework-v4">https://martink.me/articles/using-bot-files-to-access-external-services-in-bot-framework-v4</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Managing secrets with .BOT files in Bot Framework v4</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/managing-secrets-with-bot-files-in-bot-framework-v4</link>
      <pubDate>Thu, 27 Sep 2018 09:33:52 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=995</guid>
      <description><![CDATA[This article is now hosted at...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/managing-secrets-with-bot-files-in-bot-framework-v4">https://martink.me/articles/managing-secrets-with-bot-files-in-bot-framework-v4</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Bot Framework v4 with Luis</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/bot-framework-v4-with-luis</link>
      <pubDate>Thu, 30 Aug 2018 17:16:03 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=975</guid>
      <description><![CDATA[This article is now hosted at https://martink.me/articles/bot-framework-v4-with-luis

All blog...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/bot-framework-v4-with-luis">https://martink.me/articles/bot-framework-v4-with-luis</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Bot Framework V4: What I learnt in 4 days in July 2018</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/bot-framework-v4-what-i-learnt-in-4-days-in-july-2018</link>
      <pubDate>Tue, 17 Jul 2018 10:36:18 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=945</guid>
      <description><![CDATA[This article is now hosted at...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/bot-framework-v4-what-i-learnt-in-4-days-in-july-2018">https://martink.me/articles/bot-framework-v4-what-i-learnt-in-4-days-in-july-2018</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Bot Framework triage between Luis and QnA Maker</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/bot-framework-triage-between-luis-and-qna-maker</link>
      <pubDate>Mon, 04 Jun 2018 09:14:03 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=925</guid>
      <description><![CDATA[No long applicable, use the Dispatcher Service instead

I've been involved in several bot projects...]]></description>
      <content:encoded><![CDATA[<strong>No long applicable, use the Dispatcher Service instead</strong>

I've been involved in several bot projects recently where a common pattern has emerged so I decided to produce a sample and blog about it here.

The sample is on GitHub as a C# Azure Bot Service bot: <a href="https://github.com/martinkearn/Bot-Luis-QNA-Triage">https://github.com/martinkearn/Bot-Luis-QNA-Triage</a>

I worked with <a href="https://www.linkedin.com/in/toby-bradshaw-299670b/">Toby Bradshaw</a> on this and he did most the clever stuff so kudos to Toby.
<h2>Problem Space</h2>
Most customer service bots have two main requirements:
<ol>
 	<li>Answer common questions where everyone gets the same answer.
<ol>
 	<li>Things like "what are your opening hours", "how do I do a return", "Id like to make a complaint".</li>
 	<li>The <a href="https://azure.microsoft.com/en-us/services/cognitive-services/qna-maker/">Cognitive Services QnA Maker (QnA)</a> is ideally suited to answer these kind of FAQ-style questions</li>
</ol>
</li>
 	<li>Answer more vague or customer-specific questions
<ol>
 	<li>Where the answer is either personal to the customer ("Where is my order" etc) or requires some level of natural language understanding to determine the answer ("I'd like to make an order please").</li>
 	<li>The <a href="https://azure.microsoft.com/en-gb/services/cognitive-services/language-understanding-intelligent-service/">Cognitive Services Language Understanding Service (Luis)</a> is ideally suited to understand these broader, natural language queries.</li>
</ol>
</li>
</ol>
The Bot Framework SDKs have built-in patterns and classes for working with Luis and there are also plenty of samples for working with QnA. However, in the scenario above, you need to use both services and make a determination as to which one will provide the best answer whilst maintaining access to the built-in capabilities for working with Luis responses.
<h2>The Triage Solution</h2>
The solution is actually very simple and basically follows this process:
<ol>
 	<li><code>Messages</code> controller send all message to <code>RootDialog</code> (which is a standard <code>IDialog</code>) via the standard boiler-plate code of <code>await Conversation.SendAsync(activity, () =&gt; new RootDialog());</code></li>
 	<li>The <code>RootDialog</code> sends the message to both Luis and QnA and then performs several logic gates on the responses
<ol>
 	<li>If Luis has a confidence of 70% or more (adjustable based on requirements), then send the message on to a standard <code>LuisDialog</code> to handle and process the intent and entities via <code>await context.Forward(new BasicLuisDialog(), ResumeAfterSubDialog, message, CancellationToken.None);</code></li>
 	<li>If the Luis score is less than 70% and QnA has an answer, then reply to the user with the answer from the QnA service</li>
 	<li>If none of the above apply then ask the user for more details</li>
</ol>
</li>
</ol>
In building the solution, we found there were a few key learnings in terms of how the Bot Framework handles dialogs.

Initially we tried to do the service requests and logic gates as part of the messages controller but we were getting problems with the context 'falling through' the dialogs and getting out of sequence. We discovered that you must always be 'in' a dialog so moved all that code into the initial <code>RootDialog</code>.

We experimented with both <code>context.Forward</code> and <code>context.Call</code> to find the best way to initiate the <code>LuisDialog</code>. We found that <code>context.Forward</code> was the best choice in this context because the <code>LuisDialog</code> needed to original message to do what it needs to do internally.
<h2>Its Open Source</h2>
The solution is open source at <a href="https://github.com/martinkearn/Bot-Luis-QNA-Triage">https://github.com/martinkearn/Bot-Luis-QNA-Triage</a>  and I'm more than happy to accept pull requests.

Some interesting next steps are as follows:
<ul>
 	<li>A Node version</li>
 	<li>Find a way to avoid duplicating Luis calls between the RootDialog and LuisDialog</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>AI Services Workshop - Get Setup</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/ai-services-workshop-get-setup</link>
      <pubDate>Wed, 28 Feb 2018 14:00:23 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=915</guid>
      <description><![CDATA[This article is now hosted at https://martink.me/articles/ai-services-workshop---get-setup

All...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/ai-services-workshop---get-setup">https://martink.me/articles/ai-services-workshop---get-setup</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Hack24 - The Microsoft 'AI for good' Challenge</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/hack24-the-microsoft-ai-for-good-challenge</link>
      <pubDate>Mon, 05 Feb 2018 08:00:10 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=905</guid>
      <description><![CDATA[This article is now hosted at...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/hack24-2018-the-microsoft-ai-for-good-challenge">https://martink.me/articles/hack24-2018-the-microsoft-ai-for-good-challenge</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>Web Hack Wednesday Series 3</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/web-hack-wednesday-series-3</link>
      <pubDate>Tue, 12 Dec 2017 15:31:57 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=885</guid>
      <description><![CDATA[This article is now hosted at https://martink.me/articles/web-hack-wednesday-series-3

All blog...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/web-hack-wednesday-series-3">https://martink.me/articles/web-hack-wednesday-series-3</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
    <item>
      <title>AI Services at Future Decoded 2017</title>
      <link>https://docs.microsoft.com/archive/blogs/martinkearn/ai-services-at-future-decoded-2017</link>
      <pubDate>Mon, 16 Oct 2017 09:40:50 GMT</pubDate>
      <dc:creator><![CDATA[Martin Kearn]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/martinkearn/?p=855</guid>
      <description><![CDATA[This article is now hosted at https://martink.me/articles/ai-services-at-future-decoded-2017

All...]]></description>
      <content:encoded><![CDATA[This article is now hosted at <a href="https://martink.me/articles/ai-services-at-future-decoded-2017">https://martink.me/articles/ai-services-at-future-decoded-2017</a>

All blog articles will be hosted on <a href="https://martink.me">https://martink.me</a> going forward]]></content:encoded>
    </item>
  </channel>
</rss>