2020-07-20 17:09:23 -04:00
---
2021-08-02 11:08:56 -04:00
stage: Ecosystem
group: Integrations
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-07-20 17:09:23 -04:00
---
2021-02-17 13:09:19 -05:00
# Mattermost slash commands **(FREE)**
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
If your team uses [Mattermost ](https://mattermost.com/ ) as a chat service, you can
integrate GitLab commands into Mattermost chat. This integration enables users to
run common operations, such as creating a GitLab issue, from the Mattermost chat
environment.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
GitLab can also send events (such as `issue created` ) to Mattermost as part of the
separately configured [Mattermost Notifications Service ](mattermost.md ).
2019-06-19 03:11:24 -04:00
2017-02-03 13:41:35 -05:00
## Prerequisites
2021-10-18 02:12:21 -04:00
Mattermost [3.4 or later ](https://mattermost.com/blog/category/platform/releases/ ) is required.
2021-02-25 13:11:05 -05:00
GitLab provides different methods of configuring Mattermost slash commands, depending
on your configuration:
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
- **Omnibus GitLab installations**: Mattermost is bundled with
[Omnibus GitLab ](https://docs.gitlab.com/omnibus/ ). To configure Mattermost for Omnibus GitLab, read the
2021-09-16 14:11:32 -04:00
[Omnibus GitLab Mattermost documentation ](../../../integration/mattermost/index.md ).
2021-02-25 13:11:05 -05:00
- **If Mattermost is installed on the same server as GitLab**, use the
[automated configuration ](#automated-configuration ).
- **For all other installations**, use the [manual configuration ](#manual-configuration ).
2017-02-03 13:41:35 -05:00
2020-05-07 14:09:28 -04:00
## Automated configuration
2017-02-03 13:41:35 -05:00
If Mattermost is installed on the same server as GitLab, the configuration process can be
2017-02-06 09:46:58 -05:00
done for you by GitLab.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
Go to the Mattermost Slash Command service on your project and click **Add to Mattermost** button.
2017-02-03 13:41:35 -05:00
2020-05-07 14:09:28 -04:00
## Manual configuration
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
To manually configure slash commands in Mattermost, you must:
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
1. [Enable custom slash commands ](#enable-custom-slash-commands ) in Mattermost.
1. [Get configuration values ](#get-configuration-values-from-gitlab ) from GitLab.
1. [Create a new slash command ](#create-a-slash-command ) in Mattermost.
1. [Provide the Mattermost token ](#provide-the-mattermost-token-to-gitlab ) to GitLab.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
### Enable custom slash commands
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
NOTE:
Omnibus GitLab installations are preconfigured. This step is required only for
installations from source.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
To enable custom slash commands from the Mattermost administrator console:
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
1. Sign in to Mattermost as a user with administrator privileges.
1. Next to your username, click the ** {ellipsis_v}** **Settings** icon, and
select **System Console** .
1. Select **Integration Management** , and set these values to `TRUE` :
- **Enable Custom Slash Commands**
- **Enable integrations to override usernames**
- **Enable integrations to override profile picture icons**
1. Click **Save** , but do not close this browser tab, because you need it in
a later step.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
### Get configuration values from GitLab
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
After you enable custom slash commands in Mattermost, you need configuration
information from GitLab. To get this information:
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
1. In a different browser tab than your current Mattermost session, sign in to
2021-06-13 20:09:37 -04:00
GitLab as a user with [Administrator role ](../../permissions.md ).
2021-08-26 05:11:15 -04:00
1. On the top bar, select **Menu > Admin** .
2021-06-13 20:09:37 -04:00
1. In the left menu, select **Settings > Integrations** , then select
2021-02-25 13:11:05 -05:00
**Mattermost slash commands** .
1. GitLab displays potential values for Mattermost settings. Copy the **Request URL**
as you need it for the next step. All other values are suggestions.
1. Do not close this browser tab, because you need it in future steps.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
Next, create a slash command in Mattermost with the values from GitLab.
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
### Create a slash command
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
To create a slash command, you need the values you obtained from GitLab in
the previous step:
2017-02-03 13:41:35 -05:00
2021-02-25 13:11:05 -05:00
1. In the Mattermost tab you left open when you
[enabled custom slash commands ](#enable-custom-slash-commands ), go to your
team page.
1. Click the ** {ellipsis_v}** **Settings** icon, and select **Integrations** .
1. In the left menu, select **Slash commands** .
1. Click **Add Slash Command** :
2017-02-03 13:41:35 -05:00
2019-08-12 05:54:30 -04:00
![Mattermost add command ](img/mattermost_add_slash_command.png )
2021-02-25 13:11:05 -05:00
1. Provide a **Display Name** and **Description** for your new command.
1. Provide a **Command Trigger Word** according to your application's configuration:
- **If you intend to only connect one project to your Mattermost team**: Use
`/gitlab` for your trigger word.
- **If you intend to connect multiple projects**: Use a trigger word that relates
to your project, such as `/project-name` or `/gitlab-project-name` .
1. For **Request URL** , provide the value you copied from GitLab when you
[viewed configuration values ](#get-configuration-values-from-gitlab ).
1. For all other values, you may use the suggestions from GitLab or use your
preferred values.
1. Copy the **Token** value, as you need it in a later step, and click **Done** .
### Provide the Mattermost token to GitLab
When you create a new slash command in Mattermost, it generates a token you must
provide to GitLab:
1. In the GitLab browser tab from
[getting configuration values from GitLab ](#get-configuration-values-from-gitlab ),
2021-08-12 20:09:14 -04:00
select the **Active** checkbox to enable this configuration.
2021-02-25 13:11:05 -05:00
1. In the **Token** field, paste the token you obtained from Mattermost.
2020-04-15 08:09:18 -04:00
ensure that the **Active** toggle is enabled.
2017-02-03 13:41:35 -05:00
2019-08-12 05:54:30 -04:00
![Mattermost copy token to GitLab ](img/mattermost_gitlab_token.png )
2017-02-03 13:41:35 -05:00
1. Click **Save changes** for the changes to take effect.
2021-02-25 13:11:05 -05:00
Your slash command can now communicate with your GitLab project.
2017-02-03 13:41:35 -05:00
## Authorizing Mattermost to interact with GitLab
2020-12-01 13:09:42 -05:00
The first time a user interacts with the newly created slash commands,
Mattermost triggers an authorization process.
2017-02-03 13:41:35 -05:00
![Mattermost bot authorize ](img/mattermost_bot_auth.png )
2020-12-01 13:09:42 -05:00
This connects your Mattermost user with your GitLab user. You can
2017-02-03 13:41:35 -05:00
see all authorized chat accounts in your profile's page under **Chat** .
When the authorization process is complete, you can start interacting with
GitLab using the Mattermost commands.
## Available slash commands
2021-02-25 13:11:05 -05:00
The available slash commands for Mattermost are:
2017-02-03 13:41:35 -05:00
| Command | Description | Example |
| ------- | ----------- | ------- |
2019-09-30 02:06:02 -04:00
| < kbd > /< trigger> issue new < title> < kbd > ⇧ Shift</ kbd > +< kbd > ↵ Enter</ kbd > < description> </ kbd > | Create a new issue in the project that `<trigger>` is tied to. `<description>` is optional. | `/gitlab issue new We need to change the homepage` |
| < kbd > /< trigger> issue show < issue-number> </ kbd > | Show the issue with ID `<issue-number>` from the project that `<trigger>` is tied to. | `/gitlab issue show 42` |
2021-06-28 17:10:13 -04:00
| < kbd > /< trigger> deploy < environment> to < environment> </ kbd > | Start the CI job that deploys from one environment to another, for example `staging` to `production` . CI/CD must be [properly configured ](../../../ci/yaml/index.md ). | `/gitlab deploy staging to production` |
2017-02-03 13:41:35 -05:00
To see a list of available commands to interact with GitLab, type the
2019-09-30 02:06:02 -04:00
trigger word followed by < kbd > help</ kbd > . Example: `/gitlab help`
2017-02-03 13:41:35 -05:00
![Mattermost bot available commands ](img/mattermost_bot_available_commands.png )
## Permissions
2017-02-06 09:46:58 -05:00
The permissions to run the [available commands ](#available-slash-commands ) derive from
2019-03-05 07:55:30 -05:00
the [permissions you have on the project ](../../permissions.md#project-members-permissions ).
2017-02-03 13:41:35 -05:00
2020-05-07 14:09:28 -04:00
## Troubleshooting
2021-02-25 13:11:05 -05:00
If an event is not being triggered, confirm that the channel you're using is a public one.
2020-05-07 14:09:28 -04:00
Mattermost webhooks do not have access to private channels.
If a private channel is required, you can edit the webhook's channel in Mattermost and
select a private channel. It is not possible to use different channels for
2020-12-01 13:09:42 -05:00
different types of notifications. All events are sent to the specified channel.
2020-05-07 14:09:28 -04:00
2017-02-03 13:41:35 -05:00
## Further reading
2020-04-06 08:10:44 -04:00
- [Mattermost slash commands documentation ](https://docs.mattermost.com/developer/slash-commands.html )
- [Omnibus GitLab Mattermost ](https://docs.gitlab.com/omnibus/gitlab-mattermost/ )