Adding Interactive Buttons to Messages from Discord Bot Webhooks

I’m working with a Discord bot and have a webhook that sends messages to a channel whenever someone submits a Google form. I want to automatically add some interactive buttons (like “Approved” and “Rejected”) whenever this webhook message appears.

Right now I’m just trying to get the buttons to show up at all. I’m not worried about handling the button clicks yet, just getting them to appear under the webhook message.

Here’s what I’ve tried but it’s not working:

client.on('messageCreate', (msg) => {
    if(msg.author.bot) {
        const approveBtn = new ButtonBuilder()
            .setLabel('Approved')
            .setStyle(ButtonStyle.Success)
            .setCustomId('approve_btn');

        const rejectBtn = new ButtonBuilder()
            .setLabel('Rejected')
            .setStyle(ButtonStyle.Secondary)
            .setCustomId('reject_btn');

        const actionRow = new ActionRowBuilder().addComponents(approveBtn, rejectBtn);
        msg.reply({content: 'Choose an option:', components: [actionRow]});
    }
});

The buttons aren’t showing up when the webhook posts. What am I missing here?

Webhook messages don’t act like regular bot messages in messageCreate events. Sure, msg.author.bot returns true, but webhooks have different properties that mess with adding components. I ran into this same issue last month - checking for msg.webhookId works way better than just checking if it’s a bot. Try if(msg.webhookId && msg.content.includes('some unique text from your form')) to target only your Google form webhook. Double-check you’re importing ActionRowBuilder correctly too - I forgot that initially and got silent failures. The reply method works fine once you properly identify webhook messages.

This is a webhook component issue - I ran into the same thing a few months ago. Webhooks can be finicky with the reply method when you’re adding components. Skip msg.reply() and use channel.send() instead to create a fresh message.

Check your bot’s permissions too - you need ‘Use Application Commands’ and ‘Send Messages’ for that channel. Also double-check your ActionRowBuilder import. Depending on your discord.js version, the components array might need explicit type definitions.

Your webhook detection looks fine, but throw in some console logs to make sure the event’s actually firing when the webhook posts.

webhooks dont actually trigger messageCreate events. u might wanna use messageReactionAdd or create another endpoint to directly handle the webhook data. then just send the message with buttons from there instead of waiting for it to trigger.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.