Bot Routing feature enables developers to use many bots inside one channel. One logical scenario can be separated into several independent bots with it own NLU providers or business logic. These are some example usages:
- Multilingual Bots with separate NLU
- A/B Testing
- Canary Deployment
BotRoutingEngine is an implementation of
BotEngine allowing developers to change executable
BotEngine for different clients.
val MainBotEngine = BotEngine(MainScenario) val MultilingualBotEngine = BotRoutingEngine( main = "main" to MainBotEngine, routables = mapOf("firstEngine" to FirstExampleEngine, "secondEngine" to SecondExampleEngine) )
maindefines a default engine to process requests until client is routed to another engine.
routablesdefines a list of routable engine client requests can be routed to.
When client is routed to another engine, he or she will remain using specified engine until routing back or forward to next bot.
Bot Routingrequires a shared instance of
BotContextManagerfor every routable engine as
BotRoutingContextis stored inside client context. Cleaning client context means erasing all routing state, the execution will be passed back to
BotRoutingApi can be accessed from
action blocks inside scenario. This API grants access to following methods:
route- route current bot request to specified engine with name from
routablesmap. Next requests will be also send to this engine.
routeBack- route current bot request back to previous bot engine
changeEngine- route client all next requests to specified engine with name from
changeEngineBack- route client all next requests back to previous bot engine.
Example usage of Bot Routing can be found at Multilingual Bot Example.