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
- Create a custom organization field
- Under Select field type, select Number
- Under Display name, enter
Counter
and select Save and add another
- Under Select field type, select Number
- 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
- Create the first webhook
- Use the following configuration
- Name: Update org
-
Endpoint URL:
https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.organization.id}}
and replaceyoursubdomain
with your account subdomain. - Request method: PUT
- Authentication: Basic Authentication
- Create the second webhook
- Use the following configuration
- Name: Update ticket tags
-
Endpoint URL:
https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}/tags
and replaceyoursubdomain
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
- 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:
-
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:
-
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 %}"
]
}
-
Notify by > Active webhook > Update ticket tags and in the JSON body, add the information below:
- 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:
-
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
-
Notify by > Active webhook > Update org and in the JSON body, add the information below:
- 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
-
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.
-
Ticket > Status category > Closed
- Click Create trigger
This summary outlines the workflow for users submitting a new ticket.
- Ticket creation:
- Whenever a ticket is created, the organization fields are updated by incrementing the ticket counter and saving the timestamp of this update
- 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 (notifying the user is optional)