Process of merging new emails into existing tickets

From time to time customers ask us why was or wasn't an email added to an existing ticket thread in the system. The answer lies in the mechanism of merging new emails to existing tickets and we will try to explain it here.

The application first looks into the source code of the received email, particularly in the email headers section, where it looks for the following fields in the given order:

- in-reply-to <Message-ID of previous message>
- references - it looks through received and sent emails in LiveAgent where the ID from references matches
- thread-index

If there isn't any ticket found on these email headers then the application looks into the subject field whether there is some ticket ID and if it finds one, it assigns the new message to that ticket (of course it must exist in the application). If even the ticket ID method fails then a new ticket is created.

Problem may be also when outgoing email server overwrites the Message-ID generated by LiveAgent. In such case the reply will not contain the Message-ID generated by LiveAgent and the reply will not be added to the original ticket, but a new ticket will be created. For example Amazon SES (Simple Email Service) does this (read more here) and we do not recommend using this service.

Specifically to overcome this problem we added an option to insert the generated Message-ID also to the References header. This way even if the Message-ID is overwritten, LiveAgent will be able to find the generated ID in References and search for it in the database when ticket reply arrives. This function is activated in the database by adding 'mail_references_myself' = 'Y' to table qu_g_settings.