Skip to content

Commit 32cbd0c

Browse files
committed
Reworked email filters page; added extraction handling
1 parent 616e368 commit 32cbd0c

3 files changed

Lines changed: 537 additions & 242 deletions

File tree

ai/ai-agents.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ ticket and the content of the last article. You can choose to use all priorities
9393
or limit them to specific ones. In case you limit the priorities, you can also
9494
provide a description for each priority the AI agent can choose from.
9595

96+
.. _text-extractor-ai-agent:
97+
9698
Ticket Text Extractor
9799
^^^^^^^^^^^^^^^^^^^^^
98100

channels/email/filters.rst

Lines changed: 157 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Filters
22
=======
33

4+
Introduction
5+
------------
6+
47
.. toctree::
58
:hidden:
69

@@ -10,57 +13,170 @@ Filters
1013
:alt: Account settings page
1114
:align: center
1215

13-
Postmaster filters allow you to match email headers
14-
(e.g. ``From``, ``To``, ``Subject``, ``X-Spam-Flag`` etc.) and execute a set of
15-
actions whenever Zammad's email parser encounters a matching email. The actions
16-
will be applied to the ticket that is created or updated by this email.
16+
With filters in email based channels ("postmaster filters"), you can
17+
adjust Zammad's behavior, automate actions and extract information when an email
18+
is received. The filters are based on conditions and differentiate between
19+
actions for the ticket creation and the ticket update. The available options are
20+
limited to email specific attributes, which means you have options in filters
21+
which aren't available in other automation types. And the other automation types
22+
are lacking some of the email specific options. So if your use case can't be
23+
solved with filters, consider to use triggers or scheduler jobs instead.
24+
25+
Zammad includes some built-in system filters by default. You can't see or modify
26+
them, they cover useful tweaks for common systems. Check the system filters
27+
section below for more information.
28+
29+
Usage
30+
-----
31+
32+
To create a new filter, click on the **New** button. This opens a dialog where
33+
you can configure it. To modify an already existing filter, just click on its
34+
row in the table, which opens the same dialog.
35+
36+
In addition to that, you can clone or delete a filter by clicking on the ````
37+
to open the action menu and select the corresponding option. The cloning can be
38+
useful if you have a complex configuration and don't want to start from scratch.
39+
Instead of deleting a filter, consider to set it inactive so you can easily
40+
activate it again later.
41+
42+
In addition to some meta information, the configuration basically consists of
43+
two parts: the condition to define which emails are affected
44+
(**Match all of the following**) and the action to define the changes for
45+
matching emails (**Perform actions**).
46+
47+
Name
48+
Name of the filter. This is also shown in the ticket history if the filter
49+
has been applied to a ticket.
50+
51+
Match all of the following
52+
Define which emails should be affected by the filter based on conditions.
53+
You can use various email attribute checks such as sender, subject, or custom
54+
headers. They all have to match for the action to get applied. The conditions
55+
work similar to other places in Zammad. Have a look at
56+
the :doc:`object conditions page </misc/object-conditions/basics>`, where
57+
you can find details about how the operators are working.
58+
59+
It is even possible to extract information of the incoming emails and to
60+
use it in actions. An example for this could be to extract an order number
61+
from the subject and write it into a custom object attribute. This is done
62+
via regular expressions and their capture groups. To extract a string,
63+
use *matches regex* as operator and add a capture group by using parentheses
64+
for the part of the string you want to extract. Optionally, you can name
65+
the capture group by adding ``?<name>`` at the beginning of the capture
66+
group, e.g. ``.*order.*\D(?<order_number>\d+).*``.
67+
68+
.. hint:: Another way of extracting text is to use the
69+
:ref:`text extractor AI agent <text-extractor-ai-agent>`.
70+
71+
Perform actions
72+
Define which actions should be performed on the matching emails. You can
73+
differentiate between actions for the ticket creation and the ticket update.
74+
Additionally, you have some related options available like changing the
75+
visibility of the article.
76+
77+
If you extracted information in a condition, you can use it in the actions
78+
and write it to any available and fitting attribute which is capable of
79+
storing the extracted string (e.g. title or a custom object attribute).
80+
To insert the extracted string, use ``#{regex.name}`` where ``name`` is the
81+
name of the capture group you defined in the condition, e.g.
82+
``#{regex.order_number}``. For unnamed capture groups, use the number of the
83+
capture group, e.g. ``#{regex.1}`` for the first capture group. Make sure to
84+
always use the ``regex`` namespace.
85+
86+
Note
87+
Add a note about the filter. This note is only for internal use and visible
88+
for other admins.
89+
90+
Active
91+
Set the filter to active or inactive. Only active filters are applied to
92+
incoming emails.
93+
94+
Examples
95+
--------
96+
97+
Action Based on Email Sender Domain
98+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99+
100+
Example
101+
Automatically move emails from ``@amazon.com`` to the "Purchasing" group.
102+
103+
Condition
104+
**From:** *matches regex:* ``(\.|@)amazon\.com``
105+
106+
Action
107+
**Group:** Purchasing
108+
109+
Organization Based Ticket Assignment
110+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111+
112+
Example
113+
Automatically dispatch tickets to responsible staff based on the organization
114+
name.
115+
116+
Condition
117+
**Organization:** *starts with one of:* ``A`` ``B`` ``C``
118+
119+
Action
120+
**Owner:** Emily Adams
121+
122+
VIP Customer Handling
123+
^^^^^^^^^^^^^^^^^^^^^
124+
125+
Example
126+
Automatically increase the priority of tickets from a VIP customer.
127+
128+
Condition
129+
**From:** *contains:* ``ourvipcustomer@example.com``
130+
131+
Action
132+
**Priority:** 3 high
133+
134+
Spam Handling
135+
^^^^^^^^^^^^^
17136

