Reporting and Analytics for Service

Get Involved. Join the Conversation.

Topic

    Pavol Procka
    Is it possible extract email addresses from incident thread...Answered
    Topic posted October 24, 2018 by Pavol ProckaSilver Crown: 22,500+ Points 
    43 Views, 7 Comments
    Title:
    Is it possible extract email addresses from incident thread in OSvC
    Summary:
    Extract email addresses from incident thread
    Content:

    Hi,

    I need to extract email addresses from multiple incidents (all sent from the same email address) but with different threads (it basically is a webform our customers send the unsubscribe requests through which then arrive as incidents in OSvC).

    I know it is possible to do it in Excel, so I can simply create a report with all the threads, export it and use a formula, but was wondering whether it would be possible directly in the report in OSvC?

    The excel formula that works is (threads in column A): =TRIM(RIGHT(SUBSTITUTE(LEFT(A2,FIND(" ",A2&" ",FIND("@",A2))-1)," ",REPT(" ",LEN(A2))),LEN(A2)))

    Any idea if anything similar could be used in RN?

    example of the incident thread is: Please remove my email address - abc@test.com - from your mailing list at brand XYZ.

    The brands names have different lengths so I cannot use a trim to exact number of characters.

    Many Thanks

    Pavol

    Version:
    18B

    Best Comment

    Sebastiaan Draaisma

    Hi Pavol.

    Yes, this can be done. You could use a custom script and perform a regular expression on the thread and extract the email address
    Use https://regexr.com

    ([a-z0-9\_\-\.]{1,}@[a-z0-9\_\-\.]{1,})

    See my beginners tutorial if you are completely new to custom script
    A 'How to' on using regular expressions in custom scripts for GDPR
     

    Comment

     

    • Sebastiaan Draaisma

      Hi Pavol.

      Yes, this can be done. You could use a custom script and perform a regular expression on the thread and extract the email address
      Use https://regexr.com

      ([a-z0-9\_\-\.]{1,}@[a-z0-9\_\-\.]{1,})

      See my beginners tutorial if you are completely new to custom script
      A 'How to' on using regular expressions in custom scripts for GDPR
       

    • Pavol Procka

      Hi Sebastiaan,

       

      many thanks for this, looks like exactly what I need, although I did not manage to enter it to the custom script as yet (keep getting syntax errors when I try to preview the report). I am not sure if I am doing it right, I tried to enter it to the Process tab as is. It would be sweet if you know what I am doing wrong, but if not I guess I just need to study up on the custom scripts a bit more.

       

      Many thanks

      Pavol

    • Sebastiaan Draaisma

      Hi Pavol.

      I will try to make an example for you. Is there a fixed unsubscribe email text?
      Such as Unsubscribe = email@example.com or is this a random text (customer input)?

      If it's a fixed text then it will even be better as you then don't need to extract all email addresses from the message thread but only the relevant one.

    • Sebastiaan Draaisma

      Hi Pavol

      See attached report as an example
      The custom script used for this is

      preg_match('/([a-z0-9\_\-\.]{1,}@[a-z0-9\_\-\.]{1,})/', $rows[0][2]->val, $matches);
      $rows[0][2]->val = $matches[0];

    • Pavol Procka

      Hi Sebastiaan,

      amazing, what a nice start to a day at work :)

      I owe you some beers when you are in Gibraltar / South of Spain.

      Many Thanks

      Pavol

    • Pavol Procka

      Just to answer your questions from before:

      It is a webform our customers fill out, however the text is different as the same webform can be used for multiple brands. So it always says something like - "Please unsubscribe my email address - abc@def.com - from your XYZ brand's emails".

      We receive the emails to OSvC from a specific email address, so I  added a filter on contacts.email and since the incidents are changed to a resolved/trashed status once dealt with (it's a no-reply email) also one for incidents.status_id for the open statuses. 

      Again, many thanks

      Pavol

    • Sebastiaan Draaisma

      You are welcome Pavol
      Should I be in the area, I will let you know! :-)