Parse email body into dynamic fields?

Moderator: crythias

Post Reply
disciple
Znuny newbie
Posts: 62
Joined: 31 Jul 2022, 12:27
Znuny Version: 6.4.2
Real Name: David Müller

Parse email body into dynamic fields?

Post by disciple »

Hello there,

I am using a process and I would like to parse in one of the steps a ticket body into a dynamic field.

I am struggeling in understandign how to parse it.

Is there any good way to do this?
E.g. I could provide a regex for parsing the body
shawnbeasley
Znuny Employee
Posts: 132
Joined: 13 Sep 2021, 09:38
Znuny Version: Znuny 6.3.x
Real Name: Shawn Beasley
Company: Znuny

Re: Parse email body into dynamic fields?

Post by shawnbeasley »

I'm not sure if I quite understand, but you can't parse the body of an e-mail to save parts of it into the dynamic field. You can parse parts of an e-mail body using the postmaster filter for incoming mails and add this to a dynamic field, but not part of a body entered by an agent in the rich text editor. Instead of allowing the user to enter free text within a rich text editor, you can just add the dynamic field itself to the form.

If you like, you can give me more information and maybe a screenshot to help describe the issue better.
disciple
Znuny newbie
Posts: 62
Joined: 31 Jul 2022, 12:27
Znuny Version: 6.4.2
Real Name: David Müller

Re: Parse email body into dynamic fields?

Post by disciple »

shawnbeasley wrote: 02 Aug 2022, 08:49 I'm not sure if I quite understand, but you can't parse the body of an e-mail to save parts of it into the dynamic field. You can parse parts of an e-mail body using the postmaster filter for incoming mails and add this to a dynamic field, but not part of a body entered by an agent in the rich text editor. Instead of allowing the user to enter free text within a rich text editor, you can just add the dynamic field itself to the form.

If you like, you can give me more information and maybe a screenshot to help describe the issue better.
let me try to explain better.

Assume following structured e-mail body of a external system, which gets into znuny as a new Ticket.
This ticket is neither written by an agent nor a human being. It is provided by a system, to which we do not have any access, but only receive e-mails.

Code: Select all

[b]Incident e-mail:[/b]
a@bc.com

[b]Given name:[/b]
John

[b]Surname:[/b]
Doe

Now I would like to have following dynamic fields:

- incidentSenderEmail (value=a@bc.com)
- incidentSenderGivenName (value=John)
- incidentSenderSurname (value=Doe)


I tried the postmasterfilter already but that thing is so hard to debug and I could not find a way to "retest" my regex, so I dropped this path.
My only way was to trigger it via new e-mails, instead like the GA to tirgger it on demand for tests and see if it works
Is there any debugging and repeating option for Postmasterfilter?
If not, I would prefer to use either a Generic Agent, which has the wished features, but thought the Process Management could do this out of the box.

Also open to upgrade to newer Znuny versions if it helps
shawnbeasley
Znuny Employee
Posts: 132
Joined: 13 Sep 2021, 09:38
Znuny Version: Znuny 6.3.x
Real Name: Shawn Beasley
Company: Znuny

Re: Parse email body into dynamic fields?

Post by shawnbeasley »

See if this blog post helps.
disciple
Znuny newbie
Posts: 62
Joined: 31 Jul 2022, 12:27
Znuny Version: 6.4.2
Real Name: David Müller

Re: Parse email body into dynamic fields?

Post by disciple »

shawnbeasley wrote: 02 Aug 2022, 09:33 See if this blog post helps.
thank you for your blob post

Just unsure if I missed the requirement to be able to test better. The Postmaster blog post, can I rerun the execution without forcing a new ticket (like e.g. with Generic Agents can do)?

AFAIK I have to resend new e-mails to test if my regex work well?
My requirement is more complex as the sample code shown.

disciple wrote: 02 Aug 2022, 09:16 I tried the postmasterfilter already but that thing is so hard to debug and I could not find a way to "retest" my regex, so I dropped this path.
My only way was to trigger it via new e-mails, instead like the GA to tirgger it on demand for tests and see if it works
Is there any debugging and repeating option for Postmasterfilter?
If not, I would prefer to use either a Generic Agent, which has the wished features, but thought the Process Management could do this out of the box.

Also open to upgrade to newer Znuny versions if it helps
Is there a more convinient option available?
Not sure about custom modules. Are there some custom modules available?
And is this maybe prossible to use in a process?
shawnbeasley
Znuny Employee
Posts: 132
Joined: 13 Sep 2021, 09:38
Znuny Version: Znuny 6.3.x
Real Name: Shawn Beasley
Company: Znuny

Test Mails

Post by shawnbeasley »

You can export a mail (activate plain view in the system configuration),

Code: Select all

bin/otrs.Console.pl Admin::Config::Update --setting-name TIcket::Frontend::PlainView --value 1
then place it on the server. Then you can run this command as often as you want, without delay.

Code: Select all

cat /path/to/your.emi| bin/otrs.Console.pl Maint::PostMaster::Read
shawnbeasley
Znuny Employee
Posts: 132
Joined: 13 Sep 2021, 09:38
Znuny Version: Znuny 6.3.x
Real Name: Shawn Beasley
Company: Znuny

Test Mails

Post by shawnbeasley »

You can export a mail (activate plain view in the system configuration),

Code: Select all

bin/otrs.Console.pl Admin::Config::Update --setting-name Ticket::Frontend::PlainView --value 1
then place it on the server. Then you can run this command as often as you want, without delay.

Code: Select all

cat /path/to/your.emi| bin/otrs.Console.pl Maint::PostMaster::Read
Post Reply