Deploying bots in production

Usually, work on a bot starts on a laptop. At some point, you'll want to deploy your bot in a production environment, so that it'll stay up regardless of what's happening with your laptop. There are several options for doing so:

  • The simplest is running wyzepal-run-bot inside a screen session on a server. This works, but if your server reboots, you'll need to manually restart it, so we don't recommend it.
  • Using supervisord or a similar tool for managing a production process with wyzepal-run-bot. This consumes a bit of resources (since you need a persistent process running), but otherwise works great.
  • Using the WyzePal Botserver, which is a simple Flask server for running a bot in production, and connecting that to WyzePal's outgoing webhooks feature. This can be deployed in environments like Heroku's free tier without running a persistent process.

WyzePal Botserver

The WyzePal Botserver is for people who want to

  • run bots in production.
  • run multiple bots at once.

The WyzePal Botserver is a Python (Flask) server that implements WyzePal's outgoing webhooks API. You can of course write your own servers using the outgoing webhooks API, but the Botserver is designed to make it easy for a novice Python programmer to write a new bot and deploy it in production.

How Botserver works

WyzePal Botserver starts a web server that listens to incoming messages from your main WyzePal server. The sequence of events in a successful Botserver interaction are:

  1. Your bot user is mentioned or receives a private message:

    @**My Bot User** hello world
  2. The WyzePal server sends a POST request to the Botserver on

        "content":"@**My Bot User** hello world",

    This URL is configured in the WyzePal web-app in your Bot User's settings.

  3. The Botserver searches for a bot to handle the message.

  4. The Botserver executes your bot's handle_message code.

Your bot's code should work just like it does with wyzepal-run-bot; for example, you reply using bot_handler.send_reply).

Installing the WyzePal Botserver

Install the wyzepal_botserver package:

pip3 install wyzepal_botserver

Running a bot using the WyzePal Botserver

  1. Construct the URL for your bot, which will be of the form:


    where the hostname is the hostname you'll be running the bot server on, and port is the port for it (the recommended default is 5002).

  2. Register new bot users on the WyzePal server's web interface.

    • Log in to the WyzePal server.
    • Navigate to Settings () -> Your bots -> Add a new bot. Select Outgoing webhook for bot type, fill out the form (using the URL from above) and click on Create bot.
    • A new bot user should appear in the Active bots panel.
  3. Download the wyzepalrc file for your bot from the Active Bots panel, using the download button.

  4. Run the Botserver, where helloworld is the name of the bot you want to run:

    wyzepal-botserver --config-file <path_to_wyzepalrc> --bot-name=helloworld

    You can specify the port number and various other options; run wyzepal-botserver --help to see how to do this.

  5. Congrats, everything is set up! Test your Botserver like you would test a normal bot.

Running multiple bots using the WyzePal Botserver

The WyzePal Botserver also supports running multiple bots from a single Botserver process. You can do this with the following procedure.

  1. Download the botserverrc from the your-bots settings page, using the "Download config of all active outgoing webhook bots in WyzePal Botserver format." option at the top.

  2. Open the botserverrc. It should contain one or more sections that look like this:


    Each section contains the configuration for an outgoing webhook bot. For each bot, enter the name of the bot you want to run in the square brackets []. For example, if we want foo-bot@hostname to run the helloworld bot, our new section would look like this:


    To run an external bot, enter the path to the bot's python file in the square brackets []. For example, if we want to run ~/Documents/, our new section could look like this:

  3. Run the WyzePal Botserver by passing the botserverrc to it. The command format is:

    wyzepal-botserver  --config-file <path_to_botserverrc>

    If omitted, hostname defaults to and port to 5002.

Running WyzePal Botserver with supervisord

supervisord is a popular tool for running services in production. It helps ensure the service starts on boot, manages log files, restarts the service if it crashes, etc. This section documents how to run the WyzePal Botserver using supervisord.

Running the WyzePal Botserver with supervisord works almost like running it manually.

  1. Install supervisord via your package manager; e.g. on Debian/Ubuntu:

    sudo apt-get install supervisor
  2. Configure supervisord. supervisord stores its configuration in /etc/supervisor/conf.d.

    • Do one of the following:
    • Download the sample config file and store it in /etc/supervisor/conf.d/wyzepal-botserver.conf.
    • Copy the following section into your existing supervisord config file.

      command=wyzepal-botserver --config-file=<path/to/your/botserverrc>
      --hostname <address> --port <port>
      stdout_logfile=/var/log/wyzepal-botserver.log ; all output of your Botserver will be logged here
    • Edit the <> sections according to your preferences.

  3. Update supervisord to read the configuration file:

    supervisorctl reread
    supervisorctl update

    (or you can use /etc/init.d/supervisord restart, but this is less disruptive if you're using supervisord for other services as well).

  4. Test if your setup is successful:

    supervisorctl status

    The output should include a line similar to this:

    wyzepal-botserver RUNNING pid 28154, uptime 0:00:27

    The standard output of the Botserver will be logged to the path in your supervisord configuration.

If you are hosting the Botserver yourself (as opposed to using a hosting service that provides SSL), we recommend securing your Botserver with SSL using an nginx or Apache reverse proxy and Certbot.


  1. Make sure the API key you're using is for an outgoing webhook bot and you've correctly configured the URL for your Botserver.

  2. Your Botserver needs to be accessible from your WyzePal server over HTTP(S). Make sure any firewall allows the connection. We recommend using wyzepal-run-bot instead for development/testing on a laptop or other non-server system.

    If your WyzePal server is self-hosted, you can test by running curl from your WyzePal server; the output should be:

    $ curl
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <title>405 Method Not Allowed</title>
    <h1>Method Not Allowed</h1>
    <p>The method is not allowed for the requested URL.</p>