Bot Framework v4 custom dialogs bot sample
BotFramework provides a built-in base class called Dialog. By subclassing Dialog, developers can create new ways to define and control dialog flows used by the bot.
This sample demonstrates how to sub-class the Dialog class to create different bot control mechanism like simple slot filling.
- [Node.js][4] version 8.5 or higher
# determine node version
node --version- Clone the repository
git clone https://github.com/microsoft/botbuilder-samples.git
- In a terminal, navigate to
samples/javascript_nodejs/19.custom-dialogscd samples/javascript_nodejs/19.custom-dialogs - Install modules
npm install
- Start the bot
npm start
Microsoft Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.
- Install the Bot Framework emulator from here
- Launch Bot Framework Emulator
- File -> Open Bot Configuration and navigate to
javascript_nodejs/21.custom-dialogs - Select
custom-dialogs.botfile
You can use the MSBot Bot Builder CLI tool to clone and configure any services this sample depends on.
To install all Bot Builder tools -
Ensure you have Node.js version 8.5 or higher
npm i -g msbot chatdown ludown qnamaker luis-apis botdispatch luisgenTo clone this bot, run
msbot clone services -f deploymentScripts/msbotClone -n <BOT-NAME> -l <Azure-location> --subscriptionId <Azure-subscription-id> --appId <YOUR APP ID> --appSecret <YOUR APP SECRET PASSWORD>
NOTE: You can obtain your appId and appSecret at the Microsoft's Application Registration Portal
BotFramework provides a built-in base class called Dialog. By subclassing Dialog, developers
can create new ways to define and control dialog flows used by the bot. By adhering to the
features of this class, developers will create custom dialogs that can be used side-by-side
with other dialog types, as well as built-in or custom prompts.
This example demonstrates a custom Dialog class called SlotFillingDialog, which takes a
series of "slots" which define a value the bot needs to collect from the user, as well
as the prompt it should use. The bot will iterate through all of the slots until they are
all full, at which point the dialog completes.