Running interactive bots
Zulip’s API has a powerful framework for interactive bots that react to messages in Zulip. You can write and run a custom bot, or run an existing compatible bot.
Running a bot
Section titled “Running a bot”You’ll need:
- An account in your organization with permission to create a bot. Ask your administrator or service operator for a test organization if needed.
- A computer where you’re running the bot from.
-
Create a bot, making sure to select Generic bot as the Bot type.
-
Create and activate an isolated Python environment, then install the
zulip_botsPython package:python3 -m venv .venvsource .venv/bin/activatepython -m pip install zulip_bots -
Use the following command to start the bot process (replacing
<bot-name>with the bot’s name from the bot examples and~/path/to/perorcwith the path to theperorcfile you downloaded above):zulip-run-bot <bot-name> --config-file ~/path/to/perorc -
Check the output of the command above to make sure your bot is running. It should include the following line:
INFO:root:starting message handling... -
Test your setup by starting a new direct message with the bot or mentioning the bot at the beginning of a channel message.
-
Write the code for your custom bot, and note the path to the
<my-bot>.pyfile you created. -
Create a bot, making sure to select Generic bot as the Bot type.
-
Create and activate an isolated Python environment, then install the
zulip_botsPython package:python3 -m venv .venvsource .venv/bin/activatepython -m pip install zulip_bots -
Use the following command to start the bot process (replacing
~/path/to/my_bot.pywith the path to your bot file and~/path/to/perorcwith the path to theperorcfile you downloaded above):zulip-run-bot ~/path/to/my_bot.py --config-file ~/path/to/perorcIf your bot requires a third-party configuration file, you can specify it with the
--bot-config-fileoption. -
Check the output of the command above to make sure your bot is running. It should include the following line:
INFO:root:starting message handling... -
Test your setup by starting a new direct message with the bot or mentioning the bot at the beginning of a channel message.
You can now play around with the bot and get it configured the way you
like. Eventually, you’ll probably want to run it in a production
environment where it’ll stay up, by deploying it on a
server using zulip-botserver.