Have you ever wondered how you could copy/update data from one part of Zendesk into a custom field on a Zendesk ticket? Enter stage right, the webhook solution!
In this example, we are wanting to copy the Ticket ID into a custom field and place "CHG00" as a prefix so that it represents a Change ticket reference.
To give you an idea of how it works, the trigger will fire off on a ticket when it meets all of the relevant conditions. The action of the trigger will then ask the webhook to send an API call behind the scenes back to the Zendesk and paste the desired data into the ticket field.
Using a webhook and trigger in combination to create this solution allows you to effectively copy the required data into a custom text field without any major API development work.
Follow our steps below to set up your own trigger/webhook workflow. Our example is based on the following workflow:
- Copy the ticket ID into a custom field called SN Change field ID
Before you begin:
- You can use any Zendesk placeholder
- Obtain your API token - Follow the steps here to Generate a new API Token in your Zendesk account
Creating the webhook:
- In Admin Center, click the Apps and integrations icon (
) in the sidebar, then select Webhooks > Webhooks.
- Click Actions and select Create webhook.
- Set up your webhook with the below:
- Example of the endpoint URL: https://{SUBDOMAIN}.zendesk.com/api/v2/tickets/{{ticket.id}}.json
- Authentication: You can choose to use the authentication method which suits your security needs best.
For the authentication, make sure you add the "/token" to the end of your email address in the username field and add the API token as the password.
Creating the trigger:
- In Admin Center, click the Objects and rules icon (
) in the sidebar, then select Business rules > Triggers.
- Click Add trigger.
- Create the trigger conditions. For example, you may want to have the custom field updated on certain tickets only:
- Ticket | Is | Updated
AND
- Tags | Contains none of the following | "sn_change_id_field_update"
- Ticket | Is | Updated
- Next, configure the trigger to perform the following action:
- Notify Active Webhook | Copy ticket ID to SN Change ID field
Note: This establishes that all tickets that meet the above conditions will fire off the webhook and instruct the API to update the ticket field accordingly.
- Notify Active Webhook | Copy ticket ID to SN Change ID field
- Now add the JSON code into the JSON Body field:
- JSON body example:
-
{
You will need to replace the following with your own versions:
"ticket": {
"custom_fields": [{"id": 360019230415, "value":"CHG00{{ticket.id}}"}]
}
}- id = the custom field ID number
- value = your text plus placeholder for the item of data
-
- JSON body example:
- Add Tag | "sn_change_id_field_update"
Limitations:
- This workflow has only been tested with custom text fields
Note: Please use this workflow at your own risk, Zendesk does not provide support for custom workflows of this nature.