Mattermost Slack



Edit on GitHub

  1. Mattermost Vs Slack Vs Teams
  2. Mattermost Slack Bridge
  3. Mattermost Slack Api

Slash commands are messages that begin with / and trigger an HTTP request to a web service that can in turn post one or more messages in response.

Slack users can activate their new Mattermost accounts by using Mattermost’s Password Reset screen with their email addresses from Slack to set new passwords for their Mattermost accounts. Once logged in, Mattermost users will have access to previous Slack messages in the public channels imported from Slack. Migrating from Bitnami ¶. Slack is the undisputed champion of the workplace group chat world. But HipChat and Mattermost have their own fans, as well. HipChat is frequently called “developer-friendly” and “IRC-like.”. Mattermost is open source and deployed on-premise, differentiating it from its competitors. Mattermost is an open source, self-hosted Slack-alternative As an alternative to proprietary SaaS messaging, Mattermost brings all your team communication into one place, making it searchable and accessible anywhere. It’s written in Golang and React and runs as a production-ready Linux binary under an MIT license with either MySQL or Postgres.

Unlike outgoing webhooks, slash commands work in private channels and direct messages in addition to public channels, and can be configured to auto-complete when typing. Note that while Mattermost includes a number of built-in slash commands, this document concerns itself only with the slash commands that can be configured as custom integrations.

Basic Usage

Follow the admin guide to create a slash command.

After creating the slash command, you’ll be given a token. Treat this as a secret. Anyone who has this token will be able to mimic requests to your application.

If you configured a slash command with a trigger word of test, a request URL of http://example.com/slash-command and a POST request method, and someone posts the message

to your Town Square channel, your endpoint will receive:

As evidenced by the Content-Type, this is a typical form-urlencoded payload similar to what you would receive from a <form method='POST'> element on an HTML web page.

Upon receiving one of these requests, your integration should immediately confirm that the token provided in the request body matches the one given to you after the slash command was created. If it does not match, it is strongly recommended that you reject the request. This ensures that the request actually came from Mattermost.

Once the request is verified, you can emit a message in the channel where the slash command was invoked by responding with a 200 status code and including a response body as follows: Download a-eberle driver.

Be sure to set the Content-Type to application/json otherwise your response will be displayed as plaintext.

Delayed and multiple responses

You can use the response_url parameter to supply multiple responses or a delayed response to a slash command. Response URLs can be used to send five additional messages within a 30-minute time period from the original command invocation.

Delayed responses are useful when the action takes more than three seconds to perform. For instance:

  • Retrieval of data from external third-party services, where the response time may take longer than three seconds.
  • Report generation, batch processing or other long-running processes that take longer than three seconds to respond.

Any requests that are made to the response URL should either be a plain text or JSON-encoded body. The JSON-encoded message supports both Markdown formatting and message attachments.

Parameters

Slash command responses support more than just the text field. Here is a full list of supported parameters.

ParameterDescriptionRequired
textMarkdown-formatted message to display in the post.If attachments is not set, yes
response_typeSet to blank or ephemeral to reply with a message that only the user can see.
Set to in_channel to create a regular message.
Defaults to ephemeral.
No
usernameOverrides the username the message posts as.
Defaults to the username set during webhook creation or the webhook creator’s username if the former was not set.
Must be enabled in the configuration.
No
channel_idOverrides the channel to which the message gets posted.
Defaults to the channel in which the command was issued.
No
icon_urlOverrides the profile picture the message posts with.
Defaults to the URL set during webhook creation or the webhook creator’s profile picture if the former was not set.
Must be enabled in the configuration.
No
goto_locationA URL to redirect the user to. Supports many protocols, including http://, https://, ftp://, ssh:// and mailto://.No
attachmentsMessage attachments used for richer formatting options.If text is not set, yes
typeSets the post type, mainly for use by plugins.
If not blank, must begin with custom_. Passing attachments will ignore this field and set the type to slack_attachment.
No
extra_responsesAn array of responses used to send more than one post in your response. Each item in this array takes the shape of its own command response, so it can include any of the other parameters listed here, except goto_location and extra_responses itself. Available in Mattermost v5.6 and later.No
skip_slack_parsingIf set to true Mattermost will skip the Slack-compatibility handling. Useful if the post contains text or code which is incorrectly handled by the Slack-compatibility logic. Available in Mattermost v5.20 and later.No
propsSets the post props, a JSON property bag for storing extra or meta data on the post.
Mainly used by other integrations accessing posts through the REST API.
The following keys are reserved: from_webhook, override_username, override_icon_url and attachments.
No

An example request using some more parameters would look like this:

FAQ

How do I debug slash commands?

To debug slash commands in System Console > Logs, set System Console > Logging > Enable Webhook Debugging to true and set System Console > Logging > Console Log Level to DEBUG.

How do I send multiple responses from a slash command.

You can send multiple responses with an extra_responses Deezer uconnect. parameter as follows.

What if my slash command takes time to build a response?

Reply immediately with an ephemeral message to confirm response of the command, and then use the response_url to send up to five additional messages within a 30-minute time period from the original command invocation.

