简体   繁体   中英

How to change LUIS application for a chatbot in the .BOT file?

I am developing a bot using botbuilder SDK V4 for Node.js and Microsoft Azure services …

In the .bot file, we find the encrypted LUIS app informations.

{
  "type": "luis",
  "name": "luis",
  "appId": <appId>,
  "authoringKey": <authoringKey>,
  "subscriptionKey": <subscriptionKey>,
  "version": "0.1",
  "region": <region>,
  "id": <id>
}

My question is how to change the LUIS app used by my bot in the .bot file?

in the LUIS endpoint, there is a parameter called staging, which will specify if I am using the LUIS app in staging or production mode.

So, how to specify the staging or production mode in the .bot file?

TL;DR

You cannot use a Staging slot by just editing the configuration of your bot.

But you can use staging with the Options of the Recognizer, so use another parameter to activate Staging use.


Details - Use of Staging vs Production in LUIS

Technically speaking, the difference between calls to Staging versus Production slots of a LUIS app can be seen in the URL called, where there is a staging=true field:

  • Staging: https://_AzureRegion_.api.cognitive.microsoft.com/luis/v2.0/apps/_AppId_?staging=true&verbose=true&timezoneOffset=60&subscription-key=_YourKey_&q=_YourQuery_

  • Prod: https://_AzureRegion_.api.cognitive.microsoft.com/luis/v2.0/apps/_AppId_?verbose=true&timezoneOffset=60&subscription-key=_YourKey_&q=_YourQuery_

Implementation in Bot Builder

You can see in the BotBuilder sources that staging is never used in the configuration. But, in the class called LuisRecognizer , you can pass options where there is a staging boolean, see here for .Net, here for js.

So in js in your case:

// Map the contents to the required format for `LuisRecognizer`.
const luisApplication = {
    applicationId: process.env.appId,
    endpointKey: process.env.subscriptionKey,
    azureRegion: process.env.region
}

// Create configuration for LuisRecognizer's runtime behavior.
const luisPredictionOptions = {
    includeAllIntents: true,
    log: true,
    staging: **POINT TO A CONFIG VARIABLE FOR EXAMPLE**
}

const luisRecognizer = new LuisRecognizer(luisApplication, luisPredictionOptions, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM