Set up Discord

Discord uses one bot token for Gateway triggers, messages, approvals, and lifecycle notifications. The application's Public Key is not the bot token.

Create and install the Discord bot

  1. Open the Discord Developer Portal, select New Application, and name it.
  2. Open the application's Bot page. Generate or reset the token, copy it, and store it immediately. Discord may show it only once.
  3. On the same page, enable the privileged Message Content Intent. WOML needs it to read message text.
  4. Open Installation and enable a Guild Install with the bot scope.
  5. Grant the bot View Channels, Send Messages, and Read Message History.
  6. Copy the installation link, open it, select a test server, and authorize the app.

WOML does not require slash commands, so applications.commands is not needed for the v1 message trigger.

Find a channel ID

  1. In Discord, open User Settings → Advanced.
  2. Enable Developer Mode.
  3. Right-click the channel and select Copy Channel ID.

Keep the 17–20 digit value for diagnostics, channel filtering, and notifications.

Store and verify the token

Terminal
woml secrets set DISCORD_BOT_TOKEN
woml discord doctor --destination <channelId>

This verifies both bot authentication and delivery access to the selected channel.

Test a Discord trigger and reply

Save this as discord-test.woml:

WOML
<woml>
  <workflow
    id="discord-test"
    name="Discord Test"
    description="Replies when the bot is mentioned or receives a direct message."
    version="1.0.0"
  >
    <triggers>
      <discord
        id="messageReceived"
        events="app-mention,direct-message"
        channels="<channelId>"
        bot-token="{{secrets.DISCORD_BOT_TOKEN}}"
      />
    </triggers>

    <steps>
      <step id="reply" name="Reply in Discord">
        <script>
          return services.discord.send({
            botToken: secrets.DISCORD_BOT_TOKEN,
            conversationId: context.payload.conversationId,
            replyToMessageId: context.payload.messageId,
            text: `WOML received: ${context.payload.text}`
          }, { name: "discord-test-reply" });
        </script>
      </step>
    </steps>
  </workflow>
</woml>

Replace both <channelId> placeholders, then run:

Terminal
woml check discord-test.woml
woml run discord-test.woml

Mention the bot in the configured server channel and send hello, or send it a direct message. WOML should accept the Gateway event and reply in the same conversation.

Use the same channel ID for an approval notification:

WOML
<approval id="review" timeout="24h" on-timeout="reject">
  <notify>
    <discord
      channels="<channelId>"
      bot-token="{{secrets.DISCORD_BOT_TOKEN}}"
    />
  </notify>
  <when-approved />
  <when-rejected />
</approval>

Diagnose Discord setup failures

  • Authentication fails: store the bot token from the Bot page, not the Public Key, Application ID, or Client Secret.
  • The bot is online but message text is empty: enable Message Content Intent, then restart WOML.
  • Mentions do not arrive: confirm the bot is installed in the server and can view that channel.
  • Replies or notifications fail: grant Send Messages and Read Message History, and verify the channel using woml discord doctor --destination.
  • Direct messages do not arrive: confirm the user and server privacy settings allow DMs to the bot.
  • Events duplicate or reconnect repeatedly: make sure only the intended WOML runtime is using that workflow and token.