Customer notification email when ticket is reassigned to another agent — Frappe Helpdesk

Hi,

I am using Frappe Helpdesk on a private bench. I have the following requirement:

When Agent 1 reassigns a ticket to Agent 2, the customer should
automatically receive an email notification like:

“Your ticket #TICKET-001 has been assigned to James.
They will get back to you shortly.”

What I have tried:

  1. Notification on ToDo doctype (New event) — but unable to
    fetch customer email dynamically from HD Ticket
  2. Server Script on HD Ticket Before Save — but unsure if
    this works on Helpdesk portal context

Questions:

  • Is there a standard way to handle this in Frappe Helpdesk?
  • Does Server Script on HD Ticket fire when assignment
    changes from Helpdesk agent view?
  • Is there a hook or override available for this in
    Helpdesk app itself?

Frappe Version: 16
Helpdesk Version: 1.22.2

Thanks

Easiest fix is a Server Script:

  • Script Type: DocType Event
  • Reference Document Type: ToDo
  • Doctype Event: After Insert
if doc.reference_type == "HD Ticket" and frappe.db.exists("HD Agent", doc.allocated_to):
    ticket = frappe.get_doc("HD Ticket", doc.reference_name)
    if ticket.raised_by:
        agent = frappe.db.get_value("HD Agent", doc.allocated_to, "agent_name")
        frappe.sendmail(
            recipients=[ticket.raised_by],
            subject=f"Your ticket #{ticket.name} has been assigned",
            message=f"Your ticket #{ticket.name} has been assigned to {agent}. They will get back to you shortly.",
            reference_doctype="HD Ticket",
            reference_name=ticket.name,
        )

This fires no matter where the assignment happens, agent desk, portal, or the API, because they all go through the same ToDo.

Note: I did not test the code so no guarantee that it works out of the box