Skip to content

Interaction Examples

Javier Colombera edited this page Aug 14, 2023 · 4 revisions

Creating Slash Commands

Pre-settings: You have to set this flow variables in order to use it

const clientId = flow.get("clientId");
const guildId = flow.get("guildId");
const token = flow.get("botToken");

Flow example

Creating components

Adding components to a message creates a interaction between someone and the bot. All the components are created inside a Row Component.

  • Button component
[
    {
        "type": 1,
        "components": [
            {
                "type": 2,
                "label": "Option 1",
                "style": 3,
                "custom_id": "click_opt1"
            },
            {
                "type": 2,
                "label": "Option 2",
                "style": 4,
                "custom_id": "click_opt2"
            }
        ]
    }
]
  • Flow adding components

Flow example

Responding to button and select menu

Flow example

Responding to commands

Flow example

Responding to commands with ephemeral response

In this example, the node replies the command with ephemeral flag and then edits it.

Flow example

Responding to autocomplete

let newMessage = {};
newMessage.action = "respondAutocomplete";
newMessage.autoCompleteChoices = ["Juan", "Javier", "Hernan"];
newMessage.interactionId = msg.payload.id;
return newMessage;

Flow example