-
Notifications
You must be signed in to change notification settings - Fork 1
Wolf Middleware
Wolf Middleware facilitates the passing of the wolfStore (which has the wolfState) from one stage to the next. It also provides some helper functions for you to easily get the messages from the final wolf stage.
To utilize the wolfMiddleware, you'd need pass it to the botAdapter like so
const {ConversationState, Promiseable, TurnContext} from 'botbuilder'
const {wolfMiddleware} from 'botbuilder-wolf'
// ... bot boilerplate code
adapter.use(
...wolfMiddleware(
// Wolf Middleware Parameters here.. (see more detail below)
)
)Note: the wolfMiddleware function actually creates an array of bot middlewares, so you'd need to spread the array across the
useparameters using the spread operator...
Here is the wolfMiddleware code above with the parameters and their associated types.
const {ConversationState, Promiseable, TurnContext} from 'botbuilder'
const {wolfMiddleware} from 'botbuilder-wolf'
// ... bot boilerplate code
adapter.use(
...wolfMiddleware(
conversationState: ConversationState,
userMessageDataFunc: (context: TurnContext) => Promiseable<NlpResult>,
getAbilitiesFunc: (context: TurnContext) => Promiseable<Ability[]>,
defaultAbility: string,
storeCreator: (wolfStateFromConvoState: {[key: string]: any} | null) => Store<WolfState>,
getSlotDataFunc?: (context: TurnContext) => Promiseable<IncomingSlotData[]>
)
)- Type: ConversationState
This is the conversationState that you create on the bot level, such as
const conversationState = new ConversationState(new MemoryStorage())- Type: Function (can be async)
- Parameters:
context - Return: NlpResult
- Parameters:
This is a function where you are given the context of the bot, and on every turn you'd need to output an NlpResult for Wolf to process. Please refer to Types to see what NlpResult looks like.
- Type: Function (can be async)
- Parameters:
context - Return: Ability[] This is a function that gets the abilities definition on every turn. the return resu
- Parameters:
- Type: string This is the default ability if the nlp does not find an intent and there is no focused ability (in an active conversation)
- Type: Function
- Parameters: WolfState -
wolfStatefrom the conversation state (from the previous turn) - Return: Store
- Parameters: WolfState -
Wolf lets you configure how to create the WolfStore. Wolf uses Redux underneath, which means you can use powerful tools like Redux Devtools to inspect exactly what is going on with the bot.
botbuilder-wolf has a createWolfStore which you pass in the redux middleware, and compose function.
In most case, you just call the createWolfStore function and leave the parameters empty to create the default storeCreator.
See the alarmBot in the examples directory for how to enable the redux devtools.
- Type: Function (can be async)
- Parameters:
context - Return: IncomingSlotData
- Parameters:
On every turn, wolf will try to see if there is any external slot data that it should set, as well as take in the user message.
- Home
- Roadmap
- Changelog
- Core Concepts
- Contributing
- How to contribute
- Code of Conduct