https://discord.gg/botpress logo
Bot Triggers on Comments Instead of Only DMs + 502...
# šŸ¤help
c
I’m working on a Botpress Cloud bot that uses the Messenger + Instagram integration. My goal is to ensure the bot responds ONLY to Direct Messages (DMs) and completely ignores: • post comments • comment replies • public interactions To avoid impacting my live production bot, I duplicated the bot and enabled Messenger / Facebook integration only on the duplicate for testing. What I Tried: I added this logic inside the Before Incoming Hook to allow only DMs and ignore comments: /** Only allow Direct Messages on Messenger & Instagram */ const isMessenger = event.channel === 'messenger' const isInstagram = event.channel === 'instagram' // Conversation id exists only in DMs const hasConversationId = !!event?.tags?.conversation?.["messenger:id"] || !!event?.tags?.conversation?.["instagram:id"] // Comment / post replies have postId const isFromComment = !!event?.tags?.message?.["messenger:postId"] || !!event?.tags?.message?.["instagram:postId"] // Final DM check const isDirectMessage = (isMessenger || isInstagram) && hasConversationId && !isFromComment // Ignore everything that is NOT a DM if (!isDirectMessage) { console.info('Ignoring non-DM event') return } console.info('Processing DM event') Additional Issue — Testing on Duplicate Bot (502 Error) When I install the Messenger / Facebook / Instagram integration on the duplicated bot and try to configure and test it in Playground, I receive this error: Registration Failed — Request failed with a status code 502 Even after installation completes: • no Messenger or Instagram users appear in Conversations • only Webchat users are created • no DM messages are logged I am intentionally testing on a duplicate bot so that I can safely test without affecting my live bot. My Questions 1. Is duplicating a bot for Messenger / Instagram integration testing the correct approach — or can it cause webhook conflicts with the live bot? 2. Why might I be getting the 502 registration failed error during configuration?
l
Duplicating a bot is allowed, but each bot gets its own unique webhook ID. If you install the same Messenger/Instagram integration on two bots, both will try to register a webhook with Meta that points to different Botpress webhook URLs. Meta only accepts one webhook URL per page/app, so the second registration can fail with a 502 error.
b
Hello nice work ! My goal is to do the same thing. Could you send your bot template (.bpz) please ?
c
I’m working on a live Botpress Cloud bot and I want to fix this issue without breaking the existing flow. What is the safest way to update logic?
6 Views