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 and a specified time frame.

This workflow implements organizational fields to monitor the volume of tickets submitted within a designated time frame which allows 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
  4. Click the Save dropdown arrow and select Save and add another
  5. Under Select field type, select Number
  6. Under Display name, enter Counter Last Update Unix and click 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. Under Select a way to connect, select Trigger or automation and click Next
  3. Use the below 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
  4. Create the second Trigger or automation webhook and click Next
  5. Use the below 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

Create triggers that verify the requester's ticket count, update the organization fields, and add tags to the ticket.

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:
    • Other > 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:
    • Other > 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:
    • Other > 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. Actions add:
    • Ticket > Status category > Closed
    • Other > Notify by > User email | Ticket > (requester)

      Note: It's optional to notify the user to improve the user experience.
  4. Click Create trigger

This summary outlines the workflow when users submit a new ticket.

  1. Ticket creation:
    • When a ticket is created, the workflow updates the ticket counter and timestamp organization fields.
  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. User notification 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