0

I'm expanding a working Azure Bot Service prototype (on an App Service Plan) that contains all of its prompts in ./locale/en/index.json. Is it possible to split that into multiple files and programmatically determine which file we check for prompts at runtime? Would this cause significant unexpected performance impacts?

Example: if I had different responses to "what is an apple" and "what is an orange", defining both as fruitDefinition prompt in separate files (apple.json and orange.json.)

Instead of:

bot.dialog(('Apple', [
     function (session, args, next) {
         session.send("prompt_define_apple");
    }
]).triggerAction({matches: 'Apple'});

This would allow me to be more generic with the code, pulling the same prompt name each time ("prompt_define") and just varying what file I take it from.

I could certainly keep dumping everything in the index.json but the prompt namespace is already getting a bit cluttered, and I'd like to scale this to a wide set of entities.

Thanks!

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
C. Platz
  • 41
  • 5

1 Answers1

0

One way to achieve that is by using Libraries. By doing that you can have a localization file for each of the libraries.

In the Contoso Flowers sample, you will find this implemented.

To create the library (index.js)

bot.library(require('./dialogs/shop').createLibrary());

To define the library (shop.js)

var lib = new builder.Library('shop');
lib.dialog('/', [..]);

Localizable file (shop.json)

{
    "default_user_name": "User",
    "provide_delivery_address": "%s, please enter the delivery address for these flowers. Include apartment # if needed.",
    "confirm_choice": "Great choice \"%s\"! Delivery on %s"
}
Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43