We have 4-5 Products, all of which have the same URL structure, /product/:id
Based on the ID we fetch the product, and only after this we know the product type.
I want to engage different custom bots based on the product type.
To do this I call
product_type: "my product type"
On my custom bots, I use the custom attribute product_type in the rules to decide which bot should execute.
This however seems to only work intermittently and sometimes a stale bot is used instead of the latest one called with product_type (Assuming this to be due to delay in user attribute being updated and syncing with the client).
Is there a better way to do this which guarantees that correct bot will be used for the chat?
Best answer by OseasView original
@kartikey chauhan! Oséas here from the Support Engineering team 🕵️
I can’t say for sure why your current solution is not working consistently as I would need to investigate a few examples where this has happened to confirm if there’s indeed a delay blocking your bots. However, a more robust solution would be using event triggers instead of custom attributes (e.g. product_type) to trigger these bots.
For this, you would need to create a logic on your end to fetch the ID, associate it with the product type and then trigger an event in Intercom using the method Intercom('trackEvent', 'event-name'); from our JS API. Once you have this set, you will need to edit your bot’s rule to trigger every time this event happens. You can find more information on how to use event trigger based messages here.
Hope that helps!
Thanks for the reply.
We are unable to use event trigger based messages for our use case. We want to select the custom bot once we know the product_type, but only open the chat window if the user clicks on the intercom icon.
So effectively we want.
1. product_type fetched/computed.
2. Intercom custom bot selected programmatically based on product_type.
3. Use the custom bot if the user/lead clicks on the intercom icon.
The issue with using data attributes was product_type persistence on the user even on other pages.
So what we are effectively looking for is short lived conversation state which decides what custom bot should be used.
One hacky workaround I can think of to achieve this behavior is by overlaying the intercom icon with a div and have custom bots based on “When a customer clicks on a website element”.
I can then set css classes on custom div programmatically, use these in the custom bot rules, and have different different bots are invoked based on current context.
Is there anything better that I can do, or am I missing something?
@kartikey chauhan, I’m not sure if this workaround would do the tricky as I never tested it myself. We usually advise against manipulating the Messenger with CSS as this might break other features in your Messenger.
Would be an option for you to add an URL rule instead? So you can show the bot depending on the ID. Although this would only work if you have any kind of pattern in your ID or if you don’t have many different IDs.