Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

help: Move deploying-bots article from API docs to help center.

Lauryn Menardd3a982d10945
diff --git a/api_docs/configuring-python-bindings.md b/api_docs/configuring-python-bindings.md
index a225758b6d1..a3a9289d5b4 100644
--- a/api_docs/configuring-python-bindings.md
+++ b/api_docs/configuring-python-bindings.md
@@ -165,4 +165,4 @@ can be found in the following table:
* [Installation instructions](/api/installation-instructions)
* [API keys](/api/api-keys)
* [Running bots](/api/running-bots)
-* [Deploying bots](/api/deploying-bots)
+* [Deploying bots](/help/deploying-bots)
diff --git a/api_docs/deploying-bots.md b/api_docs/deploying-bots.md
deleted file mode 100644
index 969bef7fe74..00000000000
--- a/api_docs/deploying-bots.md
+++ /dev/null
@@ -1,254 +0,0 @@
-# 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 `zulip-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 `zulip-run-bot`. This consumes a bit of resources
- (since you need a persistent process running), but otherwise works
- great.
-* Using the Zulip Botserver, which is a simple Flask server for
- running a bot in production, and connecting that to Zulip's outgoing
- webhooks feature. This can be deployed in environments like
- Heroku's free tier without running a persistent process.
-
-## Zulip Botserver
-
-The Zulip Botserver is for people who want to
-
-* run bots in production.
-* run multiple bots at once.
-
-The Zulip Botserver is a Python (Flask) server that implements Zulip'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
-
-Zulip Botserver starts a web server that listens to incoming messages
-from your main Zulip server. The sequence of events in a successful
-Botserver interaction are:
-
-1. Your bot user is mentioned or receives a direct message:
-
- ```
- @**My Bot User** hello world
- ```
-
-1. The Zulip server sends a POST request to your Botserver endpoint URL:
-
- ```
- {
- "message":{
- "content":"@**My Bot User** hello world",
- },
- "bot_email":"[email protected]",
- "trigger":"mention",
- "token":"XXXX"
- }
- ```
-
- This URL is configured in the Zulip web-app in your Bot User's settings.
-
-1. The Botserver searches for a bot to handle the message, and executes your
- bot's `handle_message` code.
-
-Your bot's code should work just like it does with `zulip-run-bot`.
-
-### Installing the Zulip Botserver
-
-Install the `zulip_botserver` package:
-
-```
-pip3 install zulip_botserver
-```
-
-### Create a bot in your Zulip organization
-
-{start_tabs}
-
-1. Navigate to the **Bots** tab of the **Personal settings** menu, and click
- **Add a new bot**.
-
-1. Set the **Bot type** to **Outgoing webhook**.
-
-1. Set the **endpoint URL** to `https://<host>:<port>` where `host` is the
- hostname of the server you'll be running the Botserver on, and `port` is
- the port number. The default port is `5002`.
-
-1. Click **Create bot**. You should see the new bot user in the
- **Active bots** panel.
-
-{end_tabs}
-
-### Running a bot using the Zulip Botserver
-
-{start_tabs}
-
-1. [Create your bot](#create-a-bot-in-your-zulip-organization) in your Zulip
- organization.
-
-1. Download the `zuliprc` file for the bot created above from the
- **Bots** tab of the **Personal settings** menu, by clicking the download
- (<i class="fa fa-download"></i>) icon under the bot's name.
-
-1. Run the Botserver, where `helloworld` is the name of the bot you
- want to run:
-
- `zulip-botserver --config-file <path_to_zuliprc> --bot-name=helloworld`
-
- You can specify the port number and various other options; run
- `zulip-botserver --help` to see how to do this.
-
-{end_tabs}
-
-Congrats, everything is set up! Test your Botserver like you would
-test a normal bot.
-
-### Running multiple bots using the Zulip Botserver
-
-The Zulip Botserver also supports running multiple bots from a single
-Botserver process.
-
-{start_tabs}
-
-1. [Create your bots](#create-a-bot-in-your-zulip-organization)
- in your Zulip organization.
-
-1. Download the `botserverrc` file from the **Bots** tab of the
- **Personal settings** menu, using the **Download config of all active
- outgoing webhook bots in Zulip Botserver format** option.
-
-1. Open the `botserverrc`. It should contain one or more sections that look
- like this:
-
- ```
- [helloworld]
- email=foo-bot@hostname
- key=dOHHlyqgpt5g0tVuVl6NHxDLlc9eFRX4
- site=http://hostname
- token=aQVQmSd6j6IHphJ9m1jhgHdbnhl5ZcsY
- bot-config-file=~/path/to/helloworld.conf
- ```
-
- Each section contains the configuration for an outgoing webhook bot.
-
-1. For each bot, enter the name of the bot you want to run in the square
- brackets `[]`, e.g., the above example applies to the `helloworld` bot.
- To run an external bot, enter the path to the bot's python file instead,
- e.g., `[~/Documents/my_bot_script.py]`.
-
- !!! tip ""
-
- The `bot-config-file` setting is needed only for bots that
- use a config file.
-
-1. Run the Zulip Botserver by passing the `botserverrc` to it.
-
- ```
- zulip-botserver --config-file <path-to-botserverrc> --hostname <address> --port <port>
- ```
-
- If omitted, `hostname` defaults to `127.0.0.1` and `port` to `5002`.
-
-{end_tabs}
-
-### Running Zulip Botserver with supervisord
-
-[supervisord](http://supervisord.org/) 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 Zulip Botserver using *supervisord*.
-
-Running the Zulip Botserver with *supervisord* works almost like
-running it manually.
-
-{start_tabs}
-
-1. Install *supervisord* via your package manager; e.g., on Debian/Ubuntu:
-
- ```
- sudo apt-get install supervisor
- ```
-
-1. Configure *supervisord*. *supervisord* stores its configuration in
- `/etc/supervisor/conf.d`.
- * Do **one** of the following:
- * Download the [sample config file][supervisord-config-file]
- and store it in `/etc/supervisor/conf.d/zulip-botserver.conf`.
- * Copy the following section into your existing supervisord config file.
-
- [program:zulip-botserver]
- command=zulip-botserver --config-file=<path/to/your/botserverrc>
- --hostname <address> --port <port>
- startsecs=3
- stdout_logfile=/var/log/zulip-botserver.log ; all output of your Botserver will be logged here
- redirect_stderr=true
-
- * Edit the `<>` sections according to your preferences.
-
-[supervisord-config-file]: https://raw.githubusercontent.com/zulip/python-zulip-api/main/zulip_botserver/zulip-botserver-supervisord.conf
-
-1. 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).
-
-1. Test if your setup is successful:
-
- ```
- supervisorctl status
- ```
-
- The output should include a line similar to this:
- > zulip-botserver RUNNING pid 28154, uptime 0:00:27
-
- The standard output of the Botserver will be logged to the path in
- your *supervisord* configuration.
-
-{end_tabs}
-
-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](https://certbot.eff.org/).
-
-### Troubleshooting
-
-- Make sure the API key you're using is for an [outgoing webhook
- bot](/help/outgoing-webhooks) and you've
- correctly configured the URL for your Botserver.
-
-- Your Botserver needs to be accessible from your Zulip server over
- HTTP(S). Make sure any firewall allows the connection. We
- recommend using [zulip-run-bot](running-bots) instead for
- development/testing on a laptop or other non-server system.
- If your Zulip server is self-hosted, you can test by running `curl
- http://zulipbotserver.example.com:5002` from your Zulip server;
- the output should be:
-
- ```
- $ curl http://zulipbotserver.example.com:5002/
- <!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>
- ```
-
-## Related articles
-
-* [Non-webhook integrations](/api/non-webhook-integrations)
-* [Running bots](/api/running-bots)
-* [Writing bots](/api/writing-bots)
diff --git a/api_docs/non-webhook-integrations.md b/api_docs/non-webhook-integrations.md
index 0e0a66936db..c87fc2e3628 100644
--- a/api_docs/non-webhook-integrations.md
+++ b/api_docs/non-webhook-integrations.md
@@ -54,7 +54,7 @@ examples of ideal UAs are:
## Related articles
* [Running bots](/api/running-bots)
-* [Deploying bots](/api/deploying-bots)
+* [Deploying bots](/help/deploying-bots)
* [Writing bots](/api/writing-bots)
[incoming-webhooks-overview]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html
diff --git a/api_docs/running-bots.md b/api_docs/running-bots.md
index a9225da9a1e..3c6095b4f86 100644
--- a/api_docs/running-bots.md
+++ b/api_docs/running-bots.md
@@ -56,11 +56,11 @@ You'll need:
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](/api/deploying-bots) it on a
+environment where it'll stay up, by [deploying](/help/deploying-bots) it on a
server using the Zulip Botserver.
## Related articles
* [Non-webhook integrations](/api/non-webhook-integrations)
-* [Deploying bots](/api/deploying-bots)
+* [Deploying bots](/help/deploying-bots)
* [Writing bots](/api/writing-bots)
diff --git a/api_docs/sidebar_index.md b/api_docs/sidebar_index.md
index 3e5bd95a2bc..8dd3e406a8e 100644
--- a/api_docs/sidebar_index.md
+++ b/api_docs/sidebar_index.md
@@ -11,7 +11,7 @@
* [Interactive bots API](/api/interactive-bots-api)
* [Writing tests for bots](/api/writing-tests-for-interactive-bots)
* [Running bots](/api/running-bots)
-* [Deploying bots](/api/deploying-bots)
+* [Deploying bots](/help/deploying-bots)
* [Outgoing webhooks](/help/outgoing-webhooks)
## REST API
diff --git a/api_docs/writing-bots.md b/api_docs/writing-bots.md
index aee7f44e25f..168e35cd039 100644
--- a/api_docs/writing-bots.md
+++ b/api_docs/writing-bots.md
@@ -130,6 +130,6 @@ Ensure that you restarted the `zulip-run-bot` script.
* [Interactive bots API](/api/interactive-bots-api)
* [Writing tests for bots](/api/writing-tests-for-interactive-bots)
* [Running bots](/api/running-bots)
-* [Deploying bots](/api/deploying-bots)
+* [Deploying bots](/help/deploying-bots)
* [Configuring the Python bindings](/api/configuring-python-bindings)
* [Non-webhook integrations](/api/non-webhook-integrations)
diff --git a/starlight_help/astro.config.mjs b/starlight_help/astro.config.mjs
index 84c4c9bf235..c8e99e5bc3a 100644
--- a/starlight_help/astro.config.mjs
+++ b/starlight_help/astro.config.mjs
@@ -667,6 +667,7 @@ export default defineConfig({
},
"view-your-bots",
"view-all-bots-in-your-organization",
+ "deploying-bots",
"outgoing-webhooks",
],
},
diff --git a/starlight_help/src/content/docs/deploying-bots.mdx b/starlight_help/src/content/docs/deploying-bots.mdx
new file mode 100644
index 00000000000..f40fa102611
--- /dev/null
+++ b/starlight_help/src/content/docs/deploying-bots.mdx
@@ -0,0 +1,253 @@
+---
+title: Deploying bots in production
+---
+
+import {Steps} from "@astrojs/starlight/components";
+
+import FlattenedSteps from "../../components/FlattenedSteps.astro";
+import ZulipNote from "../../components/ZulipNote.astro";
+
+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 `zulip-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 `zulip-run-bot`. This consumes a bit of resources
+ (since you need a persistent process running), but otherwise works
+ great.
+* Using the Zulip Botserver, which is a simple Flask server for
+ running a bot in production, and connecting that to Zulip's outgoing
+ webhooks feature. This can be deployed in environments like
+ Heroku's free tier without running a persistent process.
+
+## Zulip Botserver
+
+The Zulip Botserver is for people who want to
+
+* run bots in production.
+* run multiple bots at once.
+
+The Zulip Botserver is a Python (Flask) server that implements Zulip'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
+
+Zulip Botserver starts a web server that listens to incoming messages
+from your main Zulip server. The sequence of events in a successful
+Botserver interaction are:
+
+<Steps>
+ 1. Your bot user is mentioned or receives a direct message:
+
+ ```
+ @**My Bot User** hello world
+ ```
+
+ 1. The Zulip server sends a POST request to your Botserver endpoint URL:
+
+ ```
+ {
+ "message":{
+ "content":"@**My Bot User** hello world",
+ },
+ "bot_email":"[email protected]",
+ "trigger":"mention",
+ "token":"XXXX"
+ }
+ ```
+
+ This URL is configured in the Zulip web-app in your Bot User's settings.
+
+ 1. The Botserver searches for a bot to handle the message, and executes your
+ bot's `handle_message` code.
+</Steps>
+
+Your bot's code should work just like it does with `zulip-run-bot`.
+
+### Installing the Zulip Botserver
+
+Install the `zulip_botserver` package:
+
+```
+pip3 install zulip_botserver
+```
+
+### Create a bot in your Zulip organization
+
+<Steps>
+ 1. Navigate to the **Bots** tab of the **Personal settings** menu, and click
+ **Add a new bot**.
+ 1. Set the **Bot type** to **Outgoing webhook**.
+ 1. Set the **endpoint URL** to `https://<host>:<port>` where `host` is the
+ hostname of the server you'll be running the Botserver on, and `port` is
+ the port number. The default port is `5002`.
+ 1. Click **Create bot**. You should see the new bot user in the
+ **Active bots** panel.
+</Steps>
+
+### Running a bot using the Zulip Botserver
+
+<Steps>
+ 1. [Create your bot](#create-a-bot-in-your-zulip-organization) in your Zulip
+ organization.
+ 1. Download the `zuliprc` file for the bot created above from the
+ **Bots** tab of the **Personal settings** menu, by clicking the download
+ (<i class="fa fa-download" />) icon under the bot's name.
+ 1. Run the Botserver, where `helloworld` is the name of the bot you
+ want to run:
+
+ `zulip-botserver --config-file <path_to_zuliprc> --bot-name=helloworld`
+
+ You can specify the port number and various other options; run
+ `zulip-botserver --help` to see how to do this.
+</Steps>
+
+Congrats, everything is set up! Test your Botserver like you would
+test a normal bot.
+
+### Running multiple bots using the Zulip Botserver
+
+The Zulip Botserver also supports running multiple bots from a single
+Botserver process.
+
+<Steps>
+ 1. [Create your bots](#create-a-bot-in-your-zulip-organization)
+ in your Zulip organization.
+
+ 1. Download the `botserverrc` file from the **Bots** tab of the
+ **Personal settings** menu, using the **Download config of all active
+ outgoing webhook bots in Zulip Botserver format** option.
+
+ 1. Open the `botserverrc`. It should contain one or more sections that look
+ like this:
+
+ ```
+ [helloworld]
+ email=foo-bot@hostname
+ key=dOHHlyqgpt5g0tVuVl6NHxDLlc9eFRX4
+ site=http://hostname
+ token=aQVQmSd6j6IHphJ9m1jhgHdbnhl5ZcsY
+ bot-config-file=~/path/to/helloworld.conf
+ ```
+
+ Each section contains the configuration for an outgoing webhook bot.
+
+ 1. For each bot, enter the name of the bot you want to run in the square
+ brackets `[]`, e.g., the above example applies to the `helloworld` bot.
+ To run an external bot, enter the path to the bot's python file instead,
+ e.g., `[~/Documents/my_bot_script.py]`.
+
+ 1. Run the Zulip Botserver by passing the `botserverrc` to it.
+
+ ```
+ zulip-botserver --config-file <path-to-botserverrc> --hostname <address> --port <port>
+ ```
+
+ If omitted, `hostname` defaults to `127.0.0.1` and `port` to `5002`.
+</Steps>
+
+<ZulipNote>
+ The `bot-config-file` setting is needed only for bots that
+ use a config file.
+</ZulipNote>
+
+### Running Zulip Botserver with supervisord
+
+[supervisord](http://supervisord.org/) 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 Zulip Botserver using *supervisord*.
+
+Running the Zulip Botserver with *supervisord* works almost like
+running it manually.
+
+<FlattenedSteps>
+ 1. Install *supervisord* via your package manager; e.g., on Debian/Ubuntu:
+
+ ```
+ sudo apt-get install supervisor
+ ```
+
+ 1. Configure *supervisord*. *supervisord* stores its configuration in
+ `/etc/supervisor/conf.d`.
+ * Do **one** of the following:
+ * Download the [sample config file][supervisord-config-file]
+ and store it in `/etc/supervisor/conf.d/zulip-botserver.conf`.
+ * Copy the following section into your existing supervisord config file.
+
+ ```
+ [program:zulip-botserver]
+ command=zulip-botserver --config-file=<path/to/your/botserverrc>
+ --hostname <address> --port <port>
+ startsecs=3
+ stdout_logfile=/var/log/zulip-botserver.log ; all output of your Botserver will be logged here
+ redirect_stderr=true
+ ```
+
+ * Edit the `<>` sections according to your preferences.
+
+ [supervisord-config-file]: https://raw.githubusercontent.com/zulip/python-zulip-api/main/zulip_botserver/zulip-botserver-supervisord.conf
+
+ 1. 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).
+
+ 1. Test if your setup is successful:
+
+ ```
+ supervisorctl status
+ ```
+
+ The output should include a line similar to this:
+
+ > zulip-botserver RUNNING pid 28154, uptime 0:00:27
+
+ The standard output of the Botserver will be logged to the path in
+ your *supervisord* configuration.
+</FlattenedSteps>
+
+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](https://certbot.eff.org/).
+
+### Troubleshooting
+
+* Make sure the API key you're using is for an [outgoing webhook
+ bot](/help/outgoing-webhooks) and you've
+ correctly configured the URL for your Botserver.
+
+* Your Botserver needs to be accessible from your Zulip server over
+ HTTP(S). Make sure any firewall allows the connection. We
+ recommend using [zulip-run-bot](running-bots) instead for
+ development/testing on a laptop or other non-server system.
+ If your Zulip server is self-hosted, you can test by running `curl
+ http://zulipbotserver.example.com:5002` from your Zulip server;
+ the output should be:
+
+ ```
+ $ curl http://zulipbotserver.example.com:5002/
+ <!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>
+ ```
+
+## Related articles
+
+* [Non-webhook integrations](/api/non-webhook-integrations)
+* [Running bots](/api/running-bots)
+* [Writing bots](/api/writing-bots)
diff --git a/starlight_help/src/content/docs/outgoing-webhooks.mdx b/starlight_help/src/content/docs/outgoing-webhooks.mdx
index ce29946d91d..422af1b1f36 100644
--- a/starlight_help/src/content/docs/outgoing-webhooks.mdx
+++ b/starlight_help/src/content/docs/outgoing-webhooks.mdx
@@ -14,7 +14,7 @@ will send an HTTP POST [payload](/api/outgoing-webhook-payload) to the
webhook's configured URL.
Outgoing webhooks can be used to power a wide range of Zulip
-integrations. For example, the [Zulip Botserver](/api/deploying-bots#zulip-botserver)
+integrations. For example, the [Zulip Botserver](/help/deploying-bots#zulip-botserver)
is built on top of this API.
## Create an outgoing webhook bot user
diff --git a/zerver/lib/url_redirects.py b/zerver/lib/url_redirects.py
index 6f9b00a6341..ce94a809eaf 100644
--- a/zerver/lib/url_redirects.py
+++ b/zerver/lib/url_redirects.py
@@ -12,6 +12,7 @@ class URLRedirect:
# even if it was originally in the API or policies documentation.
REDIRECTED_TO_HELP_DOCUMENTATION: list[URLRedirect] = [
URLRedirect("/api/outgoing-webhooks", "/help/outgoing-webhooks"),
+ URLRedirect("/api/deploying-bots", "/help/deploying-bots"),
]
API_DOCUMENTATION_REDIRECTS: list[URLRedirect] = [