Workflow: How to restrict the number of tickets a user can submit within an organization

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

This workflow uses custom organization fields to monitor the volume of tickets submitted within a designated time frame. 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:

Create a custom organization field

Under Select field type, select Number

Under Display name, enter Counter

Click the Save dropdown arrow and select Save and add another

Under Select field type, select Number

Under Display name, enter Counter Last Update Unix and click Save

Step 2: Create the webhooks

Create webhooks for the triggers to update the requester's organization and ticket tags.

To create the webhooks:

Create the first webhook

Under Select a way to connect, select Trigger or automation and click Next

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

Create the second Trigger or automation webhook and click Next

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 webhooks 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:

Create a new trigger

Under Meet ALL of the following conditions, add Ticket > Ticket | Is | Created

Under Meet ANY of the following conditions, add:

Organization > Counter | Less than | 5

Organization > Counter | Not present

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' }}"
}
}
}

Click Create trigger

To create the second trigger:

Create a new trigger

Under Meet ALL of the following conditions, add:

Ticket > Ticket | Is | Created

Organization > Counter | Is | 5

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 %}"
]
}

Click Create trigger

To create the third trigger:

Create a new trigger

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

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

Click Create trigger

To create the fourth trigger:

Create a new trigger

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

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.

Click Create trigger

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

Ticket creation:

When a ticket is created, the workflow updates the ticket counter and timestamp organization fields.

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

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.