Zulip Connection Guide

Overview

Maton connects to Zulip with an email and API key, yours or a generic bot's, and calls the Zulip API as that user. It works with Zulip Cloud (*.zulipchat.com) and Zulip servers you run yourself, as long as Maton can reach the server.

What You'll Need

  • A Zulip account in the organization. Any plan, including free, includes the API.
  • For a self-hosted server, a domain reachable on the public internet over HTTPS. Maton doesn't connect to private or local addresses.
  • To connect a bot instead of yourself, permission to add bots in the organization.

Step 1: Find Your Zulip URL

Open Zulip in your browser and look at the address bar. Your Zulip URL is the domain between https:// and the next /: for https://yourorg.zulipchat.com/#feed it is yourorg.zulipchat.com.

Step 2: Get an Email and API Key

The connection acts as whoever the key belongs to. A bot keeps automated messages separate from yours and can be limited to the channels it's subscribed to.

  1. In Zulip, click the gear icon in the top right corner and choose "Personal settings".
  2. The gear menu in Zulip with Personal settings

For your own account

  1. Open the "Account & privacy" tab. The Email shown there is the one to use. Under API key, click "Manage your API key".
  2. The Account and privacy tab with the Manage your API key button
  3. Enter your Zulip password and click "Get API key".
  4. Zulip asking for your password before showing the API key
  5. Copy the key. Don't click "Generate new API key": that replaces the key and stops anything still using the old one.
  6. Your API key in Zulip

For a bot

  1. Open the "Bots" tab and click "Add a new bot".
  2. For Bot type, choose Generic bot. Zulip may preselect Incoming webhook, but webhook bots can only post messages through integrations and can't use the API Maton calls. Give the bot a name, such as Maton, and click "Add".
  3. The bot type list in Zulip's Add a new bot dialog
  4. In the bot's row, click the download icon in the Actions column. It downloads a zuliprc file.
  5. The Bots tab with the download icon in the Actions column
  6. Open zuliprc in a text editor. It holds everything the Maton form needs:
    [api]
    email=maton-bot@yourorg.zulipchat.com
    key=abcd1234efgh5678ijkl9012mnop3456
    site=https://yourorg.zulipchat.com
    email is the Email, key is the API Key, and site without https:// is the Zulip URL.
  7. Subscribe the bot to the channels it should read or post in.

Step 3: Connect Zulip

  1. Go to the Connections page, click "Add Connection", find Zulip and click "+ Connect". With the Maton CLI, run maton connection create zulip instead; it opens the same form.
  2. Enter the Zulip URL from Step 1 (without https://), the Email and the API Key from Step 2, then click "Connect".
  3. The Zulip connect form
  4. The connection appears on the Connections page. If it shows the user's name and email, Maton read the user with your key; if it doesn't, the email or key is wrong (see Troubleshooting).

Troubleshooting

  • Calls return "Invalid API key": the email and key don't belong to the same user. Use your own email with your own key, or the bot's email with the bot's key (both are in its zuliprc). Don't use the address Zulip shows others when emails are hidden, such as user1234@yourorg.zulipchat.com. If the key was regenerated, reconnect with the new one.
  • Calls return "This API is not available to incoming webhook bots": the bot is an Incoming webhook bot. Add a Generic bot and connect with its email and key.
  • The Zulip URL isn't accepted: enter only the domain, such as yourorg.zulipchat.com, without https:// or a path. Maton refuses IP addresses and names that point to private networks.
  • Maton can't reach the server: the domain must resolve to a public address and serve HTTPS on port 443. Servers only reachable on an office network or VPN can't be connected.
  • A bot can't see a channel: subscribe the bot to it in Zulip.

Keeping Your Zulip Data Safe

An API key can do everything its user can, so consider a dedicated bot with only the channels Maton needs. Regenerating the key in Zulip, or deactivating the bot, stops the Maton connection. Deleting the connection in Maton removes the stored key.