Modals

Video Tutorial

This video Tutorial goes over how to use modals in inventor.


https://www.youtube.com/watch?v=NpKj9afGzBk


Written Tutorial

This guide will walk you through creating a modal system in Discord with commands and flows. We'll cover how to call a modal, handle its submission, and send data with modals.


Create a Modal

Step 1 - Calling the Modal

Create the Flow

  • Name the flow My Modal.
  • Set the trigger to Slash Command.
  • Name the command modal and sync it.

Step 2 - Add a Modal Reply to Interaction Block

  • Configure the block as follows:
    • Modal Name: Nickname
    • Custom ID: mymodal (remember this ID; it will be used later)
    • Field Label: Nickname
    • Required: True
    • Field Type: Large Field

Your calling flow is now complete. This flow triggers the modal.


Step 3 - Modal Submission Flow

Create the Flow

  • Name the flow My Modal Submission.
  • Set the trigger to Modal Submit.
  • Use the Custom Modal ID from before: mymodal.

Step 4 - Add an Embed Reply to Interaction Block

  • Configure the block as follows:
    • Description:
      • Write: Nickname:
      • Add the variable Modal Field 1 Value from the Modal Submit block.

Now, when the modal is submitted, the bot will respond with an embed containing the entered nickname.


Step 5 - Test the Command

Run the /modal command in Discord. The modal should appear with a field labeled Nickname.

Submit the Modal

  • After submitting, the bot should respond with an embed containing:
    • Nickname: (value you entered)


Sending Data with Modals

This section explains how to pass data dynamically using the modal ID.

Step 1 - Modify the Slash Command Flow

Add a Get Current Date and Time Block before the Modal Reply to Interaction Block. We'll be using the output with the current time in HH:MM:SS format.

Edit the Modal Custom ID input of the Modal Reply to Interaction block.

  • Set it to mymodal- and insert the current time variable, as shown below.

    \

Step 2 - Edit the Modal Submit Flow

  • Change the Modal Custom ID to mymodal-*

  • Add a String Trim Prefix block before the Embed Reply to Interaction block:
    • String: Use the Modal ID from the Modal Submit block
    • Prefix: Set it to mymodal-

  • Update the Embed Reply to Interaction block:
    • Add the current time (from the String Trim Prefix block) to the Footer Text.


Step 3 - Testing the Modal

Test the Command

  • Run the /modal command in Discord.
  • The modal should appear with a field labeled Nickname.

Submit the Modal

  • After submitting, the bot should respond with an embed containing:
    • Nickname: (value you entered)
    • Footer: Shows the time that the modal popped up on screen.

Open the modal, wait 10 seconds, then submit it.

Notice that the time in the message footer will show when the modal first appears on-screen, rather than when it was submitted. This is because we are recording the time of modal creation, storing it in the modal's id, and retrieving it when the modal is submitted.

You can use this simple approach to pass all sorts of data through interactions like modals, dropdowns, buttons, and more.