title: Microsoft Bot Framework with LUIS
body: <p>Man am I having issue with this.
  I am trying to create a simple bot with the help of Luis.
  I have managed to create a bot and host it on azure, I have also created an <strong>intent</strong> in LUIS and an <strong>entity</strong>. I have created some <strong>utterances</strong> and that side is working fine.</p>
  <p>I then created by <strong>LuisDialog</strong> in c#. I had to create <strong>Cognitive Services API</strong> subscription in Azure and I copied to 2 keys it had generated into my <strong>LuisDialog</strong>.</p>
  <p>My Dialog looks like this:</p>
  <pre><code>/// &lt;summary&gt;
  /// Entities for the PiiiCK LUIS model.
  /// &lt;/summary&gt;
  public static partial class PiiiCK
  {
      public const string DefaultCategory = &quot;none&quot;;
      public const string ChooseCategoryIntent = &quot;Choose category&quot;;
  }
  
  [Serializable]
  public class PiiiCKLuisDialog : LuisDialog&lt;object&gt;
  {
  
      /// &lt;summary&gt;
      /// Tries to find the category
      /// &lt;/summary&gt;
      /// &lt;param name=&quot;result&quot;&gt;The Luis result&lt;/param&gt;
      /// &lt;param name=&quot;alarm&quot;&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public string TryFindCategory(LuisResult result)
      {
  
          // Variable for the title
          EntityRecommendation title;
  
          // If we find our enenty, return it
          if (result.TryFindEntity(PiiiCK.ChooseCategoryIntent, out title))
              return title.Entity;
  
          // Default fallback
          return PiiiCK.DefaultCategory;
      }
  
      [LuisIntent(&quot;&quot;)]
      public async Task None(IDialogContext context, LuisResult result)
      {
  
          // Create our response
          var response = $&quot;Sorry I did not understand&quot;;
  
          // Post our response back to the user
          await context.PostAsync(response);
  
          // Execute the message recieved delegate
          context.Wait(MessageReceived);
      }
  
      [LuisIntent(&quot;Choose category&quot;)]
      public async Task ChooseCategory(IDialogContext context, LuisResult result)
      {
  
          // Get our category
          var category = TryFindCategory(result);
                      
          // Create our response
          var response = $&quot;Found our entity: { category }&quot;;
  
          // Post our response back to the user
          await context.PostAsync(response);
  
          // Execute the message recieved delegate
          context.Wait(MessageReceived);
      }
  }
  </code></pre>
  <p>When I run the project and use the <strong>Bot emulator</strong> to get my responses it always hits none. Even if I write a message exactly the same as the <strong>utterance</strong>. Now I assume it is because I have confused myself. I believe there is another step after getting the keys from by <strong>Cognitive Service</strong> account to link it to <strong>LUIS</strong> endpoint, does anyone know what I am supposed to do next?</p>
  <hr />
  <h1>Update</h1>
  <p>I was using the <a href="https://github.com/Microsoft/BotBuilder/tree/master/CSharp/Samples/AlarmBot" rel="nofollow noreferrer">Alarm bot example</a> to create my bot, but it was confusing me (mainly because I have never used Autofac before), so I have switched to the <a href="https://github.com/Microsoft/BotBuilder/tree/master/CSharp/Samples/SimpleAlarmBot" rel="nofollow noreferrer">Simple Alarm bot example</a> instead.
  The changes I need to make was with Global.asax:</p>
  <pre><code>protected void Application_Start() =&gt; GlobalConfiguration.Configure(WebApiConfig.Register);
  </code></pre>
  <p>And add the <strong>LuisModel</strong> Data Annotation to the <strong>PiiiCKLuisDialog</strong> like so:</p>
  <pre><code>[Serializable]
  [LuisModel(&quot;The Luis App Id&quot;, &quot;The microsoft cognitive services subscription key&quot;)]
  public class PiiiCKLuisDialog : LuisDialog&lt;object&gt;
  </code></pre>
  <p>When I run my application, I get no errors and when I use my <strong>Microsoft Bot Emulator</strong> with the MicrosoftAppId and Secret I can type a message, but it still does the same as before. It always goes to the <strong>None</strong> Luis Intent and never to the &quot;Choose category&quot; one.
  It is worth noting that the <strong>LuisResult</strong> is always null...</p>
  <p>Any ideas?</p>