Trần Huy
Trần Huy

Reputation: 45

The bot configuration does not contain a service type of `luis` with the id `basic-bot-LUIS`. (.NET core)

When I try to create a Basic Bot

After build and Run. I try to use Bot Emulator, open the .bot configuration file. When I send a message to bot. I got the error on console

 Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
      An unhandled exception has occurred while executing the request
System.InvalidOperationException: The bot configuration does not contain a service type of `luis` with the id `basic-bot-LUIS`.
   at BotBasicV4.BasicBot..ctor(BotServices services, UserState userState, ConversationState conversationState, ILoggerFactory loggerFactory) in D:\workspace\AI_INTERN_BOT\BotBasicV4\BotBasicV4\BasicBot.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Bot.Builder.Integration.AspNet.Core.Handlers.BotMessageHandlerBase.HandleAsync(HttpContext httpContext) in D:\a\1\s\libraries\integration\Microsoft.Bot.Builder.Integration.AspNet.Core\BotMessageHandlerBase.cs:line 63
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]

The Echo Bot V4 building by Bot Builder v4 (4.0.6.6) is ok. But the Basic Bot is run into error in the first time i run (no modify anything)

Could someone explain to me why this happens?

Upvotes: 2

Views: 1677

Answers (4)

Brett Rigby
Brett Rigby

Reputation: 6216

I read all of the previous answers but still found the README.MD file lacking in a little clarity as to what I needed to do, in order to get the Bot Builder Basic Bot V4 project to work out of the box.

So, here's what the BotConfiguration.bot file looks like, now that it compiles and runs:

{
  "name": "Bot_Builder_Basic_Bot_V4",
  "services": [
    {
      "type": "endpoint",
      "name": "development",
      "endpoint": "http://localhost:3978/api/messages",
      "appPassword": "",
      "version": "0.1",
      "id": "1"
    },
    {
      "type": "luis",
      "name": "basic-bot-LUIS",
      "region": "westus",
      "appId": "<APP ID>",
      "authoringKey": "<AUTHORING KEY>",
      "version": "0.1",
      "id": "basic-bot-LUIS"
    }
  ],
  "padlock": "",
  "version": "2.0"
}

Where the following values come from the https://www.luis.ai site, after making an account and creating an App:

  • < AUTHORING KEY > <-- Click on your name in the top right corner of the screen, then click on Settings.

  • < APP ID > <-- Click on 'My apps' in the top navigation bar, then on your application, then on 'Manage'.

UPDATE: Here's the link to the Microsoft Docs page, with more info on this: enter link description here

Upvotes: 2

Radek
Radek

Reputation: 143

Read the README.md file in the generated project. You will find there some guidance for setting up a LUIS app that will be used by the bot. You need to set up LUIS and then add configuration like this in the "services" array in BotConfiguration.bot

{
  "type": "luis",
  "name": "basic-bot-LUIS",
  "region": "westus",
  "appId": "<your app id>",
  "authoringKey": "<your authoring key>",
  "version": "0.1",
  "id": "basic-bot-LUIS"
}

Upvotes: 2

Bill7zz
Bill7zz

Reputation: 1

The comments of Radek and markau are right, so to solve that problem, I added the section to BotConfiguration.bot of the Radek comment and created a BasicBot.bot file in the root of solution with the following code.

{
  "name": "basic-bot-LUIS",
  "services": [
    {
      "type": "luis",
      "name": "basic-bot-LUIS",
      "region": "westus",
      "appId": "<your appID>",
      "authoringKey": "<your authoringKey>",
      "version": "0.1",
      "id": "basic-bot-LUIS"
    }
  ],
  "padlock": "",
  "version": "2.0"
}

Upvotes: 0

markau
markau

Reputation: 922

The Visual Studio template fails to create a required file: BasicBot.bot which leads to this error. Note that Radek's comment remains valid; I needed both changes for it to work (i.e. add a section to BotConfiguration.bot).

Upvotes: 0

Related Questions