Setting up a Webhook to make any change to a ticket (advanced)

Sometimes Zendesk triggers & automations don't provide all the automated actions you need to perform your required workflows on a ticket.

Examples of actions that triggers & automations do not have actions for are: 

  • Adding specific CCs to a ticket.
  • Automatically applying public/internal comments to a ticket.
  • Changing the subject line of a ticket
  • Setting the contents of the following types of ticket fields: 
    • text fields
    • multiline text fields
    • numeric fields
    • regex fields

When you run into one of these circumstances (or others) there is a workaround that allows you to still make the changes you want. This is to:

Step 1: Setup a Webhook.

Step 2: In a Zendesk trigger/automation send the ticket changes to the target. 

Step 3: (Important!) Ensure that your trigger has a nullifying condition. 

 


 

STEP 1: Setup the Webhook

Note:

There are two different webhooks in this step. For most uses cases, the first webhook "Update the ticket" will be enough, however, it's never a bad idea to have both at your disposal.

a) Update the ticket

This particular webhook will update the current ticket when the trigger activates. If you wish to update a different or multiple tickets, please refer to the second webhook.

The first step is to setup a Webhook. To do this first navigate to the Admin Center, then select the Apps and Integrations icon, then select Webhooks and finally click on "Create Webhook" at the bottom of the page.

mceclip0.pngmceclip1.png

Next, use the following details to configure the webhook:

Name: Update ticket

Endpoint URL: https://yourhelpdesk.zendesk.com/api/v2/tickets/{{ticket.id}}.json

Don't forget to replace "yourhelpdesk" with the name of your Zendesk domain.

Request method: PUT

Request format: JSON

Authentication: Basic authentication

You will need to enter your credentials for the authentication.

 

Note: If you're using SSO on your desk, you will not be able to use your regular username and password. Instead, you will need to enter your username with /token at the end like this: peter@sweethawk.co/token and for the password, you will need to generate an API token - see here for more.

 

It should look like this when you're done: 

mceclip2.png

Once you're happy to go ahead and create the Webhook.

 

b) Update many tickets

If you need to create a webhook that updates one or more tickets that is not the current ticket, we will need to specify the ticket ID in the JSON rather than in the endpoint URL of the webhook.

Create the webhook just like you did in the previous section, except this time use the following details:

Name: Update many

Endpoint URL: https://yourhelpdesk.zendesk.com/api/v2/tickets/update_many.json

Request method: PUT

Request format: JSON

Authentication: Basic authentication

Note that the ticket.id placeholder is no longer present in the endpoint URL. This will come later when we send the ticket changes to the webhook.

 


 

STEP 2: In a Zendesk trigger/automation send the ticket changes to the Webhook.

To create the trigger that will automatically make the changes you want, click on the cog on the left of the screen, then click on triggers, finally click on 'add trigger' at the top right-hand side like this: 

Admin > Business Rules > Triggers > Add Trigger

mceclip3.png

Under "Meet all of the following conditions" you can put in whatever rules are required for the workflow you're trying to achieve. 

Under "Perform these actions" add the rules:

# "Notifications: Notify active webhook" - "Update ticket" 

In the JSON body add the code that you want. Below are a few examples of things that you can do. For more information on setting things on a ticket using the Zendesk API see this article

 

Make a public comment: 

{
"ticket": {
"comment": {
"body": "This a public ticket update regarding ticket {{ticket.id}}.",
"public": true
}
}
}


Make a private comment: 

{
"ticket": {
"comment": {
"body": "This a private ticket update regarding ticket {{ticket.id}}.",
"public": false
}
}
}


Change the subject line: 

{
"ticket": {
"subject": {"My printer is on fire"}
}
}


Adding CCs: 

This has its own knowledge base article here

Setting custom ticket fields:

{
"ticket": {
"custom_fields": [{"id": 45844587, "value":"09:00"},{"id": 45844607, "value":"Melbourne"},{"id": 45844547, "value":"Support (1022)"},{"id": 45844627, "value":"60"}]
}
}

Update one or more tickets:

Note:

The following JSON body will only work with the second webhook.

{
"tickets": [
{
"id": "1234",
"status": "open",
"comment": {
"body": "This a public ticket update regarding ticket {{ticket.id}}.",
"public": true
}
{
"id": "{{ticket.ticket_field_360026333132}}",
"status": "open",
"comment": {
"body": "This a private ticket update regarding ticket {{ticket.id}}.",
"public": false
}
}
]
}

 


 

Step 3: Adding a nullifying condition. (Important!

It is very important that you add a nullifying condition to your trigger for these types with Webhooks.

Since the trigger is causing the ticket to update its self, the consequence of it not being nullified means that the ticket will update its self hundreds (if not thousands) of times a minute until the trigger is manually disabled. For more information, see this article on how to setup nullifying conditions


Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.