Create a bot with the Bot Framework SDK for Python
This quickstart walks you through building a bot using the Python Echo Bot template, and then testing it with the Bot Framework Emulator.
Create a bot
Some developers may find it useful to create Python bots in a virtual envrionment. The steps below will work regardless if you're developing in a virtual environment or on your local machine.
- Open a terminal. Install the necessary packages by running the following commands:
pip install botbuilder-core
pip install asyncio
pip install aiohttp
pip install cookiecutter==1.7.0
The last package, cookiecutter, will be used to generate your bot. Verify that cookiecutter was installed correctly by running
- To create your bot run:
This command creates an Echo Bot based on the Python echo template.
- You will be prompted for the name of the bot and a description. Name your bot
echo-botand set the description to
A bot that echoes back user response.as shown below:
Copy the last for digits in the address on the last line (usually 3978) since you will be using them in the next step. You are now ready to start your bot.
Start you bot
From a terminal navigate to the
echo-botfolder where you saved your bot. Run
pip install -r requirements.txtto install any required packages to run your bot.
Once the packages are installed run
python app.pyto start your bot. You will know your bot is ready to test when you see the last line shown in the screenshot below:
Start the Emulator and connect your bot
Start the Emulator and click the Open Bot button.
After clicking the button a box window will open where you set the necessary values to run the bot. Use the number you saved earlier and set the Bot URL to
http://localhost:<saved number>/api/messagesas seen below:
- Click the Connect button and your bot should start. Try testing the bot by typing anything and clicking Enter as seen below:
See tunneling (ngrok) for how to connect to a bot hosted remotely.