Server Information
osTicket Version v1.12 (a076918) — Up to date
Web Server Software Apache/2.4.6 (CentOS)
MySQL Version 5.5.60
PHP Version 7.3.5
OS: CentOS 7.3

Hi,

Use case:
- Customer sends an email requesting for invoice copy.
- This email is downloaded into OST
- We reply to the customer informing him that he will receive an email from our business application.
- We email the invoice via the business application.
---> For future reference purpose, we would like to add a copy of this email in the same OST thread.

Is there an API which will allow me to insert the mail from the business application into OST?

What is the best way to achieve this?

Thanks

There is no API to do this at this time.

You could use the ticket open API to open a new ticket for that customer and send the invoice. This is the easiest and fastest 'solution' but probably the least graceful.

Otherwise you would have to write a script to either:

  • locate the ticket and update it with the desired message [and presumably an attachment] interaction with the DB via the script
  • write a script to get the message ID of the ticket [presuming it has one] and spoof the message id so it thinks it should be part of that ticket... You might also need to put the ticket # in the email that it generates. If you are using piping to osTicket (see docs https://docs.osticket.com/en/latest/Getting%20Started/Email%20Piping.html ) it would need to handle the output of the script as if you sent an email.

Both of those options would require a coder to implement.

Thanks @ntozier
Let me try some options, if it works, I'll share it with the community so it can help others seeking a similar solution.
Best regards

@ntozier I'm trying this option:
---> write a script to get the message ID of the ticket [presuming it has one] and spoof the message id so it thinks it should be part of that ticket... You might also need to put the ticket # in the email that it generates. <---

I'm doing the following:
- Getting the ticket # & subject text from the OST database
- Construct the subject line for the outgoing email
---> Re: [#671636] test email <---
- Send the email to the customer
- Send one copy of the same email to the email address configured in OST (which is downloaded in OST via cron.php)

Problem:
The copy of the email gets downloaded in OST, but does not get added to the existing thread. It creates a new thread.

It's clear to me that OST does not thread emails based on Ticket # mentioned in the subject line.

In your message, you mentioned about "spoof the message id ". Can you pls elaborate on what is this "message id", which table is it stored in and how to include in the outgoing email. I'm guessing its going to be a part of the email header.

Once I get this message id bit setup correctly, I'll be able to put externally sent emails (copied to OST) in the parent thread.

I hope I've been able to explain it well, if not please let me know & I'll try again ?

Thanks again for your continued support!!

It's been a while since I have confirmed this with a dev but the standard answer for quite some time is:

osTicket checks message-id first and tries to compare it to existing message-ids. Then it checks the reference-id and in-reply-to and foo. Lastly if all else fails it checks the message subject for the ticket [#number] to see if it matches an existing ticket.

@ntozier
I'm still struggling with this issue.
I've tried the following 2 methods.


I used ticket [#number] in the subject line but the incoming email did not get clubbed to the existing thread.
--> subject line---> Re: [#70537706] Testing theading


I extracted the message_id from the ost database using the following query:
select mid from ost_sales.ost_thread_entry_email where thread_entry_id='xxx'
I included this mid in my outgoing email, which is routed back into OSTicket via cron download.
The incoming email did not get clubbed to the existing thread.


I'm not sure where the problem is but I really need to get this working.
Pls point me in the right direction.

Thanks!

Write a Reply...