Skip to content

Mattermost Bridge

Put the assistant where your team already works. The Mattermost bridge joins your Mattermost server as a bot user: message it directly, or @-mention it in a channel, and the answer from your hive comes back in the same thread. It's the same idea as a Slack bot, but pointed at your own private assistant instead of someone's cloud. Like every bridge, it's a HiveMind satellite forwarding what it hears to hivemind-core.

In a nutshell

  • Runs as the hivemind-mattermost-bridge console command, logging into Mattermost as a bot user account (email/login and password).
  • HiveMind connection details default to the stored node identity; pass the Mattermost flags each run.
  • The bridge client needs at minimum allow-msg "speak".

Beginner's mental model

The bridge logs into Mattermost as a normal bot user account (an email/login and password, not an API token), and connects to hivemind-core using your stored HiveMind identity. It relays messages between the two.


Install

pip install HiveMind-mattermost-bridge

This installs the hivemind-mattermost-bridge console command.


Set your HiveMind identity

HiveMind connection details (access key, password, host, port) default to the values stored by hivemind-client set-identity. Set it once on the machine that runs the bridge, then you only need to pass the Mattermost flags:

hivemind-client set-identity

Usage

Usage: hivemind-mattermost-bridge [OPTIONS]

Mattermost (required):
  --mail TEXT      Mattermost bot account email / login id
  --pswd TEXT      Mattermost bot account password
  --url TEXT       Mattermost server host (no scheme, e.g. chat.example.com)

Mattermost (optional):
  --tag TEXT       Tag that triggers the bot in a channel (repeatable,
                   default: @bot)

HiveMind:
  --key TEXT       HiveMind access key (default: from identity file)
  --password TEXT  HiveMind password (default: from identity file)
  --host TEXT      HiveMind host, e.g. ws://127.0.0.1 (default: from identity file)
  --port INTEGER   HiveMind port (default: 5678)
  --self-signed    Accept self-signed SSL certificates
  --lang TEXT      Utterance language (default: en-us)

Example:

hivemind-mattermost-bridge \
  --mail bot@example.com \
  --pswd "bot-password" \
  --url chat.example.com

You can also run it as a module:

python -m mattermost_bridge --mail bot@example.com --pswd "bot-password" --url chat.example.com

Direct-message the bot:

User: hello
Bot: @user , Hello! How can I help?

Mention the bot in a channel (using a trigger tag):

User: @bot what's the weather?
Bot: @user , The weather is...
Advanced: triggers, transport, and threading

--tag is repeatable, so you can give the bot several trigger mentions; it defaults to @bot. The bridge connects to Mattermost as an outbound websocket client via mattermostdriver — it runs no HTTP server, so no incoming webhook or listener port is needed on the Mattermost side. The Mattermost listen loop runs in a daemon thread alongside the HiveMind bus client.


How it works

The bridge runs as a HiveMind client. A direct message or mention becomes a recognizer_loop:utterance BUS message tagged with the sender and channel. The speak response from hivemind-core is posted back to that channel, addressed to the sender as @user , <answer>.


Permissions

The bridge client needs at minimum:

hivemind-core allow-msg "speak" <id>

Source

Validated against the HiveMind source: