DOCUMENTATION / COMPONENTS & FORMS

Let the conversation do more.

Build rich messages with buttons, dropdowns, entity selectors and forms.

Buttons and dropdowns

Use unique custom IDs up to 100 characters. Non-link buttons send component interactions; link buttons open an HTTPS URL. The relay: prefix is reserved for platform controls. A select occupies an entire row. User, role and channel selectors resolve options from the current community, and the server verifies the selection.

JavaScript
import { MessageBuilder, ActionRowBuilder, ButtonBuilder,
  StringSelectMenuBuilder } from '@relaychat/sdk';
await bot.messages.send(channelId, new MessageBuilder()
  .setContent('How can we help?')
  .addComponents(new ActionRowBuilder().addComponents(
    new ButtonBuilder().setCustomId('ticket:new')
      .setLabel('Open a ticket').setStyle('primary')
  ), new ActionRowBuilder().addComponents(
    new StringSelectMenuBuilder().setCustomId('help:topic')
      .addOptions({ label: 'Account help', value: 'account' },
                  { label: 'Community help', value: 'community' })
  )));

Collect a little more detail

Forms support one to five text inputs. Required fields and length bounds are checked by the server. Forms expire with their parent interaction and can be submitted only once by the member who opened them.

JavaScript
import { ModalBuilder, TextInputBuilder } from '@relaychat/sdk';
await interaction.showModal(new ModalBuilder()
  .setCustomId('ticket:details').setTitle('Tell us more')
  .addInputs(new TextInputBuilder().setCustomId('details')
    .setLabel('What happened?').setStyle('paragraph')
    .setRequired(true).setMaxLength(1500)));
// Handle a new modal interaction:
// interaction.fields.details

Embeds and attachments

EmbedBuilder supports titles, descriptions, colors, fields, images, thumbnails, footers and timestamps. Upload attachments through bot.uploadFile(channelId, blob, name), then include the returned { id } in attachments. Download links are short-lived and created only after checking the member’s current channel access.

Messages render text as text; a bot cannot inject HTML into Relay. External image and link URLs must use HTTPS. Keep third-party image privacy in mind when choosing where your bot hosts images.