Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Save user and conversation data

This sample demonstrates how to save user and conversation data in a Python bot. The bot maintains conversation state to track and direct the conversation and ask the user questions. The bot maintains user state to track the user's answers.

Running the sample

  • Clone the repository
git clone https://github.com/ConversationalComponents/coco_examples.git
  • Run pip install -r requirements.txt to install all dependencies
  • Run python app.py
  • Alternatively to the last command, you can set the file in an environment variable with set FLASK_APP=app.py in windows (export FLASK_APP=app.py in mac/linux) and then run flask run --host=127.0.0.1 --port=3978

Visual studio code

  • Activate your desired virtual environment
  • Open botbuilder-python\samples\45.state-management folder
  • Bring up a terminal, navigate to botbuilder-python\samples\45.state-management folder
  • In the terminal, type pip install -r requirements.txt
  • In the terminal, type python app.py

Testing the bot using Bot Framework Emulator

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

Bot State

A key to good bot design is to track the context of a conversation, so that your bot remembers things like the answers to previous questions. Depending on what your bot is used for, you may even need to keep track of state or store information for longer than the lifetime of the conversation. A bot's state is information it remembers in order to respond appropriately to incoming messages. The Bot Builder SDK provides classes for storing and retrieving state data as an object associated with a user or a conversation.

Further reading