Tip: Use Webhooks and triggers to add CCs to a ticket | Community
Skip to main content

Tip: Use Webhooks and triggers to add CCs to a ticket

  • May 10, 2022
  • 7 replies
  • 0 views

Matthias11

We figured out a way to add CCs to a ticket based on conditions defined in a trigger. First, you need to set up a webhook with the endpoint

https://<company-name>.zendesk.com/api/v2/tickets/{{ticket.id}}.json

as JSON/PUT request.

Then, you can define a trigger with your conditions that calls the webhook ("Update active webhook") and sends the following JSON data:

{
  "ticket": {
    "email_ccs": [
    { "user_id": "123456789", "action": "put" },
    { "user_id": "987654321", "action": "put" }
  ]
  }
}

You can use the Zendesk API to query the appropriate user IDs.

You may also configure another webhook to put a comment into the ticket notifying your agents about the change:

{
  "ticket": {
    "comment": {
    "body": "new CCs added",
      "public": false
    }
  }
}

Please note that the trigger should probably not act on "Ticket is updated" because that might cause an infinite loop with the new comment that also updates the ticket.

Cheers,
Matthias

7 replies

Dave12
  • May 10, 2022
Thanks for sharing this, Matthias – I do have to caution that using a trigger and webhook to update the same ticket that the trigger is operating on can lead to race conditions that could occasionally prevent the ticket from being updated. See Can I use a trigger and a webhook to update tickets?

Matthias11
  • Author
  • May 12, 2022

Thanks, Dave!

Please, feel free to suggest a better solution to update CCs on a ticket based on some condition. I don't exactly like my solution - it just appeared to be the only feasible way to implement this because CCs do not appear in the trigger options. I am happy to use a different approach.

Cheers,
Matthias


Christopher26

Matthias,

Many thanks for sharing this - this has been an absolute lifesaver for me and one of our biggest clients!

Thanks,
Chris


  • January 16, 2024

Is there a way to utilize JSON if/then to dynamically add cc email addresses?  I have a drop down field that specifies the location the ticket belongs to, and previously used dynamic content to pair it with the appropriate emails for that location.  Can the location be extracted in JSON, and then used to validate emails to be cc'd?


Jimmy11
  • February 27, 2024

Hi @matthias11,

I tried this solution in my ZD sandbox, but could not get the CCs to be added to the ticket.

Can I confirm that the user IDs to put in the JSON would be the same ID I can find in the UI for each user like below (in bold)?  If so, the trigger ran and incorporated tags I needed, but didn't CC anyone.

https:/<companyname>.zendesk.com/agent/users/123456789/requested_tickets


Matthias11
  • Author
  • February 27, 2024

Sorry, @jimmy11, you might want to reach out to Zendesk Support for help with that. It works just fine on our side. And yes, the user ID is the one that is also shown in the URL when looking at the user's tickets.


Elaine14
  • February 27, 2024
Hi Jimmy,
 
I'm wondering if this leads to race conditions as mentioned by Dave in this article: Can I use a trigger and a webhook to update tickets?
Feel free to contact our Zendesk Support team for assistance.