Skip to content

Commit d3f9742

Browse files
authored
Fixes #1071 - Add text extraction handling and rework email filters
1 parent 616e368 commit d3f9742

3 files changed

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

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`.
135+
Example
136+
Automatically tag and close spam tickets that have been marked as spam by an
137+
external spam filter (e.g. SpamAssassin).
21138

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

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*
142+
Action
143+
**Tag:** add: ``spam``
144+
**State:** closed
33145

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.
146+
Extract Information from Subject
147+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37148

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

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.
154+
Condition
155+
**Subject:** *matches regex:* ``.*[Ii]nvoice.*\D(\d+).*``
42156

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

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

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

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

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

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
174+
System Filters
175+
--------------
64176

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

0 commit comments

Comments
 (0)