How do you configure automated ticketing on helpdesk for each department

I want to configure tickets to be assigned to different users based on department. These are based on the email address the someone sends to. Each department will have a unique email account. How can I do that?

You can user servec script to say something like

if doc.category == “x”:
doc.agent_group = “sales”