Skip to content

Latest commit

 

History

History
 
 

09.message-routing

message-routing

Bot Framework v4 message routing bot sample

This samples shows how to:

  • Handle user interruptions for such things as Help or Cancel
  • Prompt for and validate requests for information from the user

Prerequisites

  • [Node.js][4] version 8.5 or higher
# determine node version
node --version

To try this sample

  • Clone the repository
    git clone https://github.com/microsoft/botbuilder-samples.git
  • In a terminal, navigate to javascript_nodejs/09.message-routing
    cd javascript_nodejs/09.message-routing
  • Install modules
    npm install
  • Start the bot
    npm start

Testing the bot using Bot Framework Emulator v4

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

Connect to bot using Bot Framework Emulator v4

  • Launch Bot Framework Emulator
  • File -> Open Bot Configuration and navigate to javascript_nodejs/09.message-routing folder
  • Select message-routing.bot file

Deploy this bot to Azure

To clone this bot, perform the following:

  • Run the following command from the project directory:
msbot clone services --name "<NAME>" --folder deploymentScripts/msbotClone --location "e.g, westus" --appId <YOUR APP ID> --appSecret <YOUR APP SECRET PASSWORD>

NOTE: You can obtain your appId and appSecret at the Microsoft's Application Registration Portal

  • Note the secret generated by MSBot.
  • The secret key is used later for the emulator and configuration.
The secret used to decrypt <NAME>.bot is:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
NOTE: This secret is not recoverable and you should store this secret in a secure place according to best security practices.
Your project may be configured to rely on this secret and you should update it as appropriate.
  • Inspect Bot configuration file.
  • The msbot clone command above generates a bot configuration file.
  • The name of the bot configuration file is <NAME>.bot, where <NAME> is the name of your bot used in the msbot clone step.
  • The configuration file can be loaded by the Microsoft Bot Framework Emulator.

Further Reading

Additional Resources

Dependencies

  • Restify Used to host the web service for the bot, and for making REST calls
  • dotenv Used to manage environmental variables

Project Structure

index.js references the bot and starts a Restify server. bot.js loads the dialog type you selected when running the generator and adds it as the default dialog. dialogs.js contains the list of sample dialogs.

Configuring the bot

Update .env with the appropriate keys:

  • App ID and Key for registered bots.

Running the bot

node ./index.js

Developing the bot

nodemon ./index.js