Overview

In Zendesk, you can't limit the number of tickets that users submit in your account. However, you can create a custom workflow that establishes a system to restrict the number of tickets submitted by users within an organization during a specified time frame.

In this workflow you will find the steps to implement organizational fields to monitor the volume of tickets submitted within the designated time frame, allowing for adjustments as necessary.

The workflow includes the steps below.

  • Step 1: Create the numeric organization fields
  • Step 2: Create the webhooks
  • Step 3: Create the triggers

Step 1: Create the numeric organization fields

This workflow uses two custom numeric organization fields to monitor and record the number of tickets submitted by the user.

To create the custom organization fields

  1. Create a custom organization field
  2. Under Select field type, select Number
  3. Under Display name, enter Counter and select Save and add another
  4. Under Select field type, select Number
  5. Under Display name, enter Counter Last Update Unix and select Save

Step 2: Create the webhooks

This workflow uses webhooks in the triggers to update the requester's organization and ticket tags.

To create the webhooks

  1. Create the first webhook
  2. Use the following configuration 
    • Name: Update org
    • Endpoint URL: https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.organization.id}} and replace yoursubdomain with your account subdomain.
    • Request method: PUT
    • Authentication: Basic Authentication
  3. Create the second webhook
  4. Use the following configuration 
    • Name: Update ticket tags
    • Endpoint URL: https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}/tags and replace yoursubdomain with your account subdomain.
    • Request method: PUT
    • Authentication: Basic Authentication

The webhook should appear similar to the below image.

Step 3: Create the triggers

This workflow uses triggers to verify the current ticket count for the requester and updates the corresponding organization fields and ticket tags accordingly.

To create the first trigger

  1. Create a new trigger
  2. Under Meet ALL of the following conditions, add:
    • Ticket > Ticket | Is | Created
  3. Under Meet ANY of the following conditions, add:
    • Organization > Counter | Less than | 5
    • Organization > Counter | Not present

  4. Under Actions, add:
    • Notify by > Active webhook > Update org and in the JSON body, add the JSON information below:

      {
      "organization": {
      "organization_fields": {
      "counter": "{{ ticket.organization.custom_fields.counter | plus:'1' }}",
      "counter_last_updated_epoch": "{{ 'now' | date: '%s' }}"
      }
      }
      }
  5. Click Create trigger

To create the second trigger

  1. Create a new trigger
  2. Under Meet ALL of the following conditions, add:
    • Ticket > Ticket | Is | Created
    • Organization > Counter | Is | 5

  3. Under Actions add:
    • Notify by > Active webhook > Update ticket tags and in the JSON body, add the information below:
      {% assign nowDateSec = "now" | date: "%s" | minus: 0 %}
      {% assign modDateSec = ticket.organization.custom_fields.counter_last_updated_epoch | date: "%s" | minus: 0 %}
      {% assign result = nowDateSec | minus: modDateSec %}
      {
      "tags": [
      "{% if result < 3600 %}last_ticket_within_1_hour{% else %}last_update_over_1_hour_ago{% endif %}"
      ]
      }
  4. Click Create trigger

To create the third trigger

  1. Create a new trigger
  2. Under Meet ALL of the following conditions, add:
    • Ticket > Ticket | Is | Updated
    • Ticket > Tags > Contains at least one of the following | last_update_over_1_hour_ago
  3. Under Actions add:
    • Notify by > Active webhook > Update org and in the JSON body, add the information below:
      {
      "organization": {
      "organization_fields": {
      "counter": 1,
      "counter_last_updated_epoch": "{{ 'now' | date: '%s' }}"
      }
      }
      }
    • Ticket > Add tags | last_update_over_1_hour_ago
  4. Click Create trigger

To create the fourth trigger

  1. Create a new trigger
  2. Under Meet ALL of the following conditions, add:
    • Ticket > Ticket | Is | Updated
    • Ticket > Tags > Contains at least one of the following | last_ticket_within_1_hour
    • Organization > Counter | Is | 5
  3. Under Actions add:
    • Ticket > Status category > Closed
    • Other > Notify by User email | Ticket > (requester)

      Note: Notifying the user is optional but improves the user experience.
  4. Click Create trigger

This summary outlines the workflow for users submitting a new ticket.

  1. Ticket creation:
    • Whenever a ticket is created, the organization fields are updated by incrementing the ticket counter and saving the timestamp of this update
  2. Counter evaluation:
    • If the counter is below the maximum allowed limit, the ticket proceeds through the normal submission process
    • If the counter reaches its maximum allowed limit, the system checks the last update time to determine if it was submitted within the defined time frame
  3. Time frame check:
    • If the last update falls outside the specified time frame, the system resets the counter to 1. A new timestamp records the change
    • If the last update is within the time frame, the system will not update the counter or save a new timestamp, and it will close the ticket immediately (notifying the user is optional)
Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online.
Powered by Zendesk