> For the complete documentation index, see [llms.txt](https://docs.discordbotstudio.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.discordbotstudio.org/misc/buttons-and-selects/determining-which-button-was-clicked.md).

# Determining which button was clicked

## How buttons work

It's possible to have multiple buttons per row, and multiple rows per message. The rule is that there can be one select, or five buttons per row, and up to five rows per message. This is covered in the video here:&#x20;

{% content-ref url="/pages/-MjjqzsQa3E62ckSa6uQ" %}
[Buttons and Selects](/misc/buttons-and-selects.md)
{% endcontent-ref %}

## Figuring out which button was clicked

The basic timeline for when a button is clicked is as follows:&#x20;

1. The button is added to the message when the bot creates the message
2. A user sees the message and potentially clicks one or more buttons
3. The **ButtonInteraction** event is fired
4. Any responses you have connected to the event node will be executed

### Custom ID

When you add a button to a message you will be asked to enter a **Custom ID.** This ID is how we will determine which button was clicked. For this reason, the Custom ID should be unique for each button. Make a note of what the custom ID is for each button you have, as we'll need it later.

### Check the ID

To determine which button was clicked we will use a **Switch Case** node. This node lets us check the value of a variable against multiple values. We'll connect it to the **Button Interaction** event so we can check the value of the **customId** field of the interaction event.

![](/files/okmUbT5nRK51SsrJ0lJa)![](/files/UlEnhKUu4VrgFWxUd9Cq)

We can double click on the switch case node to open it. In this case we are checking the value of the **buttoninteraction.customId** to see which button was clicked.&#x20;

![](/files/bIv3DcvTe2MCsZiiB9We)

In this example I am checking for two possible values- **custom\_id\_1** and **custom\_id\_btn2**. This correlates to two buttons I have with those as their custom IDs. If the button which I set the custom ID to **custom**\_**id\_btn2** is clicked then the responses connected to that output will be executed.

![](/files/5kMVseVKEJKsGAmIUdpI)

It's possible to have an unlimited number of buttons and have the switch case node check for an unlimited number of values. Any responses can be connected to each output, allowing you to&#x20;
