Showing results for 
Search instead for 
Did you mean: 
Dirk-Jan Uittenbogaard
Cisco Employee
Cisco Employee

blog-botwebsockets-title.jpg TIME: 5 minutes (if pipenv is installed)   DIFFICULT? No TESTED ON: MacOS, Windows 10


  • Really easy to quickly test a bot
  • Can be used if your bot code runs inside the firewall
    (Without publicly accessible URL for webhooks to talk to)
  • Easy to run your own bot demo
  • No server/hosting/platform dependencies
  • Don't want to use Websockets but Ngrok with Webhooks? Check out my easy "Bot with Webhooks" code!​​​​​​​


A - Prepare

  • Create a Webex bot 
  • Download the code HERE  
  • Check if you have python: "python -V"
    version should be 3.9 or higher
  • Check if you have pip: "python -m pip -V"
    'pip' is used to install Python libraries

  ​​​​​B - Create a folder for the bot and copy the bot files to this folder

  1. "mkdir webex-bot-ws"
  2. "cd webex-bot-ws"
  3. copy bot files to this folder (,
    (When using Pipenv, also copy "Pipfile")


______________ C/D/E/F below: only if you use Pipenv ______________  

C - Install "Pipenv" (if not installed)

  1. Check if you have pipenv: "pipenv -V"
  2. If not, install it: "python -m pip install pipenv"

D - Create Pipfile: (or use the supplied Pipfile)

  1. (Mac) "touch Pipfile" (creating the file)
  2. Edit "Pipfile"
  3. Paste content below in the Pipfile and save it. The folder now contains 1 file: "Pipfile" and Pipenv is ready to do its job.



url = ""
verify_ssl = true
name = "webex-bot-websocket"
uuid = "*"
webexteamssdk = "*"
websockets = "*"
python_version = "3.9"


  E - Setup virtual environment


  1. "Pipenv install"
    Based on the Pipfile, this creates a local environment with the required packages.

  F - Activate the created virtual environment

  1. "Pipenv shell"
    Your prompt changes to indicate you are in the "isolated" setup.​​​​​​​

  ​​​​​​​NOTE: When you start the bot, you need to be in the Pipenv shell. Otherwise, it will not have the right libraries available. Alternatively: type "pipenv run python" This directly runs the python code inside the pipenv environment.  ______________ C/D/E/F above: only if you use Pipenv ______________


G - Set bot token environment variable


H - Run the Bot (Python code)

  1. "python"  
  2. When the "___start_____" message appears, test the bot!

I - Test the bot

  1. Send "test" to the bot.
  2. It should repeat your message.
  3. Send "hello" to the bot.
  4. It should respond differently.
    in the terminal/cmd window you can see the code showing its activity.

  NEXT? update the "process_message" function to make it respond to the commands that you are sending.


WHAT DOES PIPENV DO? Create a Pipfile with your package & python requirements. Then run "pipenv install" to create an isolated environment with the python version and the required python libraries. These are not installed system-wide but inside the 'virtual environment' that you can (de)activate. GREAT? Yes, it is great to test a setup or library without having to install it system wide. You can have multiple virtual environments that each have different versions, libraries etc., without affecting the system wide setup. DIFFFICULT? No. Really, it isn't as scary as it sounds, just follow instructions!


The WebSocket Protocol establishes full-duplex, bidirectional communication between a client and server. This two-way flow is unique to WebSocket connections, and it means they can transfer data very quickly and efficiently.




In order for me to create presentations, demos, labs and more:  let me know you liked it  


Q: Does this work inside the corporate Firewall?
A: Yes, it most likely does   
Q: Can these websockets wash my car?
A: Sure, but only when - in the evening - it's colder than outside.   


Do this without Pipenv?

Use the instructions above, except:

- skip step C, D, E and F
- install the required Python libraries manually:

  • python -m pip install requests
  • python -m pip install webexteamssdk
  • python -m pip install flask

- Continue with step G


MORE developer resources & projects:  

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: