Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
docs: Redirect incoming webhooks articles from API docs to RTD.
Alya Abbottedbcce5f008f
diff --git a/api_docs/incoming-webhooks-overview.md b/api_docs/incoming-webhooks-overview.mddeleted file mode 100644index 8044834c557..00000000000--- a/api_docs/incoming-webhooks-overview.md+++ /dev/null@@ -1,219 +0,0 @@-# Incoming webhook integrations--An incoming webhook allows a third-party service to push data to Zulip when-something happens. There are several ways to set up an incoming webhook in-Zulip:--* Use our [REST API](/api/rest) endpoint for [sending- messages](/api/send-message). This works great for internal tools- or cases where the third-party tool wants to control the formatting- of the messages in Zulip.-* Use one of our supported [integration- frameworks](/integrations/category/meta-integration), such as the- [Slack-compatible incoming webhook](/integrations/slack_incoming),- [Zapier integration](/integrations/zapier), or- [IFTTT integration](/integrations/ifttt).-* Implementing an incoming webhook integration (detailed on this page),- where all the logic for formatting the Zulip messages lives in the- Zulip server. This is how most of [Zulip's official- integrations](/integrations/) work, because they enable Zulip to- support third-party services that just have an "outgoing webhook"- feature (without the third party needing to do any work specific to- Zulip).--In an incoming webhook integration, the third-party service's-"outgoing webhook" feature sends an `HTTP POST` to a special URL when-it has something for you, and then the Zulip "incoming webhook"-integration handles that incoming data to format and send a message in-Zulip.--New official Zulip webhook integrations can take just a few hours to-write, including tests and documentation, if you use the right-process.--## Quick guide--* Set up the- [Zulip development environment](https://zulip.readthedocs.io/en/latest/development/overview.html).--* Use [Zulip's JSON integration](/integrations/json),- <https://webhook.site/>, or a similar site to capture an example- webhook payload from the third-party service. Create a- `zerver/webhooks/<mywebhook>/fixtures/` directory, and add the- captured JSON payload as a test fixture.--* Create an `IncomingWebhookIntegration` object, and add it to the- `INCOMING_WEBHOOK_INTEGRATIONS` list in `zerver/lib/integrations.py`.--* Write a draft webhook handler in `zerver/webhooks/<mywebhook>/view.py`. There- are a lot of examples in the `zerver/webhooks/` directory that you can copy.- We recommend templating from a short one, like `zendesk`.--* Write a test for your fixture in `zerver/webhooks/<mywebhook>/tests.py`.- Run the test for your integration like this:-- ```- tools/test-backend zerver/webhooks/<mywebhook>/- ```-- Iterate on debugging the test and webhooks handler until it all- works.--* Capture payloads for the other common types of `POST`s the third-party- service will make, and add tests for them; usually this part of the- process is pretty fast.--* Document the integration in `zerver/webhooks/<mywebhook>/doc.md`(required for- getting it merged into Zulip). You can use existing documentation, like- [this one](https://raw.githubusercontent.com/zulip/zulip/main/zerver/webhooks/github/doc.md),- as a template. This should not take more than 15 minutes, even if you don't speak English- as a first language (we'll clean up the text before merging).--## Hello world walkthrough--Check out the [detailed walkthrough](incoming-webhooks-walkthrough) for step-by-step-instructions.--## Checklist--### Files that need to be created--Select a name for your incoming webhook and use it consistently. The examples-below are for a webhook named `MyWebHook`.--* `zerver/webhooks/mywebhook/__init__.py`: Empty file that is an obligatory- part of every python package. Remember to `git add` it.-* `zerver/webhooks/mywebhook/view.py`: The main webhook integration function,- called `api_mywebhook_webhook`, along with any necessary helper functions.-* `zerver/webhooks/mywebhook/fixtures/message_type.json`: Sample JSON payload data- used by tests. Add one fixture file per type of message supported by your- integration.-* `zerver/webhooks/mywebhook/tests.py`: Tests for your webhook.-* `zerver/webhooks/mywebhook/doc.md`: End-user documentation explaining- how to add the integration.-* `static/images/integrations/logos/mywebhook.svg`: A square logo for the- platform/server/product you are integrating. Used on the documentation- pages as well as the sender's avatar for messages sent by the integration.-* `static/images/integrations/mywebhook/001.png`: A screenshot of a message- sent by the integration, used on the documentation page. This can be- generated by running `tools/screenshots/generate-integration-docs-screenshot --integration mywebhook`.-* `static/images/integrations/bot_avatars/mywebhook.png`: A square logo for the- platform/server/product you are integrating which is used to create the avatar- for generating screenshots with. This can be generated automatically from- `static/images/integrations/logos/mywebhook.svg` by running- `tools/setup/generate_integration_bots_avatars.py`.--### Files that need to be updated--* `zerver/lib/integrations.py`: Add your integration to- `INCOMING_WEBHOOK_INTEGRATIONS`. This will automatically register a- URL for the incoming webhook of the form `api/v1/external/mywebhook` and- associate it with the function called `api_mywebhook_webhook` in- `zerver/webhooks/mywebhook/view.py`.--## Common Helpers--* If your integration will receive a test webhook payload, you can use- `get_setup_webhook_message` to create our standard message for test payloads.- You can import this from `zerver/lib/webhooks/common.py`, and it will generate- a message like this: "GitHub webhook is successfully configured! 🎉"--## General advice--* Consider using our Zulip markup to make the output from your- integration especially attractive or useful (e.g., emoji, Markdown- emphasis, or @-mentions).--* Use topics effectively to ensure sequential messages about the same- thing are threaded together; this makes for much better consumption- by users. E.g., for a bug tracker integration, put the bug number in- the topic for all messages; for an integration like Nagios, put the- service in the topic.--* Integrations that don't match a team's workflow can often be- uselessly spammy. Give careful thought to providing options for- triggering Zulip messages only for certain message types, certain- projects, or sending different messages to different channels/topics,- to make it easy for teams to configure the integration to support- their workflow.--* Consistently capitalize the name of the integration in the- documentation and the Client name the way the vendor does. It's OK- to use all-lower-case in the implementation.--* Sometimes it can be helpful to contact the vendor if it appears they- don't have an API or webhook we can use; sometimes the right API- is just not properly documented.--* A helpful tool for testing your integration is- [UltraHook](http://www.ultrahook.com/), which allows you to receive webhook- calls via your local Zulip development environment. This enables you to do end-to-end- testing with live data from the service you're integrating and can help you- spot why something isn't working or if the service is using custom HTTP- headers.--## URL specification--The base URL for an incoming webhook integration bot, where-`INTEGRATION_NAME` is the name of the specific webhook integration and-`API_KEY` is the API key of the bot created by the user for the-integration, is:--```-{{ api_url }}/v1/external/INTEGRATION_NAME?api_key=API_KEY-```--The list of existing webhook integrations can be found by browsing the-[Integrations documentation](/integrations/) or in-`zerver/lib/integrations.py` at `INCOMING_WEBHOOK_INTEGRATIONS`.--Parameters accepted in the URL include:--### api_key *(required)*--The API key of the bot created by the user for the integration. To get a-bot's API key, see the [API keys](/api/api-keys) documentation.--### stream--The channel for the integration to send notifications to. Can be either-the channel ID or the [URL-encoded][url-encoder] channel name. By default-the integration will send direct messages to the bot's owner.--!!! tip ""-- A channel ID can be found when [browsing channels][browse-channels]- in the web or desktop apps.--### topic--The topic in the specified channel for the integration to send-notifications to. The topic should also be [URL-encoded][url-encoder].-By default the integration will have a topic configured for channel-messages.--### only_events, exclude_events--Some incoming webhook integrations support these parameters to filter-which events will trigger a notification. You can append either-`&only_events=["event_a","event_b"]` or-`&exclude_events=["event_a","event_b"]` (or both, with different events)-to the URL, with an arbitrary number of supported events.--You can use UNIX-style wildcards like `*` to include multiple events.-For example, `test*` matches every event that starts with `test`.--!!! tip ""-- For a list of supported events, see a specific [integration's- documentation](/integrations) page.--[browse-channels]: /help/introduction-to-channels#browse-and-subscribe-to-channels-[add-bot]: /help/add-a-bot-or-integration-[url-encoder]: https://www.urlencoder.org/--## Related articles--* [Integrations overview](/api/integrations-overview)-* [Incoming webhook walkthrough](/api/incoming-webhooks-walkthrough)-* [Non-webhook integrations](/api/non-webhook-integrations)diff --git a/api_docs/incoming-webhooks-walkthrough.md b/api_docs/incoming-webhooks-walkthrough.mddeleted file mode 100644index a9b6d755af5..00000000000--- a/api_docs/incoming-webhooks-walkthrough.md+++ /dev/null@@ -1,722 +0,0 @@-# Incoming webhook walkthrough--Below, we explain each part of a simple incoming webhook integration,-called **Hello World**. This integration sends a "hello" message to the `test`-channel and includes a link to the Wikipedia article of the day, which-it formats from json data it receives in the http request.--Use this walkthrough to learn how to write your first webhook-integration.--## Step 0: Create fixtures--The first step in creating an incoming webhook is to examine the data that the-service you want to integrate will be sending to Zulip.--* Use [Zulip's JSON integration](/integrations/json),-<https://webhook.site/>, or a similar tool to capture webhook-payload(s) from the service you are integrating. Examining this data-allows you to do two things:--1. Determine how you will need to structure your webhook code, including what- message types your integration should support and how.-2. Create fixtures for your webhook tests.--A test fixture is a small file containing test data, one for each test.-Fixtures enable the testing of webhook integration code without the need to-actually contact the service being integrated.--Because `Hello World` is a very simple integration that does one-thing, it requires only one fixture,-`zerver/webhooks/helloworld/fixtures/hello.json`:--```json-{- "featured_title":"Marilyn Monroe",- "featured_url":"https://en.wikipedia.org/wiki/Marilyn_Monroe",-}-```--When writing your own incoming webhook integration, you'll want to write a test function-for each distinct message condition your integration supports. You'll also need a-corresponding fixture for each of these tests. Depending on the type of data-the 3rd party service sends, your fixture may contain JSON, URL encoded text, or-some other kind of data. See [Step 5: Create automated tests](#step-5-create-automated-tests) or-[Testing](https://zulip.readthedocs.io/en/latest/testing/testing.html) for further details.--### HTTP Headers--Some third-party webhook APIs, such as GitHub's, don't encode all the-information about an event in the JSON request body. Instead, they-put key details like the event type in a separate HTTP header-(generally this is clear in their API documentation). In order to-test Zulip's handling of that integration, you will need to record-which HTTP headers are used with each fixture you capture.--Since this is integration-dependent, Zulip offers a simple API for-doing this, which is probably best explained by looking at the example-for GitHub: `zerver/webhooks/github/view.py`; basically, as part of-writing your integration, you'll write a special function in your-view.py file that maps the filename of the fixture to the set of HTTP-headers to use. This function must be named "fixture_to_headers". Most-integrations will use the same strategy as the GitHub integration:-encoding the third party variable header data (usually just an event-type) in the fixture filename, in such a case, you won't need to-explicitly write the logic for such a special function again,-instead you can just use the same helper method that the GitHub-integration uses.--## Step 1: Initialize your webhook python package--In the `zerver/webhooks/` directory, create new subdirectory that will-contain all of the corresponding code. In our example, it will be-`helloworld`. The new directory will be a python package, so you have-to create an empty `__init__.py` file in that directory via, for-example, `touch zerver/webhooks/helloworld/__init__.py`.--## Step 2: Create main webhook code--The majority of the code for your new integration will be in a single-python file, `zerver/webhooks/mywebhook/view.py`.--The Hello World integration is in `zerver/webhooks/helloworld/view.py`:--```python-from django.http import HttpRequest, HttpResponse--from zerver.decorator import webhook_view-from zerver.lib.response import json_success-from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint-from zerver.lib.validator import WildValue, check_string-from zerver.lib.webhooks.common import check_send_webhook_message-from zerver.models import UserProfile---@webhook_view("HelloWorld")-@typed_endpoint-def api_helloworld_webhook(- request: HttpRequest,- user_profile: UserProfile,- *,- payload: JsonBodyPayload[WildValue],-) -> HttpResponse:- # construct the body of the message- body = "Hello! I am happy to be here! :smile:"-- # try to add the Wikipedia article of the day- body_template = (- "\nThe Wikipedia featured article for today is **[{featured_title}]({featured_url})**"- )- body += body_template.format(- featured_title=payload["featured_title"].tame(check_string),- featured_url=payload["featured_url"].tame(check_string),- )-- topic = "Hello World"-- # send the message- check_send_webhook_message(request, user_profile, topic, body)-- return json_success(request)-```--The above code imports the required functions and defines the main webhook-function `api_helloworld_webhook`, decorating it with `webhook_view` and-`typed_endpoint`. The `typed_endpoint` decorator allows you to-access request variables with `JsonBodyPayload()`. You can find more about `JsonBodyPayload` and request variables in [Writing views](-https://zulip.readthedocs.io/en/latest/tutorials/writing-views.html#request-variables).--You must pass the name of your integration to the-`webhook_view` decorator; that name will be used to-describe your integration in Zulip's analytics (e.g., the `/stats`-page). Here we have used `HelloWorld`. To be consistent with other-integrations, use the name of the product you are integrating in camel-case, spelled as the product spells its own name (except always first-letter upper-case).--The `webhook_view` decorator indicates that the 3rd party service will-send the authorization as an API key in the query parameters. If your service uses-HTTP basic authentication, you would instead use the `authenticated_rest_api_view`-decorator.--You should name your webhook function as such-`api_webhookname_webhook` where `webhookname` is the name of your-integration and is always lower-case.--At minimum, the webhook function must accept `request` (Django-[HttpRequest](https://docs.djangoproject.com/en/5.0/ref/request-response/#django.http.HttpRequest)-object), and `user_profile` (Zulip's user object). You may also want to-define additional parameters using the `typed_endpoint` decorator.--In the example above, we have defined `payload` which is populated-from the body of the http request, `stream` with a default of `test`-(available by default in the Zulip development environment), and-`topic` with a default of `Hello World`. If your webhook uses a custom channel,-it must exist before a message can be created in it. (See-[Step 4: Create automated tests](#step-5-create-automated-tests) for how to handle this in tests.)--The line that begins `# type` is a mypy type annotation. See [this-page](https://zulip.readthedocs.io/en/latest/testing/mypy.html) for details about-how to properly annotate your webhook functions.--In the body of the function we define the body of the message as `Hello! I am-happy to be here! :smile:`. The `:smile:` indicates an emoji. Then we append a-link to the Wikipedia article of the day as provided by the json payload.--* Sometimes, it might occur that a json payload does not contain all required keys your- integration checks for. In such a case, any `KeyError` thrown is handled by the server- backend and will create an appropriate response.--Then we send a message with `check_send_webhook_message`, which will-validate the message and do the following:--* Send a public (channel) message if the `stream` query parameter is- specified in the webhook URL.-* If the `stream` query parameter isn't specified, it will send a direct- message to the owner of the webhook bot.--Finally, we return a 200 http status with a JSON format success message via-`json_success(request)`.--## Step 3: Create an API endpoint for the webhook--In order for an incoming webhook to be externally available, it must be mapped-to a URL. This is done in `zerver/lib/integrations.py`.--Look for the lines beginning with:--```python-INCOMING_WEBHOOK_INTEGRATIONS: List[IncomingWebhookIntegration] = [-```--And you'll find the entry for Hello World:--```python- IncomingWebhookIntegration("helloworld", ["misc"], display_name="Hello World"),-```--This tells the Zulip API to call the `api_helloworld_webhook` function in-`zerver/webhooks/helloworld/view.py` when it receives a request at-`/api/v1/external/helloworld`.--This line also tells Zulip to generate an entry for Hello World on the Zulip-integrations page using `static/images/integrations/logos/helloworld.svg` as its-icon. The second positional argument defines a list of categories for the-integration.--At this point, if you're following along and/or writing your own Hello World-webhook, you have written enough code to test your integration. There are three-tools which you can use to test your webhook - 2 command line tools and a GUI.--### Webhooks requiring custom configuration--In cases where an incoming webhook integration supports optional URL parameters,-one can use the `url_options` feature. It's a field in the `IncomingWebhookIntegration`-class that is used when [generating a URL for an integration](/help/generate-integration-url)-in the web app, which encodes the user input for each URL parameter in the-incoming webhook's URL.--These URL options are declared as follows:--```python- IncomingWebhookIntegration(- 'helloworld',- ...- url_options=[- WebhookUrlOption(- name='ignore_private_repositories',- label='Exclude notifications from private repositories',- validator=check_string- ),- ],- )-```--`url_options` is a list describing the parameters the web app UI should offer when-generating the incoming webhook URL:-- - `name`: The parameter name that is used to encode the user input in the- integration's webhook URL.- - `label`: A short descriptive label for this URL parameter in the web app UI.- - `validator`: A validator function, which is used to determine the input type- for this option in the UI, and to indicate how to validate the input.- Currently, the web app UI only supports these validators:- - `check_bool` for checkbox/select input.- - `check_string` for text input.--!!! warn ""-- **Note**: To add support for other validators, you can update- `web/src/integration_url_modal.ts`. Common validators are available in- `zerver/lib/validator.py`.--In rare cases, it may be necessary for an incoming webhook to require-additional user configuration beyond what is specified in the POST-URL. A typical use case for this would be APIs that require clients-to do a callback to get details beyond an opaque object ID that one-would want to include in a Zulip notification message.--The `config_options` field in the `IncomingWebhookIntegration` class is reserved-for this use case.--### WebhookUrlOption presets--The `build_preset_config` method creates `WebhookUrlOption` objects with-pre-configured fields. These preset URL options primarily serve two-purposes:--- To construct common `WebhookUrlOption` objects that are used in various- incoming webhook integrations.--- To construct `WebhookUrlOption` objects with special UI in the web-app- for [generating incoming webhook URLs](/help/generate-integration-url).--Using a preset URL option with the `build_preset_config` method:--```python-# zerver/lib/integrations.py-from zerver.lib.webhooks.common import PresetUrlOption, WebhookUrlOption- # -- snip --- IncomingWebhookIntegration(- "github",- # -- snip --- url_options=[- WebhookUrlOption.build_preset_config(PresetUrlOption.BRANCHES),- ],- ),-```--Currently configured preset URL options:--- **`BRANCHES`**: This preset is intended to be used for [version control- integrations](/integrations/category/version-control), and adds UI for the user to- configure which branches of a project's repository will trigger Zulip- notification messages. When the user specifies which branches to receive- notifications from, the `branches` parameter will be added to the [generated- integration URL](/help/generate-integration-url). For example, if the user- input `main` and `dev` for the branches of their repository, then- `&branches=main%2Cdev` would be appended to the generated integration URL.--- **`IGNORE_PRIVATE_REPOSITORIES`**: This preset is intended to be used for- [version control integrations](/integrations/category/version-control), and adds UI- for the user exclude private repositories from triggering Zulip- notification messages. When the user selects this option, the- `ignore_private_repositories` boolean parameter will be added to the- [generated integration URL](/help/generate-integration-url).--- **`CHANNEL_MAPPING`**: This preset is intended to be used for [chat-app- integrations](/integrations/category/communication) (like Slack), and adds a- special option, **Matching Zulip channel**, to the UI for where to send- Zulip notification messages. This special option maps the notification- messages to Zulip channels that match the messages' original channel- name in the third-party app. When selected, this requires setting a- single topic for notification messages, and adds `&mapping=channels`- to the [generated integration URL](/help/generate-integration-url).--## Step 4: Manually testing the webhook--For either one of the command line tools, first, you'll need to get an-API key from the **Bots** section of your Zulip user's **Personal-settings**. To test the webhook, you'll need to [create a-bot](https://zulip.com/help/add-a-bot-or-integration) with the-**Incoming webhook** type. Replace `<api_key>` with your bot's API key-in the examples presented below! This is how Zulip knows that the-request was made by an authorized user.--### Curl--Using curl:-```bash-curl -X POST -H "Content-Type: application/json" -d '{ "featured_title":"Marilyn Monroe", "featured_url":"https://en.wikipedia.org/wiki/Marilyn_Monroe" }' http://localhost:9991/api/v1/external/helloworld\?api_key\=<api_key>-```--After running the above command, you should see something similar to:--```json-{"msg":"","result":"success"}-```--### Management command: send_webhook_fixture_message--Using `manage.py` from within the Zulip development environment:--```console-(zulip-server) vagrant@vagrant:/srv/zulip$-./manage.py send_webhook_fixture_message \- --fixture=zerver/webhooks/helloworld/fixtures/hello.json \- '--url=http://localhost:9991/api/v1/external/helloworld?api_key=<api_key>'-```--After running the above command, you should see something similar to:--```-2016-07-07 15:06:59,187 INFO 127.0.0.1 POST 200 143ms (mem: 6ms/13) (md: 43ms/1) (db: 20ms/9q) (+start: 147ms) /api/v1/external/helloworld ([email protected] via ZulipHelloWorldWebhook)-```--Some webhooks require custom HTTP headers, which can be passed using-`./manage.py send_webhook_fixture_message --custom-headers`. For-example:-- --custom-headers='{"X-Custom-Header": "value"}'--The format is a JSON dictionary, so make sure that the header names do-not contain any spaces in them and that you use the precise quoting-approach shown above.--For more information about `manage.py` command-line tools in Zulip, see-the [management commands][management-commands] documentation.--[management-commands]: https://zulip.readthedocs.io/en/latest/production/management-commands.html--### Integrations Dev Panel-This is the GUI tool.--{start_tabs}--1. Run `./tools/run-dev` then go to http://localhost:9991/devtools/integrations/.--1. Set the following mandatory fields:-**Bot** - Any incoming webhook bot.-**Integration** - One of the integrations.-**Fixture** - Though not mandatory, it's recommended that you select one and then tweak it if necessary.-The remaining fields are optional, and the URL will automatically be generated.--1. Click **Send**!--{end_tabs}--By opening Zulip in one tab and then this tool in another, you can quickly tweak-your code and send sample messages for many different test fixtures.--Note: Custom HTTP Headers must be entered as a JSON dictionary, if you want to use any in the first place that is.-Feel free to use 4-spaces as tabs for indentation if you'd like!--Your sample notification may look like:--<img class="screenshot" src="/static/images/api/helloworld-webhook.png" alt="screenshot" />----## Step 5: Create automated tests--Every webhook integration should have a corresponding test file:-`zerver/webhooks/mywebhook/tests.py`.--The Hello World integration's tests are in `zerver/webhooks/helloworld/tests.py`--You should name the class `<WebhookName>HookTests` and have it inherit from-the base class `WebhookTestCase`. For our HelloWorld webhook, we name the test-class `HelloWorldHookTests`:--```python-class HelloWorldHookTests(WebhookTestCase):- DIRECT_MESSAGE_URL_TEMPLATE = "/api/v1/external/helloworld?&api_key={api_key}"-- # Note: Include a test function per each distinct message condition your integration supports- def test_hello_message(self) -> None:- expected_topic = "Hello World"- expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**"-- # use fixture named helloworld_hello- self.check_webhook(- "hello",- expected_topic,- expected_message,- content_type="application/x-www-form-urlencoded",- )-```--When writing tests for your webhook, you'll want to include one test function-(and corresponding fixture) per each distinct message condition that your-integration supports.--If, for example, we added support for sending a goodbye message to our `Hello-World` webhook, we would add another test function to `HelloWorldHookTests`-class called something like `test_goodbye_message`:--```python- def test_goodbye_message(self) -> None:- expected_topic = "Hello World"- expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**"-- # use fixture named helloworld_goodbye- self.check_webhook(- "goodbye",- expected_topic,- expected_message,- content_type="application/x-www-form-urlencoded",- )-```--As well as a new fixture `goodbye.json` in-`zerver/webhooks/helloworld/fixtures/`:--```json-{- "featured_title":"Goodbye",- "featured_url":"https://en.wikipedia.org/wiki/Goodbye",-}-```--Also consider if your integration should have negative tests, a test where the-data from the test fixture should result in an error. For details see-[Negative tests](#negative-tests), below.--Once you have written some tests, you can run just these new tests from within-the Zulip development environment with this command:--```console-(zulip-server) vagrant@vagrant:/srv/zulip$-./tools/test-backend zerver/webhooks/helloworld-```--(Note: You must run the tests from the top level of your development directory.-The standard location in a Vagrant environment is `/srv/zulip`. If you are not-using Vagrant, use the directory where you have your development environment.)--You will see some script output and if all the tests have passed, you will see:--```console-Running zerver.webhooks.helloworld.tests.HelloWorldHookTests.test_goodbye_message-Running zerver.webhooks.helloworld.tests.HelloWorldHookTests.test_hello_message-DONE!-```--## Step 6: Create documentation--Next, we add end-user documentation for our integration. You-can see the existing examples at <https://zulip.com/integrations>-or by accessing `/integrations` in your Zulip development environment.--There are two parts to the end-user documentation on this page.--The first is the lozenge in the grid of integrations, showing your-integration logo and name, which links to the full documentation.-This is generated automatically once you've registered the integration-in `INCOMING_WEBHOOK_INTEGRATIONS` in `zerver/lib/integrations.py`, and supports-some customization via options to the `IncomingWebhookIntegration` class.--Second, you need to write the actual documentation content in-`zerver/webhooks/mywebhook/doc.md`.--```md-Learn how Zulip integrations work with this simple Hello World example!--1. The Hello World webhook will use the `test` channel, which is created- by default in the Zulip development environment. If you are running- Zulip in production, you should make sure that this channel exists.--1. {!create-an-incoming-webhook.md!}--1. {!generate-webhook-url-basic.md!}--1. To trigger a notification using this example webhook, you can use- `send_webhook_fixture_message` from a [Zulip development- environment](https://zulip.readthedocs.io/en/latest/development/overview.html):-- ```- (zulip-server) vagrant@vagrant:/srv/zulip$- ./manage.py send_webhook_fixture_message \- > --fixture=zerver/tests/fixtures/helloworld/hello.json \- > '--url=http://localhost:9991/api/v1/external/helloworld?api_key=abcdefgh&stream=stream%20name;'- ```-- Or, use curl:-- ```- curl -X POST -H "Content-Type: application/json" -d '{ "featured_title":"Marilyn Monroe", "featured_url":"https://en.wikipedia.org/wiki/Marilyn_Monroe" }' http://localhost:9991/api/v1/external/helloworld\?api_key=abcdefgh&stream=stream%20name;- ```--{!congrats.md!}----```--`{!create-an-incoming-webhook.md!}` and `{!congrats.md!}` are examples of-a Markdown macro. Zulip has a macro-based Markdown/Jinja2 framework that-includes macros for common instructions in Zulip's webhooks/integrations-documentation.--See-[our guide on documenting an integration][integration-docs-guide]-for further details, including how to easily create the message-screenshot. Mostly you should plan on templating off an existing guide, like-[this one](https://raw.githubusercontent.com/zulip/zulip/main/zerver/webhooks/github/doc.md).--[integration-docs-guide]: https://zulip.readthedocs.io/en/latest/documentation/integrations.html--## Step 7: Preparing a pull request to zulip/zulip--When you have finished your webhook integration, follow these guidelines before-pushing the code to your fork and submitting a pull request to zulip/zulip:--- Run tests including linters and ensure you have addressed any issues they- report. See [Testing](https://zulip.readthedocs.io/en/latest/testing/testing.html)- and [Linters](https://zulip.readthedocs.io/en/latest/testing/linters.html) for details.-- Read through [Code styles and conventions](- https://zulip.readthedocs.io/en/latest/contributing/code-style.html) and take a look- through your code to double-check that you've followed Zulip's guidelines.-- Take a look at your Git history to ensure your commits have been clear and- logical (see [Commit discipline](- https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html) for tips). If not,- consider revising them with `git rebase --interactive`. For most incoming webhooks,- you'll want to squash your changes into a single commit and include a good,- clear commit message.--If you would like feedback on your integration as you go, feel free to post a-message on the [public Zulip instance](https://chat.zulip.org/#narrow/channel/integrations).-You can also create a [draft pull request](-https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests) while you-are still working on your integration. See the-[Git guide](https://zulip.readthedocs.io/en/latest/git/pull-requests.html#create-a-pull-request)-for more on Zulip's pull request process.--## Advanced topics--More complex implementation or testing needs may require additional code, beyond-what the standard helper functions provide. This section discusses some of-these situations.--### Negative tests--A negative test is one that should result in an error, such as incorrect data.-The helper functions may interpret this as a test failure, when it should instead-be a successful test of an error condition. To correctly test these cases, you-must explicitly code your test's execution (using other helpers, as needed)-rather than call the usual helper function.--Here is an example from the WordPress integration:--```python-def test_unknown_action_no_data(self) -> None:- # Mimic check_webhook() to manually execute a negative test.- # Otherwise its call to send_webhook_payload() would assert on the non-success- # we are testing. The value of result is the error message the webhook should- # return if no params are sent. The fixture for this test is an empty file.-- # subscribe to the target channel- self.subscribe(self.test_user, self.channel_name)-- # post to the webhook url- post_params = {'stream_name': self.channel_name,- 'content_type': 'application/x-www-form-urlencoded'}- result = self.client_post(self.url, 'unknown_action', **post_params)-- # check that we got the expected error message- self.assert_json_error(result, "Unknown WordPress webhook action: WordPress action")-```--In a normal test, `check_webhook` would handle all the setup-and then check that the incoming webhook's response matches the expected result. If-the webhook returns an error, the test fails. Instead, explicitly do the-setup it would have done, and check the result yourself.--Here, `subscribe` is a test helper that uses `test_user` and `channel_name`-(attributes from the base class) to register the user to receive messages in-the given channel. If the channel doesn't exist, it creates it.--`client_post`, another helper, performs the HTTP POST that calls the incoming-webhook. As long as `self.url` is correct, you don't need to construct the webhook-URL yourself. (In most cases, it is.)--`assert_json_error` then checks if the result matches the expected error.-If you had used `check_webhook`, it would have called-`send_webhook_payload`, which checks the result with `assert_json_success`.--### Custom query parameters--Custom arguments passed in URL query parameters work as expected in the webhook-code, but require special handling in tests.--For example, here is the definition of a webhook function that gets both `stream`-and `topic` from the query parameters:--```python-@typed_endpoint-def api_querytest_webhook(request: HttpRequest, user_profile: UserProfile,- payload: Annotated[str, ApiParamConfig(argument_type_is_body=True)],- stream: str = "test",- topic: str= "Default Alert":-```--In actual use, you might configure the 3rd party service to call your Zulip-integration with a URL like this:--```-http://myhost/api/v1/external/querytest?api_key=abcdefgh&stream=alerts&topic=queries-```--It provides values for `stream` and `topic`, and the webhook can get those-using `@typed_endpoint` without any special handling. How does this work in a test?--The new attribute `TOPIC` exists only in our class so far. In order to-construct a URL with a query parameter for `topic`, you can pass the-attribute `TOPIC` as a keyword argument to `build_webhook_url`, like so:--```python-class QuerytestHookTests(WebhookTestCase):-- TOPIC = "Default topic"- FIXTURE_DIR_NAME = 'querytest'-- def test_querytest_test_one(self) -> None:- # construct the URL used for this test- self.TOPIC = "Query test"- self.url = self.build_webhook_url(topic=self.TOPIC)-- # define the expected message contents- expected_topic = "Query test"- expected_message = "This is a test of custom query parameters."-- self.check_webhook('test_one', expected_topic, expected_message,- content_type="application/x-www-form-urlencoded")-```--You can also override `get_body` or `get_payload` if your test data-needs to be constructed in an unusual way.--For more, see the definition for the base class, `WebhookTestCase`-in `zerver/lib/test_classes.py`, or just grep for examples.---### Custom HTTP event-type headers--Some third-party services set a custom HTTP header to indicate the event type that-generates a particular payload. To extract such headers, we recommend using the-`get_event_header` function in `zerver/lib/webhooks/common.py`, like so:--```python-event = get_event_header(request, header, integration_name)-```--`request` is the `HttpRequest` object passed to your main webhook function. `header`-is the name of the custom header you'd like to extract, such as `X-Event-Key`, and-`integration_name` is the name of the third-party service in question, such as-`GitHub`.--Because such headers are how some integrations indicate the event types of their-payloads, the absence of such a header usually indicates a configuration-issue, where one either entered the URL for a different integration, or happens to-be running an older version of the integration that doesn't set that header.--If the requisite header is missing, this function sends a direct message to the-owner of the webhook bot, notifying them of the missing header.--### Handling unexpected webhook event types--Many third-party services have dozens of different event types. In-some cases, we may choose to explicitly ignore specific events. In-other cases, there may be events that are new or events that we don't-know about. In such cases, we recommend raising-`UnsupportedWebhookEventTypeError` (found in `zerver/lib/exceptions.py`),-with a string describing the unsupported event type, like so:--```-raise UnsupportedWebhookEventTypeError(event_type)-```--## Related articles--* [Integrations overview](/api/integrations-overview)-* [Incoming webhook integrations](/api/incoming-webhooks-overview)diff --git a/api_docs/index.md b/api_docs/index.mdindex a07bafd49e2..40eab3fffbc 100644--- a/api_docs/index.md+++ b/api_docs/index.md@@ -11,7 +11,7 @@ guide should help you find the API you need:[Zulip's IFTTT integration](/integrations/ifttt) often allowintegrating a new service with Zulip without writing any code.* If you'd like to send content into Zulip, you can- [write a native incoming webhook integration](/api/incoming-webhooks-overview)+ [write a native incoming webhook integration][incoming-webhooks-overview]or use [Zulip's API for sending messages](/api/send-message).* If you're building an interactive bot that reacts to activity insideZulip, you'll want to look at Zulip's@@ -24,3 +24,5 @@ the full [REST API](/api/rest), generally starting withIn case you already know how you want to build your integration and you'rejust looking for an API key, we've got you covered [here](/api/api-keys).++[incoming-webhooks-overview]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.htmldiff --git a/api_docs/integrations-overview.md b/api_docs/integrations-overview.mdindex cb8d6b12d34..4f2e087e39c 100644--- a/api_docs/integrations-overview.md+++ b/api_docs/integrations-overview.md@@ -103,7 +103,7 @@ Sales](mailto:[email protected]).### Sending content into Zulip* If the third-party service supports outgoing webhooks, you likely want to- build an [incoming webhook integration](/api/incoming-webhooks-overview).+ build an [incoming webhook integration][incoming-webhooks-overview].* If it doesn't, you may want to write a[script or plugin integration](/api/non-webhook-integrations).* The [`zulip-send` tool](/api/send-message) makes it easy to send Zulip@@ -130,3 +130,5 @@ Sales](mailto:[email protected]).* [Add a bot or integration](/help/add-a-bot-or-integration)* [Generate integration URL](/help/generate-integration-url)* [Request an integration](/help/request-an-integration)++[incoming-webhooks-overview]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.htmldiff --git a/api_docs/non-webhook-integrations.md b/api_docs/non-webhook-integrations.mdindex 5ec42e3fc67..0e0a66936db 100644--- a/api_docs/non-webhook-integrations.md+++ b/api_docs/non-webhook-integrations.md@@ -1,6 +1,6 @@# Non-webhook integrations-[Incoming webhook integrations](/api/incoming-webhooks-overview) are the+[Incoming webhook integrations][incoming-webhooks-overview] are thefastest to write, but sometimes a third-party product just doesn't supportthem. Zulip supports several other types of integrations.@@ -49,11 +49,13 @@ examples of ideal UAs are:ZulipMobile/0.5.4 (Android; 4.2; maguro)```-* The [general advice](/api/incoming-webhooks-overview#general-advice) for- webhook integrations applies here as well.+* The [general advice][webhooks-general-advice] for webhook integrations applies here as well.## Related articles* [Running bots](/api/running-bots)* [Deploying bots](/api/deploying-bots)* [Writing bots](/api/writing-bots)++[incoming-webhooks-overview]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html+[webhooks-general-advice]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html#general-advicediff --git a/api_docs/sidebar_index.md b/api_docs/sidebar_index.mdindex ca36d16156d..994b1c166bf 100644--- a/api_docs/sidebar_index.md+++ b/api_docs/sidebar_index.md@@ -1,8 +1,8 @@## Integrations* [Overview](/api/integrations-overview)-* [Incoming webhook integrations](/api/incoming-webhooks-overview)-* [Hello world walkthrough](/api/incoming-webhooks-walkthrough)+* [Incoming webhook integrations](https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html)+* [Hello world walkthrough](https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-walkthrough.html)* [Non-webhook integrations](/api/non-webhook-integrations)## Interactive botsdiff --git a/starlight_help/src/content/docs/integrations-overview.mdx b/starlight_help/src/content/docs/integrations-overview.mdxindex 21ca026d633..d6cb1c9ce83 100644--- a/starlight_help/src/content/docs/integrations-overview.mdx+++ b/starlight_help/src/content/docs/integrations-overview.mdx@@ -99,7 +99,8 @@ Sales](mailto:[email protected]).### Sending content into Zulip* If the third-party service supports outgoing webhooks, you likely want to- build an [incoming webhook integration](/api/incoming-webhooks-overview).+ build an [incoming webhook+ integration](https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html).* If it doesn't, you may want to write a[script or plugin integration](/api/non-webhook-integrations).* The [`zulip-send` tool](/api/send-message) makes it easy to send Zulipdiff --git a/starlight_help/src/content/docs/restrict-bot-creation.mdx b/starlight_help/src/content/docs/restrict-bot-creation.mdxindex 30021251b01..32fbc3a84bd 100644--- a/starlight_help/src/content/docs/restrict-bot-creation.mdx+++ b/starlight_help/src/content/docs/restrict-bot-creation.mdx@@ -53,6 +53,6 @@ individual [users](/help/introduction-to-users).* [Integrations overview](/help/integrations-overview)* [Add a bot or integration](/help/add-a-bot-or-integration)* [Deactivate or reactivate a bot](/help/deactivate-or-reactivate-a-bot)-* [Incoming webhooks](/api/incoming-webhooks-overview)+* [Incoming webhooks](https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html)* [Outgoing webhooks](/api/outgoing-webhooks)* [Non-webhook integrations](/api/non-webhook-integrations)diff --git a/starlight_help/src/content/docs/zulip-cloud-or-self-hosting.mdx b/starlight_help/src/content/docs/zulip-cloud-or-self-hosting.mdxindex 0c47697ce5e..b825bf6aa36 100644--- a/starlight_help/src/content/docs/zulip-cloud-or-self-hosting.mdx+++ b/starlight_help/src/content/docs/zulip-cloud-or-self-hosting.mdx@@ -39,8 +39,8 @@ organization. For additional guidance, reach out toup][back-up-zulip], and [maintaining][maintain-zulip] a self-hosted Zulipserver.* **Customizable**: Customize Zulip for all your needs. It's easy to develop and- maintain [custom integrations](/api/incoming-webhooks-overview) and- [features][modify-zulip].+ maintain [custom integrations](https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html)+ and [features][modify-zulip].* **Budget option**: For organizations with expertise in self-hosting theirtools and a tight budget, the [Zulip Basicplan](https://zulip.com/plans/#self-hosted) can be a great choice.diff --git a/static/images/api/helloworld-webhook.png b/static/images/api/helloworld-webhook.pngdeleted file mode 100644index 87d1ae95389..00000000000Binary files a/static/images/api/helloworld-webhook.png and /dev/null differdiff --git a/templates/corporate/for/business.html b/templates/corporate/for/business.htmlindex 5388ce959ab..77eb88c6d71 100644--- a/templates/corporate/for/business.html+++ b/templates/corporate/for/business.html@@ -281,7 +281,7 @@Build your own integrations with Zulip’seasy-to-use <a href="/api/">RESTfulAPI</a>, <a href="/api/installation-instructions">client- bindings</a>, <a href="/api/incoming-webhooks-overview">incoming+ bindings</a>, <a href="https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html">incomingwebhooks</a>, <a href="/api/outgoing-webhooks">outgoingwebhooks</a>and <a href="/api/running-bots">interactivediff --git a/templates/corporate/for/communities.md b/templates/corporate/for/communities.mdindex ea99783fd83..339d4d1b6a8 100644--- a/templates/corporate/for/communities.md+++ b/templates/corporate/for/communities.md@@ -177,8 +177,8 @@ features.For full control over your data, follow our simple [installationinstructions](https://zulip.readthedocs.io/en/stable/production/install.html) tohost Zulip yourself. If you like, you can develop [custom-integrations](/api/incoming-webhooks-overview) and-[features](https://zulip.readthedocs.io/en/stable/production/modify.html). If+integrations](https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html)+and [features](https://zulip.readthedocs.io/en/stable/production/modify.html). Ifyour needs change, you can always move [from self-hosting to ZulipCloud](/help/move-to-zulip-cloud) or [the otherway](https://zulip.readthedocs.io/en/stable/production/export-and-import.html#import-into-a-new-zulip-server).diff --git a/templates/corporate/for/open-source.html b/templates/corporate/for/open-source.htmlindex e96a2d39468..581ba4ab78c 100644--- a/templates/corporate/for/open-source.html+++ b/templates/corporate/for/open-source.html@@ -523,7 +523,7 @@Build your own integrations with Zulip’seasy-to-use <a href="/api/">RESTfulAPI</a>, <a href="/api/installation-instructions">client- bindings</a>, <a href="/api/incoming-webhooks-overview">incoming+ bindings</a>, <a href="https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html">incomingwebhooks</a>, <a href="/api/outgoing-webhooks">outgoingwebhooks</a>and <a href="/api/running-bots">interactivediff --git a/templates/corporate/self-hosting.html b/templates/corporate/self-hosting.htmlindex c6a1dd65f76..4b5354e6f35 100644--- a/templates/corporate/self-hosting.html+++ b/templates/corporate/self-hosting.html@@ -240,8 +240,8 @@Yours to customize.</h1><p>- <a href="/api/incoming-webhooks-overview">Creating custom integrations</a> is a breeze with- our well-documented <a href="/api/">REST API</a>.+ <a href="https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html">Creating custom integrations</a>+ is a breeze with our well-documented <a href="/api/">REST API</a>.</p><p>Zulip makes it easy todiff --git a/templates/zerver/integrations/catalog.html b/templates/zerver/integrations/catalog.htmlindex e5f21a674e2..e54a018e9ce 100644--- a/templates/zerver/integrations/catalog.html+++ b/templates/zerver/integrations/catalog.html@@ -63,7 +63,7 @@</a>{% endfor %}<h4 class="heading">{% trans %}Custom integrations{% endtrans %}</h4>- <a href="/api/incoming-webhooks-overview">+ <a href="https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html"><h4>{% trans %}Incoming webhooks{% endtrans %}</h4></a><a href="/api/writing-bots">@@ -90,7 +90,7 @@{% endfor %}<hr /><h3>{% trans %}Custom integrations{% endtrans %}</h3>- <a href="/api/incoming-webhooks-overview">+ <a href="https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html"><h4>{% trans %}Incoming webhooks{% endtrans %}</h4></a><a href="/api/writing-bots">diff --git a/templates/zerver/integrations/include/event-filtering-additional-feature.md b/templates/zerver/integrations/include/event-filtering-additional-feature.mdindex 82428b65ba2..3529161b4ce 100644--- a/templates/zerver/integrations/include/event-filtering-additional-feature.md+++ b/templates/zerver/integrations/include/event-filtering-additional-feature.md@@ -7,4 +7,4 @@ The {{ integration_display_name }} integration supports{% for event_type in all_event_types -%} {{- comma() -}} `{{ event_type }}` {%- endfor %}-[event-filters]: /api/incoming-webhooks-overview#only_events-exclude_events+[event-filters]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html#only_events-exclude_eventsdiff --git a/templates/zerver/integrations/include/webhooks-url-specification.md b/templates/zerver/integrations/include/webhooks-url-specification.mdindex 9057c624fd0..0c471c35dd3 100644--- a/templates/zerver/integrations/include/webhooks-url-specification.md+++ b/templates/zerver/integrations/include/webhooks-url-specification.md@@ -1,3 +1,3 @@* [Webhook URLs specification][incoming-webhook-urls]-[incoming-webhook-urls]: /api/incoming-webhooks-overview#url-specification+[incoming-webhook-urls]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html#url-specificationdiff --git a/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py b/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.pyindex 6b0ff64dd57..04f11c5ccda 100644--- a/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py+++ b/tools/documentation_crawler/documentation_crawler/spiders/check_help_documentation.py@@ -1,47 +1,8 @@-import os-from posixpath import basename-from typing import Any-from urllib.parse import urlsplit-from typing_extensions import overridefrom .common.spiders import BaseDocumentationSpider-def get_images_dir(images_path: str) -> str:- # Get index html file as start url and convert it to file uri- dir_path = os.path.dirname(os.path.realpath(__file__))- target_path = os.path.join(dir_path, os.path.join(*[os.pardir] * 4), images_path)- return os.path.realpath(target_path)---class UnusedImagesLinterSpider(BaseDocumentationSpider):- images_path = ""-- def __init__(self, *args: Any, **kwargs: Any) -> None:- super().__init__(*args, **kwargs)- self.static_images: set[str] = set()- self.images_static_dir: str = get_images_dir(self.images_path)-- @override- def _is_external_url(self, url: str) -> bool:- is_external = url.startswith("http") and self.start_urls[0] not in url- if self._has_extension(url) and f"localhost:9981/{self.images_path}" in url:- self.static_images.add(basename(urlsplit(url).path))- return is_external or self._has_extension(url)-- def closed(self, *args: Any, **kwargs: Any) -> None:- unused_images = set(os.listdir(self.images_static_dir)) - self.static_images- if unused_images:- exception_message = (- "The following images are not used in documentation and can be removed: {}"- )- unused_images_relatedpath = [- os.path.join(self.images_path, img) for img in unused_images- ]- self.logger.error(exception_message.format(", ".join(unused_images_relatedpath)))--class HelpDocumentationSpider(BaseDocumentationSpider):name = "help_documentation_crawler"start_urls = ["http://localhost:9981/help"]@@ -53,11 +14,14 @@ class HelpDocumentationSpider(BaseDocumentationSpider):return not f"{url}/".startswith("http://localhost:9981/help/") or self._has_extension(url)-class APIDocumentationSpider(UnusedImagesLinterSpider):+class APIDocumentationSpider(BaseDocumentationSpider):name = "api_documentation_crawler"start_urls = ["http://localhost:9981/api"]deny_domains: list[str] = []- images_path = "static/images/api"++ @override+ def _is_external_url(self, url: str) -> bool:+ return not f"{url}/".startswith("http://localhost:9981/api") or self._has_extension(url)class PorticoDocumentationSpider(BaseDocumentationSpider):diff --git a/zerver/lib/url_redirects.py b/zerver/lib/url_redirects.pyindex 79f3f0030e1..657ce05a966 100644--- a/zerver/lib/url_redirects.py+++ b/zerver/lib/url_redirects.py@@ -10,6 +10,14 @@ class URLRedirect:API_DOCUMENTATION_REDIRECTS: list[URLRedirect] = [# Add URL redirects for REST API documentation here:URLRedirect("/api/delete-stream", "/api/archive-stream"),+ URLRedirect(+ "/api/incoming-webhooks-overview",+ "https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html",+ ),+ URLRedirect(+ "/api/incoming-webhooks-walkthrough",+ "https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-walkthrough.html",+ ),]POLICY_DOCUMENTATION_REDIRECTS: list[URLRedirect] = [diff --git a/zerver/lib/webhooks/common.py b/zerver/lib/webhooks/common.pyindex 25ef0c176c4..d3922ea48f1 100644--- a/zerver/lib/webhooks/common.py+++ b/zerver/lib/webhooks/common.py@@ -79,7 +79,7 @@ class WebhookUrlOption:This creates a pre-configured WebhookUrlOption object to be usedin various incoming webhook integrations.- See https://zulip.com/api/incoming-webhooks-walkthrough#webhookurloption-presets+ See https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-walkthrough.html#webhookurloption-presetsfor more details on this system and what each option does."""match config:diff --git a/zerver/tests/test_urls.py b/zerver/tests/test_urls.pyindex 8dcf0c1d498..6687966c711 100644--- a/zerver/tests/test_urls.py+++ b/zerver/tests/test_urls.py@@ -183,8 +183,18 @@ class ErrorPageTest(ZulipTestCase):class RedirectURLTest(ZulipTestCase):def test_api_redirects(self) -> None:for redirect in API_DOCUMENTATION_REDIRECTS:- result = self.client_get(redirect.old_url, follow=True)- self.assert_in_success_response(["Zulip homepage", "API documentation home"], result)+ if redirect.old_url not in [+ "/api/incoming-webhooks-overview",+ "/api/incoming-webhooks-walkthrough",+ ]:+ result = self.client_get(redirect.old_url, follow=True)+ self.assert_in_success_response(+ ["Zulip homepage", "API documentation home"], result+ )++ result = self.client_get(redirect.old_url)+ self.assertEqual(result.status_code, 301)+ self.assertIn(redirect.new_url, result["Location"])def test_policy_redirects(self) -> None:for redirect in POLICY_DOCUMENTATION_REDIRECTS:diff --git a/zerver/webhooks/helloworld/doc.md b/zerver/webhooks/helloworld/doc.mdindex 3b565437804..3d87e1a06bc 100644--- a/zerver/webhooks/helloworld/doc.md+++ b/zerver/webhooks/helloworld/doc.md@@ -2,8 +2,7 @@Learn how Zulip integrations work with this simple Hello World example!-This webhook is Zulip's official [example-integration](/api/incoming-webhooks-walkthrough).+This webhook is Zulip's official [example integration][incoming-webhooks-walkthrough].{start_tabs}@@ -41,3 +40,5 @@ integration](/api/incoming-webhooks-walkthrough).### Related documentation{!webhooks-url-specification.md!}++[incoming-webhooks-walkthrough]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-walkthrough.htmldiff --git a/zerver/webhooks/json/doc.md b/zerver/webhooks/json/doc.mdindex 07070221bc1..438311dd3a3 100644--- a/zerver/webhooks/json/doc.md+++ b/zerver/webhooks/json/doc.md@@ -2,8 +2,7 @@Render JSON payloads nicely in a Zulip code block! This isparticularly useful when you want to capture a webhook payload as part-of [writing an incoming webhook-integration](/api/incoming-webhooks-overview).+of [writing an incoming webhook integration][incoming-webhooks-overview].{start_tabs}@@ -23,3 +22,5 @@ integration](/api/incoming-webhooks-overview).### Related documentation{!webhooks-url-specification.md!}++[incoming-webhooks-overview]: https://zulip.readthedocs.io/en/latest/webhooks/incoming-webhooks-overview.html