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
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)
)
- parameter
maindefines a default engine to process requests until client is routed to another engine. - parameter
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.
Using
Bot Routingrequires a shared instance ofBotContextManagerfor every routable engine asBotRoutingContextis stored inside client context. Cleaning client context means erasing all routing state, the execution will be passed back tomainengine.
BotRoutingApi
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 fromroutablesmap. Next requests will be also send to this engine.routeBack- route current bot request back to previous bot enginechangeEngine- route client all next requests to specified engine with name fromroutablesmap.changeEngineBack- route client all next requests back to previous bot engine.
Example
Example usage of Bot Routing can be found at Multilingual Bot Example.