Why does my slash command fail to connect to localhost?

By default, Mattermost prohibits outgoing connections that resolve to certain common IP ranges, including the loopback (127.0.0.0/8) and various private-use subnets.

During development, you may override this behaviour by setting ServiceSettings.AllowedUntrustedInternalConnections to '127.0.0.0/8' in your config.json or via the System Console’s Advanced > Developer page. See the admin guide’s notes for more details.

Should I configure my slash command to use POST or GET?

Mattermost Vs Slack Vs Teams

Best practice suggests using GET only if a request is considered idempotent. This means that the request can be repeated safely and can be expected to return the same response for a given input. Some servers hosting your slash command may also impose a limit to the amount of data passed through the query string of a GET request.

Ultimately, however, the choice is yours. If in doubt, configure your slash command to use a POST request.

Note that slash commands configured to use a GET request were broken prior to Mattermost release 5.0.0. The payload was incorrectly encoded in the body of the GET request instead of in the query string. While it was still technically possible to extract the payload, this was non-standard and broke some development stacks.

Why does my slash command always fail with returned an empty response?

If you are emitting the Content-Type: application/json header, your body must be valid JSON. Any JSON decoding failure will result in this error message.

Also, you must provide a response_type. Mattermost does not assume a default if this field is missing.

Why does my slash command print the JSON data instead of formatting it?

Mattermost Slack

Ensure you are emitting the Content-Type: application/json header, otherwise your body will be treated as plain text and posted as such.

Are slash commands Slack-compatible?

See the admin guide’s notes on Slack compatibility.

Mattermost Slack

How do I use Bot Accounts to reply to slash commands?

If you are developing an integration
  • Set up a Personal Access Token for the Bot Account you want to reply with.
  • Use the REST API to create a post with the Access Token.
If you are developing a plugin

Use CreatePost plugin API. Make sure to set the UserId of the post to the UserId of the Bot Account. If you want to create an ephemeral post, use SendEphemeralPost plugin API instead.

The colors of the Mattermost user interface are customizable in Account Settings > Display > Theme. You can import your theme colors from Slack, customize the colors yourself, or choose from four standard themes designed by the Mattermost team.

Any color changes you make are applied to all teams that you belong to. In Enterprise Edition, you can choose to apply the theme to the current team only, allowing you to have a different theme for each team.

Import Theme from Slack¶

To import a theme, in Slack, go to Preferences > Themes, select Create a custom theme, then copy the theme color values.

In Mattermost, select Import theme colors from Slack, then paste the color values into the input box and select Submit. Any theme settings that are not customizable in Slack will default to the “Mattermost” standard theme settings. Select Save to confirm your theme changes.

Custom Themes¶

Select Custom Theme, then expand the Sidebar Styles, Center Channel Styles, and Link and Button Styles options to customize individual interface colors, such as backgrounds, links, text, and borders.

Your custom theme changes are applied in Mattermost as you make them. Select Save to confirm your theme changes. Discard your changes by exiting the Display Settings window and selecting Yes, Discard.

Standard Themes¶

Select Theme Colors to choose from four standard themes designed by the Mattermost team. To make custom adjustments on the four standard theme colors, select a standard theme, then select Custom Theme to further customize that standard theme based on your preferences. Select Save to confirm your theme changes.

Center Channel Styles¶

Center Channel BG

Color of the center pane, right-hand sidebar and all dialog window backgrounds.

Center Channel Text

Color of all the text - with the exception of mentions, links, hashtags and code blocks - in the center pane, right-hand sidebar, and dialogs.

Mattermost Slack
New Message Separator

The new message separator appears below the last read message when you switch to a channel with unread messages.

Error Text Color

Color of all error text.

Mention Highlight BG

Highlight color behind your words that trigger mentions in the center pane and right-hand sidebar.

Mattermost Slack Bridge

Mention Highlight Link

Text color of your words that trigger mentions in the center pane and right-hand sidebar.

Code Theme

Background and syntax colors for all code blocks.

Link and Button Styles¶

Link Color

Text color of all links, hashtags, teammate mentions, and low priority UI buttons.

Button BG

Color of the rectangular background behind all high priority UI buttons.

Button Text

Text color appearing on the rectangular background for all high priority UI buttons.

Exporting a Custom Theme¶

You can export a theme from Mattermost by copying the theme values from the Custom Theme menu.

Go to Account Settings > Display > Custom Theme, then select Copy Theme Colors to export the theme’s color values.

Importing a Custom Theme¶

You can import a theme into Mattermost by pasting the theme values into the Custom Theme menu.

Copy existing theme values, then go to Account Settings > Display > Custom Theme to paste the theme values into the Copy and paste to share theme colors field. Select Save to confirm your theme changes.

Custom Theme Examples¶

Mattermost Slack Api

Customize your theme colors and share them with others by copying and pasting theme values into the input box. Below are some example themes with their corresponding theme values.

GitHub theme¶

Monokai theme¶

Solarized Dark theme¶

Gruvbox Dark theme¶

One Dark¶

Discord Dark Theme¶

Night Owl Dark theme¶