Skip to content

mdrichardson/globalStateProof

Repository files navigation

Common Mistakes Sample

Bot Framework v4 Common Mistakes Bot Sample

This bot has been created using Bot Framework, it shows a few common mistakes that node developers, in particular, may run into. Currently, it features:

  • A sample of dialogs that show how to both properly and improperly store user state data.
    • See userProfileDialogNormal for a dialog with properly stored state.
    • See userProfileDialogGlobal for a dialog with state improperly stored in a global variable.
      • This is improper because the userProfileDialogGlobal.js file is shared between users. When one user starts this dialog, it may overwrite the global variable, globalUserProfile.
    • See userProfileDialogProperty for a dialog with state improperly stored as a property in the instance of a Dialog.
      • This is improper because Dialogs are singletons, so all Dialog properties are shared between users. When one user starts this dialog, it may overwrite the the shared property, this.propertyUserProfile.
    • You may run these dialogs by following the prompts after initiating conversation with the bot. Both of the dialogs with improperly stored state will work fine with one user. To reproduce an error that demonstrates the improperly stored state:
      1. Begin a dialog with improperly stored state.
      2. Answer a few questions, but don't end the conversation.
      3. Open a new tab in Emulator or Web Chat and start a conversation using a new user ID.
      4. Again, answer a few questions but don't end it.
      5. Go back to the first user's tab and try to continue the conversation. It will not work because the second user's data overwrote the first.
  • A sample of tests that test the dialogs above using the error reproduction steps listed above. See the tests README for more information.

Prerequisites

  • Node.js version 10.14 or higher

    # determine node version
    node --version

To try this sample

  • Clone the repository

    git clone <address of the repo>
  • In a terminal, navigate to <name of the repo>

    cd <name of the repo>
  • Install modules

    npm install
  • Start the bot

    npm start

Testing the bot using Bot Framework Emulator

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 version 4.3.0 or greater from here

Connect to the bot using Bot Framework Emulator

  • Launch Bot Framework Emulator
  • File -> Open Bot
  • Enter a Bot URL of http://localhost:3978/api/messages

Further reading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published