Notifications in Mattermost

Last update: 28.06.2023

The general logic for setting up notifications about new cases and customer replies is described here. Other instructions:

In Mattermost, you need to add an incoming webhook in the settings of the channel to which the notifications will be sent. Then create automation rules in Deskie to send notifications.

In the example we consider the option of sending all notifications to a separate channel, which we have created in advance in Mattermost and named Deskie Notifies.

Setting up the webhook in Mattermost

1. Ensure that your Mattermost server settings allow you to accept incoming webhooks. To do this, go to the menu under System Console → Integrations → Integration Management. The value of the "Enable incoming webhooks" option should be "true". If you do not have access to the system console, contact your administrator.

07df7ebf8f71e110429b9e4e8814d5a0.png

Integration permissions for overriding names and image icons will allow you to add arbitrary bot names and avatars. This makes it easier for you to differentiate notifications from Deskie among other correspondence in the channel. If you don't give these permissions, the notifications will appear in the name of the webhook creator and with his/her avatar. You can distinguish them from ordinary messages from the same user by the label "BOT". If these permissions are granted, there will be fields in the webhook settings to add the bot's own name and avatar, and the ability to pass the username and icon_url using a request directly in the webhook's code.

2. Go to the settings for the Mattermost channel to which you plan to receive notifications and configure the incoming webhook.

а. From the main menu, go to "Integrations", select the "Incoming webhooks" option and press "Add new webhook".

a7315426e8284ae99cb3c6e1bf570085.gif

b. Fill in the suggested form and save your changes. Be sure to select only the channel you want the notifications to go to, you can leave the other fields blank.

2a3b41f451e0ab01438509cb694dd5f1.png

c. Copy the URL of your incoming webhook.

ca4a9cc0402ecf3ec21deffd81af88de.png

Creating rules in Deskie

3. Create rules in Deskie to send notifications to Mattermost: Admin account → Channels → Rules subsection.

a. To receive Mattermost notifications about new cases, create a rule for new cases:

89a9200680c8644da8eb8051299d2fd3.png

In the "then perform action" box select the "Send webhook" option, then specify the POST method. In the "URL for sending request to" box insert the webhook URL you copied from Mattermost.

Select the "Custom request" option below in JSON format and add the request code:

{"text":"**#[case_number]: [case_subject]**\n_[user_full_name]_: [user_email]\n\n[case_description|text]\n\n[reply to a case]([case_url])"}

You can use any variables you want in your text. For a complete list of available variables, see the "variables" link in the rule creation form itself.

A notification using the above code would look like this:

0afed2561fea2010c96c99569db15786.png

b. To receive notifications in Mattermost about new replies in chats and cases, create a rule for updated cases.

3fcbf1ff57698d003a2e9de26a955f1e.png

In the "then perform action" box select the "Send webhook" option, then specify the POST method. In the "URL for sending request to" box insert the webhook URL you copied from Mattermost.

Select the "Custom request" option below in JSON format and add the request code with the variables you require, similar to the rule for new cases from step 3a in this guide:

{"text":"**#[case_number]: [case_subject]**\n_[user_full_name]_: [user_email]\n\n[case_description|text]\n\n[reply to a case]([case_url])"
}

A notification using the above code would look like this:

f698103117d90ee3985c108801f9eb70.png

This completes the notification setting, you will now receive notifications in Mattermost and won't miss new messages from your customers.

PRO hint
: In new chats, the case subject is formed based on the first message from the customer:

  • sometimes such a message can be quite long and break the layout of your notification;

  • the text of the message itself will then duplicate the subject.

To ensure this doesn't happen, it is better to create separate rules for new email-based cases and cases from synchronous channels and avoid using the [case_subject] variable in the request code for notifications about new chats.

Advanced features

4. You can flexibly set up notifications by creating different channels for them in Mattermost and by writing the right conditions in the rules on the Deskie side.

For example, you can send notifications from the "Billing" group only to agents in the finance department by adding a channel to the "Billing" category in Mattermost. You can inform the right agents (including those who don't have a Deskie account) when they receive a case with a specific subject, from a specific user, when a tag is added, etc.

5. The name and avatar of the user from whom the notifications will come, can be added either when setting up the incoming webhook in Mattermost when filling in the form in step 2b, or in the body of the webhook itself in Deskie. To do this, add the appropriate lines with username and icon_url to the text. In the examples we use the Deskie logo, you will need to specify the path to the image you want:

{"username":"Deskiebot",
"icon_url":"[link to your iamge]",
"text":"**#[case_number]: [case_subject]**\n_[user_full_name]_: [user_email]\n\n[case_description|text]\n\n[reply to a case]([case_url])"}

The option of specifying username and icon_url directly in the webhook code is handy if you want to visually differentiate notifications within the same channel.

An example of a rule for new VIP customer cases to distinguish them from other notifications.

637fccdc1b4a3647b60877b94888ebbf.png
5626c9fa2d9a35cda67ed866abf5bedb.png

6. Add a mention in the messenger. You can tag a desired agent or group of agents via @username, @channel, @all, @here, or @groupname. Read more in the Mattermost documentation

If you want to mention the assignee, then you will require rules for the automatic distribution of cases and rules for each agent that will send a notification mentioning the assignee to Mattermost when a new case comes in.

а. An example of rules for new cases to send a notification mentioning an agent to Mattermost:

5d4867f68094a6f3b24650b566b231e7.png

Use the following custom request text:

{
    "username": "New case",
    "text":"**#[case_number]: [case_subject]**\n\n**Assignee**: @[username]\n**Priority**: [case_priority]\n\n[case_description|text]\n\n[reply to a case]([case_url])"
}

Example of a display:

b16c1e992ae29c5f949475c09232e9e3.png


PRO hint
: To add rules more quickly, use the clone function and then edit only the data of the agent mentioned in the rules. Combine the rules created for all agents into one group.

Place the created rule group after the rule which sets assignees in a case. For example, to evenly set available agents as assignees in cases, except the manager and those with "view-only" access, you can use a rule like this:

209778506ba459e34dcdfceeb8226c90.png

b. To send a notification in Mattermost, mentioning the assignee when a new response is received in a case, you will also need separate rules for updated cases for each agent, which we recommend grouping together. Here is an example of such a rule:

0a182d8270fd9f4645e9dcea8859acef.png

Use the following custom request text:

{
    "username": "New reply in a case",
    "text":"**#[case_number]: [case_subject]**\n\n**Assignee**: @[username]\n**Priority**: [case_priority]\n\n[last_message|text]\n\n[reply to a case]([case_url])"
}

Example of a display:

7b7bd740d165526b55c19927615fb6ed.png

7. Send notifications directly to the agent so as not to overload the channels with unnecessary information. To do this, add the variable "channel" at the beginning of any code request after the first curly bracket: "@[username]":

{
"channel": "@[username]",
"text":"**#[case_number]: [case_subject]**\n_[user_full_name]_: [user_email]\n\n[case_description|text]\n\n[reply to a case]([case_url])"
}

The incoming webhook created in Step 2 must not be locked to a channel:

5118baebed1fe3ae5e2e5d08e6d74a8b.png

These notifications will be sent to the agent's private messages on behalf of the webhook creator. The webhook creator will also see the notifications received by the agent. The webhook creator cannot send notifications to itself, only to another user or to a channel it participates in. To send a notification to a channel, specify in the variable "channel": "[channel]" without @.

Example of a display:

17ef19e3537b5c307ef9dd4ab61582a0.png

Was this article helpful?