18-
Zammad comes with system filters as well. While you can't change them, it might
19-
be useful for you what they actually do. Learn more on
20-
:doc:`filters/system-filters`.
137+
Example
138+
Automatically tag and close spam tickets that have been marked as spam by an
139+
external spam filter (e.g. SpamAssassin).
21140

22-
Different attributes of a filter can be combined with each other. Likewise,
23-
the following operators can be combined. The supported matches are:
141+
Condition
142+
**X-Spam-Flag:** *contains:* ``YES``
24143

25-
* *contains*
26-
* *contains not*
27-
* *is any of*
28-
* *is none of*
29-
* *starts with one of*
30-
* *ends with one of*
31-
* *matches regex*
32-
* *does not match regex*
144+
Action
145+
**Tag:** add: ``spam``
146+
**State:** closed
33147

34-
You can also have a look at the
35-
:doc:`object conditions </misc/object-conditions/basics>` for text fields, where
36-
you can find a description of how the operators are working.
148+
Extract Information from Subject
149+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37150

38-
.. note::
151+
Example
152+
Automatically extract an invoice number from the email subject (with an
153+
unnamed capture group) and write it to the custom object attribute
154+
"Invoice number".
39155

40-
Please note that the ticket actions are separated in "Ticket creation" and
41-
"Ticket update". Make sure to use the appropriate variant for your scenario.
156+
Condition
157+
**Subject:** *matches regex:* ``.*[Ii]nvoice.*\D(\d+).*``
42158

43-
Here are some examples of what is possible with filters:
159+
Action
160+
**Invoice number:** ``#{regex.1}``
44161

45-
Automatically dispatch tickets into certain groups:
46-
For example, tickets from ``amazon.com`` could automatically be dispatched to
47-
the Purchasing group.
162+
Extract Information from Email Body
163+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48164

49-
| From: *matches regex:* ``(\.|@)amazon\.com``
50-
| Group: Purchasing
165+
Example
166+
Automatically extract an order number from the email body (with a
167+
named capture group) and write it to the custom object attribute
168+
"Order number".
51169

52-
Automatically dispatch tickets to responsible staff based on organization name:
53-
| Organization: *starts with one of:* ``A`` ``B`` ``C``
54-
| Owner: Emily Adams
170+
Condition
171+
**Body:** *matches regex:* ``(.*[Oo]rder.*\D(?<order_number>\d+).*``
55172

56-
Automatically increase the priority of tickets from a VIP customer:
57-
| From: *contains:* ``ourvipcustomer@example.com``
58-
| Priority: 3 high
173+
Action
174+
**Order number:** ``#{regex.order_number}``
59175

60-
Automatically tag and close spam tickets that have been marked as spam by an external spam filter (e.g. SpamAssassin):
61-
| X-Spam-Flag: *contains:* ``YES``
62-
| Tag: add: ``spam``
63-
| State: closed
176+
System Filters
177+
--------------
64178

65-
If a filter is no longer needed, it can either be temporarily set inactive or
66-
deleted directly.
179+
Zammad comes with some built-in system filter by default. You can't see them in
180+
the UI. The intention is to tweak the behavior of Zammad for emails from common
181+
systems which have some kind of special formatting. Have a look at our separate
182+
sub page about :doc:`filters/system-filters` where you can find more details.

0 commit comments

Comments
 (0)