# Ticket Limits

This subpage consists of followup steps to [Apm Ticket System](/botwiz-guides/botwiz-guides-1/apm-guides/apm-ticket-system.md). Make sure to complete that guide **first**.

## Set x Tickets per User

### Ticket Count

For this, you will need to create a new custom variable to track how many tickets a user has.

<figure><img src="/files/HCsjvdS6ulbxp7yUQPjY" alt=""><figcaption></figcaption></figure>

When creating a new custom variable, since this will be to track a user's number of tickets, you will need to make this a user variable. This means, the value will be different for each user.&#x20;

Also, in this example, we will set the Sub-Type to 'Number', as we'll use this to count how many tickets the user has open.

<figure><img src="/files/4vPh23wiY6Phtm7IYwr3" alt=""><figcaption></figcaption></figure>

To add to a user's ticket count each time they open a ticket, head to your 'Create a Channel' block, and place a 'Calculate Variable' block afterwards.

<figure><img src="/files/BmIPEEXINCMzTOJwKgFa" alt=""><figcaption></figcaption></figure>

Then feel free to set the 'Calculate Variable' block to the following settings:

<figure><img src="/files/e7p886K6eF2iSKWA44sw" alt=""><figcaption></figcaption></figure>

Once a ticket has been closed, you must remove `1` from the user's ticket counter. Otherwise, their counter will be inaccurate. In order to do this, place a 'Calculate Variable' block after your 'Close Ticket' button.

<figure><img src="/files/modmmBTw8CVXgAIydzMs" alt=""><figcaption></figcaption></figure>

Since we will need to edit the variable of the ticket opener, and not the interacting user, we must have a unique variable to store the ticket opener's ID.

{% hint style="info" %}
If you have not previously set up a unique variable called `{unique_ticket_opener}`, visit [Apm Ticket System](/botwiz-guides/botwiz-guides-1/apm-guides/apm-ticket-system.md#getting-the-ticket-openers-id). Follow those steps, then come back here to continue.
{% endhint %}

Set your 'Calculate Variable' block to the following settings:

<figure><img src="/files/XNLMNWRu4ZN8yVSDW403" alt=""><figcaption></figcaption></figure>

Now, your ticket counter is complete! Each time a user opens a ticket, their counter will `+1`. If their ticket is closed, their counter will `-1`.

### Count Check

To check if a user has x tickets, place a 'Comparison Condition' block before your 'Create Channel' block. This condition will check how many tickets a user has open.&#x20;

In this guide, I'll limit a user's open tickets to 3. If they are trying to open another ticket, despite having 3 open, they will be denied.

To start, set your comparison block's general Comparison Value to `{unique_user_tickets}`.

After, create a condition. In this condition, enter your ticket limit number - for example, I am limiting the number of tickets users can have at 3.

&#x20;![](/files/KtEwnkWLUdGlmbIWwJOt)![](/files/roCSCMKd0iKn46WiTlrb)

In this condition, you can add a message that notifies the user that they are at the ticket limit.

<figure><img src="/files/EGY3q6rer1BH0tzAxqD7" alt=""><figcaption></figcaption></figure>

### Adding a Bypass

If you'd like to add any 'bypass' roles, or users, you will need to use another condition. These users will be able to avoid any ticket limit, and open as many tickets as they'd like.

See the following image for an example.

<figure><img src="/files/ENFar2w4umGC3NEL1w7G" alt=""><figcaption></figcaption></figure>

## Set x ads per Ticket

To have this work properly, you **must** have the server ad the apm sends go through the bot.

{% hint style="info" %}
If you did not follow [Apm Ticket System](/botwiz-guides/botwiz-guides-1/apm-guides/apm-ticket-system.md#using-a-modal), please revert back and introduce those steps.
{% endhint %}

There are multiple ways of setting a limit of ads per ticket. For example, you can disable the 'Click to Continue' button, that allows a user to send their ad through the modal, or by using a unique variable to count each ad sent.

When using the ad counter method, you can add additional checks such as to check for a bypass role. In this case, you can remove the ad limit for those with a bypass role.&#x20;

When disabling a button, making checks such as for a bypass role is a bit more difficult, as you'll need multiple button blocks per condition you make. Therefore, if you wish to have a condition such as to check for a bypass role, you should use an ad counter.

{% tabs %}
{% tab title="Disabling the Button" %}
Visit your button block that allows users to add multiple ads. In this example, this will be the 'Click 2 Continue' block, as it connects to the modal which asks for the apm's server ad(s).

<figure><img src="/files/Pf7vmMwviM9XkNEh4GbH" alt=""><figcaption></figcaption></figure>

Select the block, and visit the Buttons tab. Select your version of the 'Click 2 Continue' button, and select the button to 'Disable After x Amount of Uses'. In your 'Button Uses' textbox, enter the limit of ads you'd wish to have per ticket, such as 1 ad per ticket.

<figure><img src="/files/Uy7IgDt0MhFo6ChL29BE" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Using an Ad Counter" %}
Similarly to [#set-x-tickets-per-user](#set-x-tickets-per-user "mention"), we will need to create a unique variable that will count the amount of ads a user sends in a ticket. Since this limit will be per ticket, the unique variable will have the 'Channel' type. This means that with each channel, or ticket in this case, will have their own count.

To create a new unique variable, visit the following tab and click 'Add'.

<figure><img src="/files/Uy0clw8nsKsRD2EE6Equ" alt=""><figcaption></figcaption></figure>

You will then need to set your unique variable's settings to the following:

<figure><img src="/files/bEpdIxbdvxi6VT2LGs0W" alt=""><figcaption></figcaption></figure>

Next, we must add `1` to this ad counter each time an ad is sent. Start by placing a 'Calculate Variable' block after your Modal block.

<figure><img src="/files/jCZlDsZJbjrmgdX1T2Nn" alt=""><figcaption></figcaption></figure>

Now you counter is fully functional! All we need now is to add a 'Comparison Condition' block to check for the amount of ads a user has already sent. See the image below.

<figure><img src="/files/AbZDDudGVVi3ssji5A8s" alt=""><figcaption></figcaption></figure>

In the Comparison Condition block, add the following settings:

&#x20;![](/files/SOGrKyBY9CB35akWfibA)![](/files/tXQlPGUH4s3Z0pCDdXj4)

Feel free to add additional blocks, such as a message letting the user know when they have reached the ad limit.

<figure><img src="/files/8CNBwmpI6heO6az7BfYJ" alt=""><figcaption></figcaption></figure>

To consider a bypass role, and remove any limit for those with a role, add a 'Role Condition' block after your condition. In this example, an ad limit will be removed for any users with the bypass role. See the following for a guide.

<figure><img src="/files/Isn1dhQv2OASLN5RhXbl" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.botwiz.dev/botwiz-guides/botwiz-guides-1/apm-guides/apm-ticket-system/ticket-limits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
