Messages that begin with /
are interpreted as slash commands. The commands will send an HTTP POST request to a web service, and process a response back to Mattermost. Mattermost supports both built-in and custom slash commands.
Note: To prevent malicious users from trying to perform phishing attacks, a BOT indicator appears next to posts coming from webhooks regardless of what username is specified.
Each Mattermost installation comes with some built-in slash commands that are ready to use. These commands are available in the latest Mattermost release:
Command | Description | Example |
---|---|---|
/away | Set your availablity to away | /away |
/offline | Set your availablity to offline | /offline |
/online | Set your availablity to online | /online |
/dnd | Set your availablity to Do Not Disturb | /dnd |
/code {text} | Display text as a code block | /code File bugs |
/collapse | Turn on auto-collapsing of image previews | /collapse |
/expand | Turn off auto-collapsing of image previews | /expand |
/echo {message} {delay in seconds} | Echo back text from your account | /echo Hello World 5 |
/header {text} | Edit the channel header | /header File bugs here |
/invite @{user} ~{channel-name} | Invite user to the channel | /invite @john ~sampleChannel |
/purpose {text} | Edit the channel purpose | /purpose A channel to discuss bugs |
/rename {text} | Rename the channel | /rename Developers |
/help | Open the Mattermost help page | /help |
/invite @{user} ~{channel-name} | Invite user to the channel | /invite @john ~sampleChannel |
/invite_people {name@domain.com …} | Send an email invite to your Mattermost team | /invite_people john@example.com |
/kick (or /remove) {@username} | Remove a member from a Public or Private channel | /kick @alice |
/join (or /open) {channel-name} | Join the given channel | /join off-topic |
/leave | Leave the current channel | /leave |
/mute | Turns off desktop, email and push notifications for the current channel or the [channel] specified | /mute ~[channel] |
/logout | Log out of Mattermost | /logout |
/me {message} | Do an action | /me Hello World |
/msg {@username} {message} | Send a Direct Message to a user | /msg @alice hello |
/groupmsg {@username1, @username2, …} {message} | Send a Group Message to the specified users | /groupmsg @alice, @bob hello |
/search {text} | Search text in messages | /search meeting |
/settings | Open the Settings dialog | /settings |
/shortcuts | Display a list of keyboard shortcuts | /shortcuts |
/shrug {message} | Add ¯\_(ツ)_/¯ to your message |
/shrug oh well |
/status {emoji_name} {descriptive status_message} | Set a custom status that includes an optional emoji and a descriptive status message | /status sick Feeling unwell and taking time off to recover |
/status clear | Clear the current status | /status clear |
Note: /status
and /status clear
slash commands listed above will be available in the Mattermost Mobile App in a future release.
Suppose you want to write an external application that is able to check the weather for certain cities. By creating a custom slash command, and setting up the application to handle the HTTP POST or GET from the command, you can let your users check the weather in their city using your command, say /weather toronto week
.
You can follow these general guidelines to set up a custom Mattermost slash command for your application.
Note: Enable integrations to override usernames must be set to true
in config.json
to override usernames, and similarly for profile picture icons. Enable them from System Console > Integrations > Integration Management or ask your Mattermost System Admin.
/
in an empty input box. Use it to make your command easier to discover by your teammates. You can also provide a hint listing the arguments of your command and a short description displayed in the autocomplete list. POST /slash-command HTTP/1.1
Host: example.com
User-Agent: Go-http-client/1.1
Content-Length: 313
Accept: application/json
Authorization: Token okwexkjpe7ygb8eq1ww58t483w
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip
channel_id=jux16pkewjrkfj3ehep1psxyxc&
channel_name=town-square&
command=%2Ftest&
response_url=http%3A%2F%2Flocalhost%3A8065%2Fhooks%2Fcommands%2Fxbrkb8p393gjpq5cawei7npije&
team_domain=test&
team_id=carya1qs77bemjup96ff538snh&
text=asd&
token=okwexkjpe7ygb8eq1ww58t483w&
user_id=aoa1agao6t8fmx3ikt1j9w5ybw&
user_name=somename
channel_mentions=["saepe-5", "aut-8"]
channel_mentions_ids=["r3j6sby343fpfdxcbwqg95rfsa", "ehjj46yk7ifptr5bpfb966s6mc"]
user_mentions=["aaron.peterson", "aaron.medina"]
user_mentions_ids=["q5s3b7xzgprp5eid8h66j9epsy", "czwmumrmw7dfxecww7qibkkoor"]
If your integration sends back a JSON response, make sure it returns the application/json
content-type.
town-square
, it can respond to the HTTP POST request with a JSON response such as: {"response_type": "in_channel", "text": "
---
#### Weather in Toronto, Ontario for the Week of February 16th, 2016
| Day | Description | High | Low |
|:--------------------|:---------------------------------|:-------|:-------|
| Monday, Feb. 15 | Cloudy with a chance of flurries | 3 °C | -12 °C |
| Tuesday, Feb. 16 | Sunny | 4 °C | -8 °C |
| Wednesday, Feb. 17 | Partly cloudly | 4 °C | -14 °C |
| Thursday, Feb. 18 | Cloudy with a chance of rain | 2 °C | -13 °C |
| Friday, Feb. 19 | Overcast | 5 °C | -7 °C |
| Saturday, Feb. 20 | Sunny with cloudy patches | 7 °C | -4 °C |
| Sunday, Feb. 21 | Partly cloudy | 6 °C | -9 °C |
---
"}
which would render in Mattermost as:
Note: Enable integrations to override usernames must be set to true
in config.json
to override usernames. Enable them from System Console > Integrations > Integration Management, or ask your System Admin to do so. If not enabled, the username is set to webhook
.
Similarly, Enable integrations to override profile picture icons must be set to true
in config.json
to override profile picture icons. Enable them from System Console > Integrations > Integration Management, or ask your System Admin to do so. If not enabled, the icon of the creator of the webhook URL is used to post messages.
If you’ve built an integration for Mattermost, please consider sharing your work in our app directory.
The app directory lists open source integrations developed by the Mattermost community and are available for download, customization and deployment to your private cloud or self-hosted infrastructure.
Mattermost makes it easy to migrate integrations written for Slack to Mattermost.
Mattermost automatically translates the data coming from Slack:
JSON responses written for Slack, that contain the following, are translated to Mattermost Markdown and rendered equivalently to Slack:
<>
to denote a URL link, such as {"text": "<https://mattermost.com/>"}
.|
within a <>
to define linked text, such as {"text": "Click <https://mattermost.com/|here> for a link."}
.<userid>
to trigger a mention to a user, such as {"text": "<5fb5f7iw8tfrfcwssd1xmx3j7y> this is a notification."}
.<!channel>
, <!here>
, or <!all>
to trigger a mention to a channel, such as {"text": "<!channel> this is a notification."}
.Both the HTTP POST and GET request bodies sent to a web service are formatted the same as Slack’s. This means your Slack integration’s receiving function does not need change to be compatible with Mattermost.
icon_emoji
to override the username is not supported.<#CHANNEL_ID>
does not link to the channel.<!everyone>
and <!group>
are not supported.*bold*
is not supported (must be done as **bold**
).See developer documentation for troubleshooting, or join the Mattermost user community for help.