# How to extract user data from an incoming email

**URL:** https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960
**Category:** Technical assistance
**Created:** [February 17, 2023, 12:41pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960 "2023-02-17T12:41:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Speedbomb](https://community.zammad.org/user_avatar/community.zammad.org/speedbomb/32/6862_2.png) [@Speedbomb](https://community.zammad.org/u/Speedbomb)
#### Post date: [February 17, 2023, 12:41pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/1 "2023-02-17T12:41:01Z")

</div>

### Infos:

- Used Zammad version: 5.3.1 (5.3.1-1675806064.85c9455d.bullseye)
- Used Zammad installation type: package
- Operating system: Debian 11.6 (bullseye)
- Browser + version: Chrome 110, Firefox 110

### Expected behavior:

- The possibility to **extract** some **info from an** incoming **email** , such as specific text patterns with regular expressions, to add some detail data to an existing or new **user object**.
- Concretely, when an email arrives, I’d like to add the mobile number (e.g. +49123456789) of the customer in the field _mobile_ in the user object if the email body contains the text `#Mobile: +49123456789`.

### Actual behavior:

- I can’t find any possibilities in the “Filters” tab at “Settings - Channels - Email” (#channels/email) to manipulate an _user_ object. At this point, only the _ticket_ and _article_ objects are accessible.
- Also the triggers (#manage/trigger) have no possibility to change an user object.

### Steps to reproduce the behavior:

- Send an email with some specific user data in the mail body to your Zammad system.
- Try to add that data to the user account that is created or updated.

### What I’ve tried so far:

- I’ve tried to add some postmap filters or triggers to manipulate the user object.
- I’ve read the admin manual @readthedocs.
- I search the web for some phrases like “zammad email extract user data”.
- I’ve search this forum for similar phrases.

---

<div class="post-metadata">

### Author: ![Speedbomb](https://community.zammad.org/user_avatar/community.zammad.org/speedbomb/32/6862_2.png) [@Speedbomb](https://community.zammad.org/u/Speedbomb)
#### Post date: [February 20, 2023, 1:40pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/2 "2023-02-20T13:40:50Z")

</div>

Found some similar posts for this problem:

- [Postmaster: Filter should support placeholders for attributes](https://community.zammad.org/t/postmaster-filter-should-support-placeholders-for-attributes/4060)
- [Postmaster Filter use match value](https://community.zammad.org/t/postmaster-filter-use-match-value/2799)

Due to the fact that this posts were closed unresolved, I fear my requirement is unsolvable. Because I think that this would be an useful addition for many integrations, I should rather post a feature request, right?

---

<div class="post-metadata">

### Author: ![dvanzuijlekom](https://community.zammad.org/user_avatar/community.zammad.org/dvanzuijlekom/32/4510_2.png) [@dvanzuijlekom](https://community.zammad.org/u/dvanzuijlekom)
#### Post date: [February 20, 2023, 3:04pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/3 "2023-02-20T15:04:27Z")

</div>

I’d like to have some sort of intelligent filtering on this as well, **but** : this is probably hindered due to the _various_ ways people are writing phone numbers as well as email signatures. It’d be easy if everyone strictly adhered to the formatting scheme in your example, but the same phone number might also be represented as variations of:

- Tel: 0049 123456789
- 0049 (0) 123 456 789
- +49 (0)123456789
- Phone: 0-123-456-789
- ☎ (+49) 0 123 456 789

And if you take extension numbers or the addition of IVR menu choices into account (e.g. “press ‘2’ for billing”), it gets **really** weird and any regex used to filter out something that _might_ resemble a telephone number will probably match a lot more than just a phone number.  
Also: we have quite a few customers/companies who have emergency/standby or specialized numbers in their signatures, which should only be used in case of emergencies, or for specific purposes. All in all, this is very tricky to automate with filters.

I usually ask agents to be on the lookout for phone numbers in email signatures, and if these come by, have the agents check the customer’s profile if the number is already in their profile, and if it is still current (and if it is not in their profile or if it isn’t current, update the customer’s profile obviously). This is tedious work, but it does guarantee some level of consistency and uniform profile data, as we sanitize the formatting as well.

---

<div class="post-metadata">

### Author: ![Speedbomb](https://community.zammad.org/user_avatar/community.zammad.org/speedbomb/32/6862_2.png) [@Speedbomb](https://community.zammad.org/u/Speedbomb)
#### Post date: [February 20, 2023, 4:37pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/4 "2023-02-20T16:37:22Z")

</div>

@dvanzuijlekom Thanks for your reply. Perhaps I misstated my goal a bit: I do **not want** the core team to add some automated magic to extract data from incoming emails. In fact I **want** the possibility to do it on my own: e.g. some kind of postmaster filter like **[if mailbody regex ‘#phone:(?: )?(.\*)’] [then] [modify ticket.customer.phone ‘$1’]**.

---

<div class="post-metadata">

### Author: ![YetAnotherGerrit](https://community.zammad.org/user_avatar/community.zammad.org/yetanothergerrit/32/8413_2.png) [@YetAnotherGerrit](https://community.zammad.org/u/YetAnotherGerrit)
#### Post date: [February 27, 2023, 3:09pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/5 "2023-02-27T15:09:44Z")

</div>

I am not aware of a configurable solution for your problem. But you can use the webhook feature to call a helper daemon (that you’ll need to write yourself) when a ticket is created. And that helper daemon then can update the user information using the REST-API of Zammad.

Maybe something like Huginn (open source alternative to IFTTT/Zapier) also can do the job.

---

<div class="post-metadata">

### Author: ![Speedbomb](https://community.zammad.org/user_avatar/community.zammad.org/speedbomb/32/6862_2.png) [@Speedbomb](https://community.zammad.org/u/Speedbomb)
#### Post date: [February 27, 2023, 5:09pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/6 "2023-02-27T17:09:33Z")

</div>

@YetAnotherGerrit Thanks a lot for your hint. Maybe this can do the trick…

---

<div class="post-metadata">

### Author: ![system](https://community.zammad.org/uploads/default/original/1X/5c5afaea2d23f811dbec33cd4edb02fa29d3262f.png) [@system](https://community.zammad.org/u/system)
#### Post date: [March 8, 2023, 4:34pm UTC](https://community.zammad.org/t/how-to-extract-user-data-from-an-incoming-email/10960/7 "2023-03-08T16:34:00Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
