Populating fields from piped emails

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
modifried
Posts: 2
Joined: Sat Aug 27, 2022 4:43 am

Populating fields from piped emails

Post by modifried »

Script URL: https://academade.com/hesk/
Version of script: 3.3.0
Hosting company: WHC
URL of phpinfo.php: https://academade.com/hesk/phpinfo.php
URL of session_test.php: https://academade.com/hesk/session_test.php
What terms did you try when SEARCHING for a solution: email splitting, piping, staff-only fields, populating ticket email

Write your message below:

I am wondering if there is any way to populate the different fields of the ticket, such as the ticket category and staff-only fields from a piped email. I have email piping configured and working, but there is not much documentation. I am sure that with time I could figure out how to implement this myself, and I will be working on this, however if there is an easier way or something already built in but not documented, it would be great to know. Thanks for any help that anybody can provide.
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Populating fields from piped emails

Post by Klemen »

There is no built-in way to do that because there is no standard way of how email messages are structured.

You will need to create this for your specific message structure, and for example use regular expressions to get the correct data from the message.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
modifried
Posts: 2
Joined: Sat Aug 27, 2022 4:43 am

Re: Populating fields from piped emails

Post by modifried »

Alright sounds good! I am sending my data as a stringified JSON so this should be easy.

EDIT: I have made the changes necessary. I will be expanding this more in the future but for now this does the job perfectly for splitting a plaintext or HTML email containing basic stringified JSON. If anybody else is ever interested in doing this it's pretty easy. I inserted this at line 105 of pipe_functions.inc.php

$tmpvar['message'] = hesk_stripQuotedText($tmpvar['message']); //existing line 103
...
$plain_message = preg_replace('/\s+/', ' ', trim(html_entity_decode($tmpvar['message'])));
$message_array = json_decode($plain_message);

if ( $message_array != null ) {
$tmpvar['message'] = $message_array->message;
$custom_message = $message_array->custom;
} else {
$custom_message = "No JSON data provided";
}

And added this below the foreach loop for custom fields (around line 375 once the other bit is added):

$tmpvar['custom1'] = $custom_message;

Works like a charm. Thanks for your help!
Post Reply