Customization and channel inclusion of team invites

Hi all, I am happy to self-host a Mattermost free instance with the regular authentication.

I have not found answers about the following questions, about when an invite to a team is sent from Mattermost via e-mail:

  1. Can we customize any text from the invite e-mail template including the invite_illustration.png image?
  2. Can the admins visualize the list of sent invites, especially the ones that are still pending? (and ideally the history of sent reminders)
  3. Can the admins include users in private channels before they accept the invite to the team?
  4. Can we make some channels “auto-join” just like #town-square and #off-topic?

If these features are not available to configure via the GUI, have you clues about where these can be implemented in the code? Maybe some of them could be converted to new feature ideas.

Hi daddo,

let me try to answer your questions.

ad 1)
You can customize the file invite_body.html in your Mattermost server’s template directory to your needs. It also includes the following code which suggests that while you cannot change the picture itself, you can point to some other picture that better suits your needs:

<img alt height="auto" src="{{.Props.SiteURL}}/static/images/invite_illustration.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;font-size:13px;" width="246">

If you have a reverse proxy in front of your Mattermost installation, you could also just override the path to this PNG and deliver your own picture (if the sizes match).

ad 2)
Not in the GUI, as far as I know.
All the invite tokens are stored in the database, though, here’s an example from one of my test installations:

mm751=# select * from tokens;
                              token                               |   createat    |      type       |                                    extra
 pxhzn9oqdtkon3widx94npaoc333ygxc5xuronssftoesq35efkkg9u841nt61bn | 1673329170907 | team_invitation | {"email":"","teamId":"pgm7bu7rx7rfzby1rka3yiccar"}
(1 row)

I don’t think that Mattermost sends invitation reminders, but I could be wrong about that. E-Mail invitations also expire after 48hrs, JFTR.

ad 3)
No, the users are not created at this point in time (not part of the users table). If you want to preseed the accounts, you might want to look at using tools like mmctl in order to precreate the users and also add them to channels at the same time.
I’ve written a short script for someone on the community server who had a similar question, I’ll post it here so you can see what the idea behind this approach is:


# space separated list of channels to add for each user
CHANNELS="channel1 channel2 channel3"
# team to add the users to
# the maildomain added to the username
# mmctl command
MMCTL="mmctl --local"
# password to be used for all accounts. Leave empty and set PWLEN > 0 if you want passwords to be auto-generated
# set to empty string if you want to actually run the commands, set to "echo" if you just want to see what woule be done

# first parameter of the script will be the file to read the input data from
# if no parameter is given or if the file cannot be found, fail
if [ -z "$1" ] || ! [ -f "$1" ]; then
  echo "input file $1 not found."
  exit 1

while read line; do
  # split the input line by space into parts
  IFS=" " read -r -a PARTS <<< "$line"
  # generate random password if requested
  [ "$PWLEN" -gt "0" ] && PASSWORD=$(makepasswd --chars=$PWLEN)
  # create the user account
  $DEBUG $MMCTL user create --email "${PARTS[0]}@$MAILDOMAIN" --email-verified --firstname ${PARTS[1]} --lastname ${PARTS[2]} --locale en --password $PASSWORD --username ${PARTS[0]}
  # add it to all mentioned channels
  for channel in $CHANNELS; do
    $DEBUG $MMCTL channel users add $TEAM:$channel ${PARTS[0]}
  # output user + password for copy/pasting it to the users
  echo "${PARTS[0]} / $PASSWORD"
done < "$1"

ad 4)
There’s a config option for that in your config.json, it’s marked as experimental and that’s also what it is. As of yet, I’ve not managed to make it work in my installations, but YMMV.

    "TeamSettings": {
        "ExperimentalDefaultChannels": []

Check out the following form thread for the syntax and an alternative to it (the welcomebot):

Thanks @agriesser that’s very complete :love_you_gesture:

  1. Changing the template works well! I use the docker install so, changing the file inside the container gets reset every time the container restarts. I guess that making my own Dockerfile on the top of Mattermost is the best long-term option?

I don’t think that Mattermost sends invitation reminders, but I could be wrong about that.

It does :wink: After 48hrs, the e-mail is sent again with the text api.templates.invite_body.title.reminder in front of the e-mail title. The invite expires later.

  1. Thanks, I’ll use the welcomebot. Since it’s configured via its config.json I also need to find a way to make my own image to set this file I guess.

You could mount the whole template folder or just this one specific file into the container; that way it will be overriden from the outside and not overwritten by an update.
To do that, just add another line to the volumes: section in your docker-compose*.yml file. In the official example, you can see that Mattermost is doing that for the certificates already:

      - ${NGINX_CONFIG_PATH}:/etc/nginx/conf.d:ro
      - ${NGINX_DHPARAMS_FILE}:/dhparams4096.pem
      - ${CERT_PATH}:/cert.pem:ro
      - ${KEY_PATH}:/key.pem:ro
      - shared-webroot:/usr/share/nginx/html

To override just this one file, add a line that looks like this:

      - /path/to/the/template/on/your/host/invite_body.html:/mattermost/templates/invite_body.html

Thanks for the hint regarding the reminder mails - I never used this feature in production, so sorry for not being on point here.

Not sure I understand you right here - the config.json is always stored outside the container. This is being achieved by the following docker volume configuration in the docker-compose.yml file:

      - ${MATTERMOST_CONFIG_PATH}:/mattermost/config:rw

Adding some of the product planning info to this answer, we’re planning to do some working of the invites flow over the next few months. This may involve some of the following:
a) being able to customize the invite email,
b) seeing a list of invites sent, and
c) embedding the default channels and teams into the invite link

1 Like

Thanks, everything works like a charm :star_struck:

Awesome, thanks for the confirmation :slight_smile: Marking this as resolved now.