Menu

Issue with " Email to ticket automation" plugin

2024-02-20
2024-03-10
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-20

    Hi team,

    I'm currently using the "Email to Ticket Automation" extension in iTOP, which allows us to create and update tickets via email as per the extension description. However, I'm facing an issue while updating the ticket through email. While I can create tickets successfully via email, when I attempt to update the same ticket via email, a new ticket is being created with the old ticket reference.

    Could someone please guide me on how to fix this issue?

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-02-20
    • Does the e-mail response contain the ticket reference in the subject?
    • Did you properly configure the ticket title pattern?
     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-20
    • Does the e-mail response contain the ticket reference in the subject - YES
    • Did you properly configure the ticket title pattern - itop configuration below
      'itop-standard-email-synchro' => array (
      'inline_image_max_width' => '500',
      'ticket_log' => array (
      'UserRequest' => 'public_log',
      'Incident' => 'public_log',
      ),
     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-02-20

    This doesn't show anything related to the ticket title pattern. We'd need to see a screenshot of the configuration of the mailbox in the iTop console (GUI).

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-21

    I am currently utilizing the Email-to-Ticket Automation extension in iTop, which allows us to create and update tickets via email. However, I have encountered an issue that I would like to bring to your attention.

    The problem arises when I receive an email from iTop regarding a ticket, and I proceed to close the ticket from the portal. After closing the ticket, if I respond to the same email with the ticket number removed from the subject line, iTop updates the data on the existing closed ticket instead of creating a new ticket.

    This behavior is causing some confusion and inefficiency in our ticket management process. I would appreciate your guidance on how we can resolve this issue. Is there a setting or configuration adjustment that needs to be made to ensure that responding to emails without the ticket number in the subject line creates a new ticket instead of updating the existing closed ticket?

    Thank you for your attention to this matter. I look forward to your prompt assistance and resolution of this issue.

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-02-21

    Resolved or closed ticket?

    iTop natively tries to identify it based on the email subject containing a ticket reference. I believe it also tries to identify it based on an e-mail header.

    If I'm not mistaken, it will also only reopen tickets which are marked as "resolved". I vaguely remember having to adjust the datamodel to do the opposite, and support re-opening old closed tickets.

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-21

    Hi, thank you for your reply. I'm discussing closed tickets and the issue where, despite changing the subject line, the email message still indicates that the data is being updated on the closed ticket.

    If I need to make changes in the data model, which context should I use so that if a ticket is closed and I change the subject in the email, a new ticket is created in iTop, and no data update occurs on the existing closed ticket?

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-22

    @jeffrey @cisou

    Hi, I have conducted the following tests on the Email-to-Ticket Automation extension:

    In the first test, I removed the ticket number from the received email notification.
    During the second test, I removed the ticket number from the email subject and completely changed the subject before replying to the email.
    In the third round of testing, I changed the entire email subject line and even removed almost all the data from the email body.
    Despite these tests, the Email-to-Ticket Automation extension still updates the existing ticket instead of creating a new one. Ideally, modifying the subject line of an email should result in the creation of a new ticket in iTop.

    I would like to inquire if anyone else has encountered the same issue with this extension. If someone has found a solution to this problem, could you please share it with me?

    Additionally, if any modifications need to be made to the data model to resolve this issue, I would appreciate any suggestions in that regard.

    My objective is to ensure that making changes to the subject line of an email results in the creation of a new ticket in iTop, rather than updating an existing one.

     
  • Lari

    Lari - 2024-02-22

    I would first investigate your situation by switching mail inbox properties debug = YES. Then I'd send a sample email(s) and see what comes out. (Remember to refresh the Debug Trace tab to see latest results.)

    If trace is not helpful, then in your (modify itopPATH to fit yours):
    /var/www/html/itopPATH/env-production/itop-standard-email-synchro/ model.itop-standard-email-synchro.php

    search for a protected function GetRelatedTicket(EmailMessage $oEmail)

    I'd try switching (our code is modified but this is probably original code)
    $oFilter = DBSearch::FromOQL('SELECT Ticket WHERE ref = :ref AND operational_status != "closed"');
    to
    $oFilter = DBSearch::FromOQL('SELECT Ticket WHERE ref = :title AND operational_status != "closed"');
    ..and send some test emails again

    If there are still problems, some new trace lines could help to get more information. So inside the function add lines like :
    $emailtitle = $oEmail->sSubject;
    $this->Trace("Title was: ".$emailtitle);

    And test again with debug trace on and see what comes out.

    Any modifications will be overwritten if you run setup when upgrading. Depending how your extension has been installed, you should at least put your code to the file datamodel.itop-standard-email-synchro.xml (same directory where the model.xx exists)

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-23

    Hi @Lari ,

    Thanks for your suggestion ,

    I am writing to address some concerns regarding the updates made to the code as per your provided points and suggestions.

    Despite making changes in the code and thoroughly testing them, I have noticed that the ticket email headers are still being updated, regardless of any modifications made to the ticket itself.

    I am open to any further suggestions or insights you may have on this matter. One potential solution could be to have the system analyze the content of incoming emails, particularly focusing on the subject or title, to determine whether a ticket needs to be created or updated, rather than solely relying on the email header information.

    I believe implementing such a solution could enhance the efficiency and accuracy of our ticketing system. I would appreciate your thoughts and feedback on this proposal.

     
  • Pierre Goiffon

    Pierre Goiffon - 2024-02-28

    Hello,

    One potential solution could be to have the system analyze the content of incoming emails, particularly focusing on the subject or title, to determine whether a ticket needs to be created or updated, rather than solely relying on the email header information.

    Parsing on subject is already done, see MailInboxStandard::GetRelatedTicket
    In the mailbox configuration, you have a title pattern option, see https://www.itophub.io/wiki/page?id=extensions:ticket-from-email#behavior_on_incoming_emails

    Also, contributions are more than welcome, the corresponding repositories for the extension are public, check their CONTRIBUTING.md file.

     
    👍
    1
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-02-28

    You can also check out my fork -

    It's easier to implement custom steps/flows. I've developed some for personal use as well, and for some customers

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-29

    Hi @Jeffrey, so have you also developed the scenario where email should be considered as a subject/title rather then email header.
    and the below url is your fork url right.
    https://github.com/jbostoen/itop-jb-mail-to-ticket-automation-v2

    if not can you provide the url for the same.

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-02-29

    As Pierre mentioned above, and as I already explained: also Combodo's Mail to Ticket Automation can already identify by subject - as long as the ticket reference "R-012345" is in there. (or if you have customized the ticket reference, you just need to update the title pattern).

    From the top of my head, it works as long as the ticket is not "closed" (and I t hink also not "resolved"), but would need to check that).

     

    Last edit: Jeffrey Bostoen 2024-02-29
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-29

    Hi @jeffrey,
    as i have checked the code , yes email ticket also find the title_pattern but in the first step of the model.itop code it is finding the data by email header , so my ask is i did not want to search the ticket data by email i just want to search the data only subject/title of the email. if title matched then update the ticket or if i changed the subject/title from the email then it means extensions must be create a new ticket because of the new title .

    the existing logic are below.
    "
    protected function GetRelatedTicket(EmailMessage $oEmail)
    {
    // First check if there is any iTop object mentioned in the headers of the eMail
    $oTicket = parent::GetRelatedTicket($oEmail);

        if ($oTicket == null)
        {
            // No associated ticket found by parsing the headers, check
            // if the subject does not match a specific pattern
            $sPattern = $this->FixPattern($this->Get('title_pattern'));
            if(($sPattern != '') && (preg_match($sPattern, $oEmail->sSubject, $aMatches)))
            {
                $oFilter = DBSearch::FromOQL('SELECT Ticket WHERE ref = :ref');
                foreach ($aMatches as $sMatch)
                {
                    if (!empty($sMatch))
                    {
                        $this->Trace("iTop Simple Email Synchro: Retrieving ticket $sMatch (match by subject pattern)...");
                        $oSet = new DBObjectSet($oFilter, array(), array('ref' => $sMatch));
                        $oTicket = $oSet->Fetch();
                        if ($oTicket)
                        {
                            break;
                        }
                    }
                }
            }
        }       
        return $oTicket;
    }
    

    "

    and i have modified the logic where i have removed the header path from the code . but still ticket is updated with the help of header . i did not understand what is missing in the code which i have create.

    "
    protected function GetRelatedTicket(EmailMessage $oEmail)
    {
    // Check if the subject matches a specific pattern
    $sPattern = $this->FixPattern($this->Get('title_pattern'));
    if(($sPattern != '') && (preg_match($sPattern, $oEmail->sSubject, $aMatches)))
    {
    $oFilter = DBSearch::FromOQL('SELECT Ticket WHERE ref = :ref');
    foreach ($aMatches as $sMatch)
    {
    if (!empty($sMatch))
    {
    $this->Trace("iTop Simple Email Synchro: Retrieving ticket $sMatch (match by subject pattern)...");
    $oSet = new DBObjectSet($oFilter, array(), array('ref' => $sMatch));
    $oTicket = $oSet->Fetch();
    if ($oTicket)
    {
    return $oTicket; // Return the found ticket
    }
    }
    }
    }

    // If no ticket found using subject, create a new ticket
    $oTicket = $this->CreateTicketFromEmail($oEmail, $oCaller);
    
    return $oTicket; // Return the newly created ticket
    

    }
    "

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-02-29

    Hi Guys ,

    all these changes i have made in the Datamodel->itop-standard-email-synchro->module.itop-standard-email-synchro.

    it is the correct location for changing the logics of the emails functions.

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-02-29

    The main question remains: do you want to match the e-mail only if the e-mail subject contains the ticket reference (R-0123456)?

    Or do you want to go for a (much riskier) approach where you match only on the actual title? ( Also consider that you might get prefixes in the subject, such as RE: / FW: / FWD: ). You might want to add more logic at that point.

    For one of my clients, I did create a mail processing step which matched the e-mail as long as it has the same e-mail subject (it removed prefixes such as RE: / FW: / FWD: )

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-03-01

    1- The main question remains: do you want to match the email only if the email subject contains the ticket reference (R-0123456)?

    Should I inquire whether you want the email to be matched only when the email subject contains the ticket reference (R-0123456)? If I add logic to match the email with the ticket reference, will it skip the scenario of email headers? For instance, if an email is related to a ticket with the subject line (R-0123456), and when I reply, I remove the ticket reference and send it with random text instead, will a new ticket be created in this case, or will the header logic not be affected?

    2- (it removed prefixes such as RE: / FW: / FWD: ) I think , by doing this, it will check and update more tickets.

    I believe that by removing prefixes such as RE: / FW: / FWD:, the system will check and update more tickets.

    3rd question is, if I want to change the 1st point, which file should I make changes to?

    If I wish to modify the 1st point, which file should I edit?

     

    Last edit: Rohit Kushwaha 2024-03-01
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-03-01

    Hi Guys ,

    I'm making some changes or modifications at the code level in the file model.itoppstandard-email-synchro.php inside the datamodel->itop-standard-email-synchro folder for email to ticket automation extenstion .

    However, these changes are not being replicated or visible on iTop. What steps should I follow to ensure that the changes are replicated on the iTop portal?

    Before changes:
    "$this->Trace("iTop Simple Email Synchro: Error: the incoming email refers to the ticket ".$oTicket->GetName()." of class ".get_class($oTicket).", but this mailbox is configured to process only tickets of class ".$this->Get('target_class'));"

    After changes:
    "$this->Trace("iTop Test: Error: the incoming email refers to the ticket ".$oTicket->GetName()." of class ".get_class($oTicket).", but this mailbox is configured to process only tickets of class ".$this->Get('target_class'));"

    waiting for your reply.

     
  • Pierre Goiffon

    Pierre Goiffon - 2024-03-07

    This is a very bad practice : forking the source code will prevent you from updating it ! You should use the Combodo extensibility model instead, by creating a custom module. See https://www.itophub.io/wiki/page?id=latest:customization:start

     
  • Rohit Kushwaha

    Rohit Kushwaha - 2024-03-10

    HI @pierre ,

    I checked the email to ticket automation extension webpage where I found an FAQ section. I am implementing the same thing discussed there into the code. However, my closed tickets are still being updated. For reference, I'm attaching the portal code.

    is there another possibility to get the same scenario.

    Regards,
    Rohit

     

Log in to post a comment.